@company-semantics/contracts 0.76.0 → 0.78.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.76.0",
3
+ "version": "0.78.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/chat/index.ts CHANGED
@@ -45,3 +45,7 @@ export type {
45
45
  LegacyChatListInvalidatedEvent,
46
46
  LegacyChatSseEvent,
47
47
  } from './types'
48
+
49
+ // Runtime profile types and constants
50
+ export type { ChatRuntimeProfile, ChatRuntimeProfileInfo } from './runtime-profile'
51
+ export { CHAT_RUNTIME_PROFILES, DEFAULT_CHAT_RUNTIME_PROFILE } from './runtime-profile'
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Chat runtime profile — user-selectable orchestration strategy.
3
+ *
4
+ * Abstracts vendor and model details from the UI.
5
+ * The profile-to-orchestrator mapping is server-defined.
6
+ *
7
+ * - fast: Low-latency, single-step. AiSdkOrchestrator + gpt-3.5-turbo.
8
+ * - balanced: Default. AiSdkOrchestrator + gpt-4o with tool support.
9
+ * - agentic: Multi-turn agent loop. ClaudeAgentOrchestrator.
10
+ */
11
+ export type ChatRuntimeProfile = 'fast' | 'balanced' | 'agentic'
12
+
13
+ /**
14
+ * Runtime profile metadata for UI rendering.
15
+ * Labels and descriptions are user-facing — no vendor names.
16
+ */
17
+ export interface ChatRuntimeProfileInfo {
18
+ id: ChatRuntimeProfile
19
+ label: string
20
+ description: string
21
+ model: string
22
+ }
23
+
24
+ /**
25
+ * Ordered list of available profiles for UI rendering.
26
+ */
27
+ export const CHAT_RUNTIME_PROFILES: readonly ChatRuntimeProfileInfo[] = [
28
+ { id: 'fast', label: 'Fast', description: 'Single-step, no tools', model: 'gpt-3.5-turbo' },
29
+ { id: 'balanced', label: 'Balanced', description: 'Multi-step with tools', model: 'gpt-4o' },
30
+ { id: 'agentic', label: 'Agentic', description: 'Agent loop, full reasoning', model: 'claude-sonnet-4' },
31
+ ] as const
32
+
33
+ /**
34
+ * Default profile when none is specified in the request.
35
+ */
36
+ export const DEFAULT_CHAT_RUNTIME_PROFILE: ChatRuntimeProfile = 'agentic'
package/src/index.ts CHANGED
@@ -176,8 +176,13 @@ export type {
176
176
  LegacyChatInvalidatedEvent,
177
177
  LegacyChatListInvalidatedEvent,
178
178
  LegacyChatSseEvent,
179
+ // Runtime profile types (PRD-00229)
180
+ ChatRuntimeProfile,
181
+ ChatRuntimeProfileInfo,
179
182
  } from './chat/index'
180
183
 
184
+ export { CHAT_RUNTIME_PROFILES, DEFAULT_CHAT_RUNTIME_PROFILE } from './chat/index'
185
+
181
186
  // Organization domain types
182
187
  // @see ADR-BE-XXX for design rationale (Personal vs Shared Organization Model)
