@company-semantics/contracts 0.123.0 → 0.125.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/src/chat/index.ts CHANGED
@@ -46,6 +46,9 @@ export type {
46
46
  CreateShareResponse,
47
47
  ListSharesResponse,
48
48
  UpdateShareResponse,
49
+ ChatMessage,
50
+ ChatDetail,
51
+ GetChatResponse,
49
52
  } from './types'
50
53
 
51
54
  // =============================================================================
@@ -81,6 +84,9 @@ export {
81
84
  CreateShareResponseSchema,
82
85
  ListSharesResponseSchema,
83
86
  UpdateShareResponseSchema,
87
+ ChatMessageSchema,
88
+ ChatDetailSchema,
89
+ GetChatResponseSchema,
84
90
  } from './schemas'
85
91
 
86
92
  // Runtime profile types and constants
@@ -153,6 +153,20 @@ export const ChatSseEventSchema = z.discriminatedUnion('type', [
153
153
  InvalidateChatListEventSchema,
154
154
  ])
155
155
 
156
+ // =============================================================================
157
+ // Message Types
158
+ // =============================================================================
159
+
160
+ /** Individual message in a chat, as returned by GET /api/chats/:id. */
161
+ export const ChatMessageSchema = z.object({
162
+ id: z.string(),
163
+ role: z.enum(['user', 'assistant']),
164
+ content: z.string(),
165
+ parts: z.array(z.unknown()).optional(),
166
+ sequenceNumber: z.number().int(),
167
+ createdAt: IsoDateString,
168
+ })
169
+
156
170
  // =============================================================================
157
171
  // HTTP Response Schemas
158
172
  // =============================================================================
