@company-semantics/contracts 0.60.0 → 0.60.2
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 +5 -1
- package/src/chat/index.ts +11 -0
- package/src/chat/types.ts +97 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"types": "./src/ralph/index.ts",
|
|
41
41
|
"default": "./src/ralph/index.ts"
|
|
42
42
|
},
|
|
43
|
+
"./chat": {
|
|
44
|
+
"types": "./src/chat/index.ts",
|
|
45
|
+
"default": "./src/chat/index.ts"
|
|
46
|
+
},
|
|
43
47
|
"./schemas/guard-result.schema.json": "./schemas/guard-result.schema.json"
|
|
44
48
|
},
|
|
45
49
|
"types": "./src/index.ts",
|
package/src/chat/index.ts
CHANGED
|
@@ -17,4 +17,15 @@ export type {
|
|
|
17
17
|
SharedChatMessage,
|
|
18
18
|
CreateShareRequest,
|
|
19
19
|
UpdateShareRequest,
|
|
20
|
+
// Chat lifecycle types
|
|
21
|
+
ChatStatus,
|
|
22
|
+
TitleSource,
|
|
23
|
+
ChatListFilters,
|
|
24
|
+
ChatSummaryExtended,
|
|
25
|
+
TitleGenerationRequest,
|
|
26
|
+
TitleGenerationResponse,
|
|
27
|
+
ChatSseEvent,
|
|
28
|
+
ChatUpdateEvent,
|
|
29
|
+
// Chat creation event (server-first navigation contract)
|
|
30
|
+
ChatCreatedEvent,
|
|
20
31
|
} from './types'
|
package/src/chat/types.ts
CHANGED
|
@@ -103,3 +103,100 @@ export interface UpdateShareRequest {
|
|
|
103
103
|
/** If true, update snapshot to include new messages added since share creation */
|
|
104
104
|
updateSnapshot?: boolean
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
// =============================================================================
|
|
108
|
+
// Chat Lifecycle Types
|
|
109
|
+
// =============================================================================
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Chat status for lifecycle management.
|
|
113
|
+
* - active: Normal visible chat
|
|
114
|
+
* - archived: Hidden from main list, still searchable
|
|
115
|
+
*/
|
|
116
|
+
export type ChatStatus = 'active' | 'archived'
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Title source - tracks how the title was set.
|
|
120
|
+
* - auto: Generated automatically by LLM
|
|
121
|
+
* - manual: Set by user (disables future auto-generation)
|
|
122
|
+
*/
|
|
123
|
+
export type TitleSource = 'auto' | 'manual'
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Filters for listing chats.
|
|
127
|
+
*/
|
|
128
|
+
export interface ChatListFilters {
|
|
129
|
+
/** Search query - matches against title */
|
|
130
|
+
search?: string
|
|
131
|
+
/** Filter by status. Defaults to 'active' */
|
|
132
|
+
status?: ChatStatus | 'all'
|
|
133
|
+
/** Include pinned chats at top */
|
|
134
|
+
includePinned?: boolean
|
|
135
|
+
/** Pagination limit */
|
|
136
|
+
limit?: number
|
|
137
|
+
/** Pagination offset */
|
|
138
|
+
offset?: number
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Extended chat summary with pin/archive/title status.
|
|
143
|
+
*/
|
|
144
|
+
export interface ChatSummaryExtended extends ChatSummary {
|
|
145
|
+
status: ChatStatus
|
|
146
|
+
/** If pinned, when it was pinned */
|
|
147
|
+
pinnedAt: string | null
|
|
148
|
+
/** How the title was set: 'auto' or 'manual' */
|
|
149
|
+
titleSource: TitleSource | null
|
|
150
|
+
/** When auto-title was generated (null if never auto-generated) */
|
|
151
|
+
titleGeneratedAt: string | null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Request to generate a title for a chat.
|
|
156
|
+
*/
|
|
157
|
+
export interface TitleGenerationRequest {
|
|
158
|
+
chatId: string
|
|
159
|
+
/** First few messages for context */
|
|
160
|
+
messages: Array<{ role: 'user' | 'assistant'; content: string }>
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Response from title generation.
|
|
165
|
+
*/
|
|
166
|
+
export interface TitleGenerationResponse {
|
|
167
|
+
title: string
|
|
168
|
+
/** Whether this was auto-generated */
|
|
169
|
+
isAutoGenerated: boolean
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* SSE event types for chat updates (convention locked).
|
|
174
|
+
* Client receives these and handles accordingly.
|
|
175
|
+
*/
|
|
176
|
+
export type ChatSseEvent =
|
|
177
|
+
| { type: 'chat.invalidated'; chatId: string; timestamp: string }
|
|
178
|
+
| { type: 'chat.list.invalidated'; timestamp: string }
|
|
179
|
+
| ChatCreatedEvent
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Emitted exactly once after a chat is successfully persisted.
|
|
183
|
+
* Used to transition the client from /new to /chat/:id.
|
|
184
|
+
*
|
|
185
|
+
* INV-EVENT-1: This event is emitted exactly once per successful stream.
|
|
186
|
+
* INV-PERSIST-1: Chat record + messages are committed atomically before this event.
|
|
187
|
+
*/
|
|
188
|
+
export interface ChatCreatedEvent {
|
|
189
|
+
type: 'chat.created'
|
|
190
|
+
/** Canonical server-generated UUID - use this for URLs */
|
|
191
|
+
chatId: string
|
|
192
|
+
/** Client-provided ID for correlation (optional) */
|
|
193
|
+
interactionId?: string
|
|
194
|
+
/** Auto-generated title from first message */
|
|
195
|
+
title?: string
|
|
196
|
+
timestamp: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Convenience alias for backwards compat.
|
|
201
|
+
*/
|
|
202
|
+
export type ChatUpdateEvent = ChatSseEvent
|
package/src/index.ts
CHANGED