183
188
  export type {
@@ -306,9 +311,14 @@ export type {
306
311
  ConfirmationResponseDataPart,
307
312
  // Execution result types (Phase 5)
308
313
  ExecutionArtifactStatus,
314
+ ExecutionResultSummary,
315
+ ExecutionUndoCapability,
309
316
  ExecutionResultData,
310
317
  ExecutionResultPart,
311
318
  ExecutionResultDataPart,
319
+ // Undo result types (PRD-00203)
320
+ UndoResultData,
321
+ UndoResultDataPart,
312
322
  // Message lifecycle types (Phase 1 streaming)
313
323
  // @see ADR-CONT-027 for design rationale
314
324
  StreamPhase,
@@ -2,6 +2,7 @@
2
2
  * Execution Result Surface Types
3
3
  *
4
4
  * Surfaces for displaying execution results to the user.
5
+ * User-initiated undo is supported with a server-enforced time window.
5
6
  *
6
7
  * EXECUTION MODE INVARIANTS:
7
8
  * - Execution occurs only after confirmation with matching actionId
@@ -9,9 +10,20 @@
9
10
  * - All executions produce audit records (success or failure)
10
11
  * - Execution is synchronous and deterministic
11
12
  * - Tools are explicitly allowlisted per artifact kind
12
- * - No retries, no background work, no rollback
13
13
  * - Failures stop execution immediately
14
14
  *
15
+ * INV-1: ExecutionState is single authority — no redundant status fields.
16
+ * ExecutionResultData carries `state` resolved from ExecutionState.
17
+ * INV-2: Append-only audit model — undo creates a second row with `undo_of`
18
+ * reference. Original execution row is never mutated.
19
+ * INV-3: Undo payload persisted server-side only — never on the wire.
20
+ * Only the undo capability descriptor (availableUntil, kind) is sent.
21
+ * INV-4: Undo is idempotent — second call returns existing result.
22
+ * INV-5: actionId uniqueness per artifact — each artifact kind resolves to
23
+ * at most one execution per actionId.
24
+ * INV-6: Undo race condition — 409 on expired window. Server rejects undo
25
+ * attempts after availableUntil deadline.
26
+ *
15
27
  * @see DECISIONS.md for design rationale
16
28
  */
17
29
 
@@ -25,6 +37,29 @@ export interface ExecutionArtifactStatus {
25
37
  label: string;
26
38
  status: 'success' | 'failed' | 'skipped';
27
39
  error?: string;
40
+ /** Human-readable result summary, e.g. 'Preferred name set to Ian' */
41
+ resultLabel?: string;
42
+ }
43
+
44
+ /**
45
+ * Structured summary for generic UI rendering (executor-provided).
46
+ */
47
+ export interface ExecutionResultSummary {
48
+ /** Human-readable title, e.g. 'Profile Updated' */
49
+ title: string;
50
+ /** Optional description, e.g. 'Preferred name is now Ian' */
51
+ description?: string;
52
+ }
53
+
54
+ /**
55
+ * Undo capability descriptor.
56
+ * Present only if executor supports undo for this action.
57
+ */
58
+ export interface ExecutionUndoCapability {
59
+ /** ISO 8601 deadline — server-authoritative */
60
+ availableUntil: string;
61
+ /** Executor dispatch key, e.g. 'profile.update' */
62
+ kind: string;
28
63
  }
29
64
 
30
65
  /**
@@ -32,8 +67,15 @@ export interface ExecutionArtifactStatus {
32
67
  */
33
68
  export interface ExecutionResultData {
34
69
  actionId: string;
35
- status: 'success' | 'failed';
70
+ /** Execution row ID — required for undo endpoint dispatch */
71
+ executionId: string;
72
+ /** Resolved from ExecutionState — single authority (INV-1) */
73
+ state: 'completed' | 'failed';
36
74
  artifacts: ExecutionArtifactStatus[];
75
+ /** Structured summary for generic UI rendering (executor-provided) */
76
+ summary: ExecutionResultSummary;
77
+ /** Undo capability — present only if executor supports undo. Payload is server-side only (INV-3). */
78
+ undo?: ExecutionUndoCapability; // { availableUntil, kind }
37
79
  }
38
80
 
39
81
  /**
@@ -51,3 +93,30 @@ export interface ExecutionResultDataPart {
51
93
  type: 'data-execution-result';
52
94
  data: ExecutionResultData;
53
95
  }
96
+
97
+ /**
98
+ * Undo result data payload.
99
+ * Returned by POST /api/executions/:id/undo.
100
+ *
101
+ * AUDIT MODEL (INV-2): Original execution row stays `completed`.
102
+ * Undo creates a second row with `undo_of` reference.
103
+ * Two audit events: action + revert, never mutation.
104
+ */
105
+ export interface UndoResultData {
106
+ /** Links back to original action */
107
+ actionId: string;
108
+ /** Original execution row ID */
109
+ executionId: string;
110
+ /** New undo audit row ID (append-only, INV-2) */
111
+ undoExecutionId: string;
112
+ status: 'success' | 'failed';
113
+ error?: string;
114
+ }
115
+
116
+ /**
117
+ * Undo result data part (wire format).
118
+ */
119
+ export interface UndoResultDataPart {
120
+ type: 'data-undo-result';
121
+ data: UndoResultData;
122
+ }
@@ -45,9 +45,13 @@ export type {
45
45
  // Execution result types
46
46
  export type {
47
47
  ExecutionArtifactStatus,
48
+ ExecutionResultSummary,
49
+ ExecutionUndoCapability,
48
50
  ExecutionResultData,
49
51
  ExecutionResultPart,
50
52
  ExecutionResultDataPart,
53
+ UndoResultData,
54
+ UndoResultDataPart,
51
55
  } from './execution'
52
56
 
53
57
  // Lifecycle types (Phase 1 streaming)
@@ -95,6 +95,11 @@ export interface PreviewData {
95
95
  description?: string
96
96
  /** The artifacts that would be created/sent/modified */
97
97
  artifacts: PreviewArtifact[]
98
+ /** Action type for bridge routing and executor dispatch (e.g. 'update_profile', 'send_message', 'manage_integration') */
99
+ actionType?: string
100
+ /** Top-level execution target for bridge routing and executor dispatch.
101
+ * Distinct from PreviewArtifact.metadata.target (per-artifact UI metadata). */
102
+ target?: string
98
103
  }
99
104
 
100
105
  /**
@@ -18,7 +18,12 @@ import type {
18
18
  ConfirmationResponseData,
19
19
  ConfirmationResponseDataPart,
20
20
  } from './confirmation'
21
- import type { ExecutionResultData, ExecutionResultDataPart } from './execution'
21
+ import type {
22
+ ExecutionResultData,
23
+ ExecutionResultDataPart,
24
+ UndoResultData,
25
+ UndoResultDataPart,
26
+ } from './execution'
22
27
  import type {
23
28
  MessageStartDataPart,
24
29
  MessageCompleteDataPart,
@@ -124,6 +129,25 @@ export const WireSurfaceBuilder = {
124
129
  }
125
130
  },
126
131
 
132
+ /**
133
+ * Build an undo result data part for streaming.
134
+ * Reports the outcome of an undo operation.
135
+ *
136
+ * INVARIANTS:
137
+ * - actionId must match the original executed action
138
+ * - Original execution row stays immutable (INV-2 append-only)
139
+ * - undoExecutionId references the new undo audit row
140
+ *
141
+ * @param data - Undo result data
142
+ * @returns Wire-format undo result part ready for stream
143
+ */
144
+ undoResult(data: UndoResultData): UndoResultDataPart {
145
+ return {
146
+ type: 'data-undo-result',
147
+ data,
148
+ }
149
+ },
150
+
127
151
  // =========================================================================
128
152
  // Message Lifecycle Events (Phase 1)
129
153
  // =========================================================================
package/src/org/types.ts CHANGED
@@ -396,12 +396,17 @@ export interface ChangeMemberRoleRequest {
396
396
  * INVARIANT: Auth policy changes do not affect existing sessions
397
397
  * (unless explicitly revoked via separate action).
398
398
  * @see Phase 3 Invariant #11: No retroactive enforcement
399
+ *
400
+ * EXCEPTION (ADR-BE-071): SSO credential reset or provider switch revokes
401
+ * SSO-authenticated sessions because the trust anchor is destroyed.
399
402
  */
400
403
  export interface OrgAuthPolicy {
401
404
  /** Whether SSO is required for all members */
402
405
  requireSSO: boolean;
403
406
  /** List of allowed authentication providers (e.g., 'google', 'microsoft', 'okta') */
404
407
  allowedProviders: string[];
408
+ /** True when the requesting admin's own SSO session was revoked by this operation (ADR-BE-071) */
409
+ selfRevoked?: boolean;
405
410
  }
406
411
 
407
412
  /**