@@ -192,3 +206,24 @@ export const ListSharesResponseSchema = z.object({
192
206
  export const UpdateShareResponseSchema = z.object({
193
207
  share: ChatShareInfoSchema,
194
208
  })
209
+
210
+ /**
211
+ * Chat detail object in GET /api/chats/:id response.
212
+ * Extends the base summary with interactionId (needed for append-on-edit flows).
213
+ */
214
+ export const ChatDetailSchema = z.object({
215
+ id: z.string(),
216
+ title: z.string(),
217
+ interactionId: z.string(),
218
+ pinnedAt: IsoDateString.nullable().optional(),
219
+ titleSource: TitleSourceSchema.nullable().optional(),
220
+ titleGeneratedAt: IsoDateString.nullable().optional(),
221
+ createdAt: IsoDateString,
222
+ updatedAt: IsoDateString,
223
+ })
224
+
225
+ /** Response for GET /api/chats/:id */
226
+ export const GetChatResponseSchema = z.object({
227
+ chat: ChatDetailSchema,
228
+ messages: z.array(ChatMessageSchema),
229
+ })
package/src/chat/types.ts CHANGED
@@ -34,6 +34,9 @@ import {
34
34
  CreateShareResponseSchema,
35
35
  ListSharesResponseSchema,
36
36
  UpdateShareResponseSchema,
37
+ ChatMessageSchema,
38
+ ChatDetailSchema,
39
+ GetChatResponseSchema,
37
40
  } from './schemas'
38
41
 
39
42
  // =============================================================================
@@ -259,3 +262,12 @@ export type ListSharesResponse = z.infer<typeof ListSharesResponseSchema>
259
262
 
260
263
  /** Response for PATCH /api/shares/:shareId */
261
264
  export type UpdateShareResponse = z.infer<typeof UpdateShareResponseSchema>
265
+
266
+ /** Individual message in a chat response (GET /api/chats/:id). */
267
+ export type ChatMessage = z.infer<typeof ChatMessageSchema>
268
+
269
+ /** Chat detail object in GET /api/chats/:id — includes interactionId for append-on-edit flows. */
270
+ export type ChatDetail = z.infer<typeof ChatDetailSchema>
271
+
272
+ /** Response for GET /api/chats/:id */
273
+ export type GetChatResponse = z.infer<typeof GetChatResponseSchema>
@@ -30,5 +30,29 @@ export type { AvatarSource, ResolvedAvatar } from './avatar';
30
30
  export { generateInitials, resolveAvatar } from './avatar';
31
31
 
32
32
  // Response Schemas (Zod) - canonical location per ADR-CONT-044
33
- export { MeResponseSchema, AuthStartResponseSchema, AuthVerifyResponseSchema, SsoConfigResponseSchema, ProfileResponseSchema } from './schemas';
34
- export type { MeResponse, AuthStartResponse, AuthVerifyResponse, SsoConfigResponse, ProfileResponse } from './schemas';
33
+ export {
34
+ MeResponseSchema,
35
+ AuthStartResponseSchema,
36
+ AuthVerifyResponseSchema,
37
+ SsoConfigResponseSchema,
38
+ ProfileResponseSchema,
39
+ AccountSessionListSchema,
40
+ AccountSessionRevokeResponseSchema,
41
+ AccountDeletionEligibilityResponseSchema,
42
+ AccountDeleteResponseSchema,
43
+ AccountConfirmDeletionResponseSchema,
44
+ AccountCancelDeletionResponseSchema,
45
+ } from './schemas';
46
+ export type {
47
+ MeResponse,
48
+ AuthStartResponse,
49
+ AuthVerifyResponse,
50
+ SsoConfigResponse,
51
+ ProfileResponse,
52
+ AccountSessionList,
53
+ AccountSessionRevokeResponse,
54
+ AccountDeletionEligibilityResponse,
55
+ AccountDeleteResponse,
56
+ AccountConfirmDeletionResponse,
57
+ AccountCancelDeletionResponse,
58
+ } from './schemas';
@@ -137,3 +137,88 @@ export const ProfileResponseSchema = z.object({
137
137
  });
138
138
 
139
139
  export type ProfileResponse = z.infer<typeof ProfileResponseSchema>;
140
+
141
+ // ---------------------------------------------------------------------------
142
+ // GET /api/account/sessions
143
+ // ---------------------------------------------------------------------------
144
+
145
+ const AccountSessionSchema = z.object({
146
+ id: z.string(),
147
+ deviceLabel: z.string(),
148
+ ipAddress: z.string().nullable(),
149
+ createdAt: z.string(),
150
+ lastActiveAt: z.string().nullable(),
151
+ isCurrent: z.boolean(),
152
+ });
153
+
154
+ export const AccountSessionListSchema = z.object({
155
+ sessions: z.array(AccountSessionSchema),
156
+ });
157
+
158
+ export type AccountSessionList = z.infer<typeof AccountSessionListSchema>;
159
+
160
+ // ---------------------------------------------------------------------------
161
+ // DELETE /api/account/sessions/:sessionId
162
+ // ---------------------------------------------------------------------------
163
+
164
+ export const AccountSessionRevokeResponseSchema = z.object({
165
+ success: z.literal(true),
166
+ ok: z.literal(true),
167
+ });
168
+
169
+ export type AccountSessionRevokeResponse = z.infer<typeof AccountSessionRevokeResponseSchema>;
170
+
171
+ // ---------------------------------------------------------------------------
172
+ // GET /api/account/deletion-eligibility
173
+ // ---------------------------------------------------------------------------
174
+
175
+ const DeletionBlockerSchema = z.discriminatedUnion('type', [
176
+ z.object({
177
+ type: z.literal('sole_workspace_owner'),
178
+ workspaceId: z.string(),
179
+ workspaceName: z.string(),
180
+ }),
181
+ z.object({
182
+ type: z.literal('active_legal_hold'),
183
+ holdId: z.string(),
184
+ }),
185
+ ]);
186
+
187
+ export const AccountDeletionEligibilityResponseSchema = z.object({
188
+ eligible: z.boolean(),
189
+ blockers: z.array(DeletionBlockerSchema),
190
+ });
191
+
192
+ export type AccountDeletionEligibilityResponse = z.infer<typeof AccountDeletionEligibilityResponseSchema>;
193
+
194
+ // ---------------------------------------------------------------------------
195
+ // POST /api/account/delete
196
+ // ---------------------------------------------------------------------------
197
+
198
+ export const AccountDeleteResponseSchema = z.object({
199
+ status: z.literal('confirmation_pending'),
200
+ message: z.string(),
201
+ });
202
+
203
+ export type AccountDeleteResponse = z.infer<typeof AccountDeleteResponseSchema>;
204
+
205
+ // ---------------------------------------------------------------------------
206
+ // POST /api/account/confirm-deletion
207
+ // ---------------------------------------------------------------------------
208
+
209
+ export const AccountConfirmDeletionResponseSchema = z.object({
210
+ status: z.literal('pending_deletion'),
211
+ });
212
+
213
+ export type AccountConfirmDeletionResponse = z.infer<typeof AccountConfirmDeletionResponseSchema>;
214
+
215
+ // ---------------------------------------------------------------------------
216
+ // POST /api/account/cancel-deletion
217
+ // ---------------------------------------------------------------------------
218
+
219
+ export const AccountCancelDeletionResponseSchema = z.object({
220
+ success: z.literal(true),
221
+ ok: z.literal(true),
222
+ });
223
+
224
+ export type AccountCancelDeletionResponse = z.infer<typeof AccountCancelDeletionResponseSchema>;
package/src/org/index.ts CHANGED
@@ -201,3 +201,17 @@ export type {
201
201
  OwnershipTransferResponse,
202
202
  OwnershipTransferPreview,
203
203
  } from './schemas';
204
+
205
+ // Org-ops response schemas (PRD-00449)
206
+ export {
207
+ OrgSystemEventsListSchema,
208
+ AcknowledgeSystemEventResponseSchema,
209
+ OrgBudgetConfigSchema,
210
+ OrgUsageResponseSchema,
211
+ } from './schemas';
212
+ export type {
213
+ OrgSystemEventsList,
214
+ AcknowledgeSystemEventResponse,
215
+ OrgBudgetConfig,
216
+ OrgUsageResponse,
217
+ } from './schemas';
@@ -502,3 +502,109 @@ export const OwnershipTransferPreviewSchema = z.object({
502
502
  });
503
503
 
504
504
  export type OwnershipTransferPreview = z.infer<typeof OwnershipTransferPreviewSchema>;
505
+
506
+ // ---------------------------------------------------------------------------
507
+ // GET /api/org/system-events
508
+ // ---------------------------------------------------------------------------
509
+
510
+ const OrgSystemEventSchema = z.object({
511
+ id: z.string(),
512
+ type: z.string(),
513
+ payload: z.unknown(),
514
+ createdAt: z.string(),
515
+ });
516
+
517
+ export const OrgSystemEventsListSchema = z.object({
518
+ events: z.array(OrgSystemEventSchema),
519
+ });
520
+
521
+ export type OrgSystemEventsList = z.infer<typeof OrgSystemEventsListSchema>;
522
+
523
+ // ---------------------------------------------------------------------------
524
+ // POST /api/org/system-events/:id/acknowledge
525
+ // ---------------------------------------------------------------------------
526
+
527
+ export const AcknowledgeSystemEventResponseSchema = z.object({
528
+ success: z.literal(true),
529
+ });
530
+
531
+ export type AcknowledgeSystemEventResponse = z.infer<typeof AcknowledgeSystemEventResponseSchema>;
532
+
533
+ // ---------------------------------------------------------------------------
534
+ // GET /api/orgs/:orgId/budget-config
535
+ // PUT /api/orgs/:orgId/budget-config
536
+ // ---------------------------------------------------------------------------
537
+
538
+ export const OrgBudgetConfigSchema = z.object({
539
+ monthlyBudgetUsd: z.number().nullable(),
540
+ maxCostPerExecution: z.number().nullable(),
541
+ agenticMaxSteps: z.number().int().nullable(),
542
+ alertThresholdPct: z.number().int(),
543
+ enabled: z.boolean(),
544
+ });
545
+
546
+ export type OrgBudgetConfig = z.infer<typeof OrgBudgetConfigSchema>;
547
+
548
+ // ---------------------------------------------------------------------------
549
+ // GET /api/orgs/:orgId/ai-usage
550
+ // Matches UnifiedUsageResponse from usage/types.ts
551
+ // ---------------------------------------------------------------------------
552
+
553
+ const UnifiedUsageSummarySchema = z.object({
554
+ executions: z.number(),
555
+ totalCostUsd: z.string(),
556
+ totalTokens: z.number(),
557
+ avgDurationMs: z.number(),
558
+ failureRate: z.number(),
559
+ });
560
+
561
+ const UnifiedDailyUsageSchema = z.object({
562
+ date: z.string(),
563
+ executions: z.number(),
564
+ totalCostUsd: z.string(),
565
+ });
566
+
567
+ const UnifiedProfileUsageSchema = z.object({
568
+ profile: z.string(),
569
+ executions: z.number(),
570
+ percentOfTotal: z.number(),
571
+ totalCostUsd: z.string(),
572
+ avgDurationMs: z.number(),
573
+ failureRate: z.number(),
574
+ });
575
+
576
+ const UnifiedUserUsageSchema = z.object({
577
+ userId: z.string(),
578
+ email: z.string(),
579
+ executions: z.number(),
580
+ totalCostUsd: z.string(),
581
+ totalTokens: z.number(),
582
+ favoriteProfile: z.string(),
583
+ });
584
+
585
+ const UnifiedModelUsageSchema = z.object({
586
+ model: z.string(),
587
+ provider: z.string(),
588
+ totalTokens: z.number(),
589
+ estimatedCostUsd: z.string(),
590
+ requestCount: z.number(),
591
+ });
592
+
593
+ const UnifiedFeatureUsageSchema = z.object({
594
+ feature: z.string(),
595
+ totalTokens: z.number(),
596
+ estimatedCostUsd: z.string(),
597
+ requestCount: z.number(),
598
+ });
599
+
600
+ export const OrgUsageResponseSchema = z.object({
601
+ period: z.object({ start: z.string(), end: z.string() }),
602
+ summary: UnifiedUsageSummarySchema,
603
+ daily: z.array(UnifiedDailyUsageSchema),
604
+ byProfile: z.array(UnifiedProfileUsageSchema),
605
+ byUser: z.array(UnifiedUserUsageSchema),
606
+ byModel: z.array(UnifiedModelUsageSchema),
607
+ byFeature: z.array(UnifiedFeatureUsageSchema),
608
+ });
609
+
610
+ export type OrgUsageResponse = z.infer<typeof OrgUsageResponseSchema>;