@unieai/rabi-message-feedback 0.2.1-rc.3 → 0.2.2-rc.5

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/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Aufzeichnung der Nachrichtenrückmeldung",
4
+ "description": "Erfassen Sie die Vorlieben und Abneigungen der Benutzer sowie zusätzliche Kommentare zu den Antworten des Assistenten."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Registro de comentarios de mensajes",
4
+ "description": "Registre los gustos, disgustos y comentarios adicionales de los usuarios sobre las respuestas del asistente."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Enregistrement des commentaires sur les messages",
4
+ "description": "Enregistrez les goûts, les aversions et les commentaires supplémentaires des utilisateurs sur les réponses de l'assistant."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "メッセージフィードバック記録",
4
+ "description": "アシスタントの回答に対する肯定・否定の評価と追加の意見を記録します。"
5
+ }
6
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Registro de feedback de mensagem",
4
+ "description": "Registre o que os usuários gostam, não gostam e comentários adicionais nas respostas do assistente."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Запись обратной связи по сообщению",
4
+ "description": "Записывайте лайки и антипатии пользователей, а также дополнительные комментарии к ответам помощника."
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unieai/rabi-message-feedback",
3
3
  "description": "Canonical Session-log ratings and notes for finalized assistant messages",
4
- "version": "0.2.1-rc.3",
4
+ "version": "0.2.2-rc.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -34,24 +34,28 @@
34
34
  "lib/index.js",
35
35
  "lib/types/**/*.js",
36
36
  "lib/types/**/*.d.ts",
37
+ "lib/types/**/*.d.ts.map",
38
+ "lib/**/*.js.map",
37
39
  "lib/typert.host.js",
38
40
  "lib/typert.host.d.ts",
39
41
  "lib/typert.remote-client.js",
40
42
  "lib/typert.remote-client.d.ts",
43
+ "lib/typert.remote-client.d.ts.map",
44
+ "src",
41
45
  "README.md"
42
46
  ],
43
47
  "license": "MIT",
44
48
  "peerDependencies": {
45
- "@unieai/rabi-brand": "0.2.1-rc.3",
46
- "@unieai/rabi-llm": "0.2.1-rc.3",
47
- "@unieai/rabi-session": "0.2.1-rc.3",
48
- "@unieai/rabi-session-persistence": "0.2.1-rc.3",
49
- "@unieai/rabi-typert-protocol": "0.2.1-rc.3",
50
- "@unieai/cordis": "4.0.5",
51
- "@unieai/rabi-command-feedback": "0.2.1-rc.3"
49
+ "@unieai/rabi-brand": "0.2.2-rc.5",
50
+ "@unieai/rabi-llm": "0.2.2-rc.5",
51
+ "@unieai/rabi-session": "0.2.2-rc.5",
52
+ "@unieai/rabi-session-persistence": "0.2.2-rc.5",
53
+ "@unieai/rabi-typert-protocol": "0.2.2-rc.5",
54
+ "@unieai/cordis": "4.1.0",
55
+ "@unieai/rabi-command-feedback": "0.2.2-rc.5"
52
56
  },
53
57
  "dependencies": {
54
- "@unieai/schemastery": "3.18.5",
55
- "zod": "4.4.3"
58
+ "@unieai/schemastery": "3.19.0",
59
+ "zod": "4.6.6"
56
60
  }
57
61
  }
package/src/index.ts ADDED
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Canonical Session-log feedback for finalized assistant messages.
3
+ * @module @unieai/rabi-message-feedback
4
+ */
5
+
6
+ import { Buffer } from 'node:buffer'
7
+ import { randomUUID } from 'node:crypto'
8
+ import { isDeepStrictEqual } from 'node:util'
9
+ import { Context, Service } from '@unieai/cordis'
10
+ import s from '@unieai/schemastery'
11
+ import { z } from 'zod'
12
+ import { FEEDBACK_CATEGORIES } from '@unieai/rabi-command-feedback'
13
+ import { SessionSeq } from '@unieai/rabi-session/types'
14
+ import { deriveEventMessage, isAppendSurfaceEvent } from '@unieai/rabi-session/surface'
15
+ import type { SessionEvent, SessionId } from '@unieai/rabi-session/types'
16
+ import type {} from '@unieai/rabi-session'
17
+ import type { SessionInspection } from '@unieai/rabi-session-persistence'
18
+ import { TypertRemoteService, Remote } from '@unieai/rabi-typert-protocol'
19
+ import type {
20
+ MessageFeedbackDeleteRequest,
21
+ MessageFeedbackDeleteResult,
22
+ MessageFeedbackFailure,
23
+ MessageFeedbackItem,
24
+ MessageFeedbackListRequest,
25
+ MessageFeedbackListResult,
26
+ MessageFeedbackNoteBlank,
27
+ MessageFeedbackNoteTooLarge,
28
+ MessageFeedbackPutRequest,
29
+ MessageFeedbackPutResult,
30
+ MessageFeedbackRejected,
31
+ MessageFeedbackSessionNotFound,
32
+ MessageFeedbackSuccess,
33
+ MessageFeedbackVersion,
34
+ MessageFeedbackVersionConflict,
35
+ } from './types.ts'
36
+
37
+ export type * from './types.ts'
38
+
39
+ /** Required deployment policy for optional notes. */
40
+ export interface Config {
41
+ /** Maximum UTF-8 byte length accepted for one note. */
42
+ readonly maxNoteBytes: number
43
+ }
44
+
45
+ declare module '@unieai/cordis' {
46
+ interface Context {
47
+ messageFeedback: MessageFeedbackService
48
+ }
49
+ interface Events {
50
+ /**
51
+ * Observe a durable cold feedback mutation without publishing a live Session.
52
+ * Observers run before write ownership is released and must not await
53
+ * another message-feedback operation for this Session. The payload is borrowed
54
+ * read-only; deep-clone it before transferring ownership (for example, to Session.fromRestore).
55
+ * @param inspection - committed canonical prefix, including the feedback as its last event.
56
+ * @mode parallel
57
+ */
58
+ 'feedback/committed'(inspection: SessionInspection): void
59
+ }
60
+ }
61
+
62
+ const timestamp = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
63
+ const itemSchema = z.object({
64
+ messageId: z.string().min(1),
65
+ rating: z.enum(['positive', 'negative']),
66
+ note: z.string().refine(note => note.trim().length > 0).optional(),
67
+ category: z.enum(FEEDBACK_CATEGORIES).optional(),
68
+ version: z.uuid(),
69
+ createdAt: timestamp,
70
+ updatedAt: timestamp,
71
+ }).refine(item => item.updatedAt >= item.createdAt)
72
+ const putSchema = z.object({ sessionId: z.string().min(1), item: itemSchema })
73
+ const deleteSchema = z.object({ sessionId: z.string().min(1), messageId: z.string().min(1) })
74
+
75
+ type FeedbackEvent = SessionEvent<'feedback/message-put' | 'feedback/message-delete'>
76
+ type Mutation = Pick<SessionEvent<'feedback/message-put'>, 'type' | 'data'>
77
+ | Pick<SessionEvent<'feedback/message-delete'>, 'type' | 'data'>
78
+ type Append = (event?: Mutation) => Promise<void>
79
+ type MissingSession = MessageFeedbackRejected<MessageFeedbackSessionNotFound>
80
+ type ResolvedNote = MessageFeedbackSuccess<string | undefined>
81
+ | MessageFeedbackRejected<MessageFeedbackNoteBlank | MessageFeedbackNoteTooLarge>
82
+
83
+ /** Return a caller-owned immutable value, detached from the log. */
84
+ function snapshotItem(item: MessageFeedbackItem): MessageFeedbackItem {
85
+ return Object.freeze({ ...item })
86
+ }
87
+
88
+ function success<T>(value: T): MessageFeedbackSuccess<T> {
89
+ return Object.freeze({ ok: true, value })
90
+ }
91
+
92
+ function rejected<E extends MessageFeedbackFailure>(error: E): MessageFeedbackRejected<E> {
93
+ return Object.freeze({ ok: false, error: Object.freeze(error) })
94
+ }
95
+
96
+ /** Validate persisted payloads before deriving current, Session-owned feedback. */
97
+ function currentItems(sessionId: SessionId, events: readonly SessionEvent[]): MessageFeedbackItem[] {
98
+ const items = new Map<MessageFeedbackItem['messageId'], MessageFeedbackItem>()
99
+ for (const event of events) {
100
+ switch (event.type) {
101
+ case 'feedback/message-put':
102
+ putSchema.parse(event.data)
103
+ if (event.data.sessionId === sessionId) items.set(event.data.item.messageId, event.data.item)
104
+ break
105
+ case 'feedback/message-delete':
106
+ deleteSchema.parse(event.data)
107
+ if (event.data.sessionId === sessionId) items.delete(event.data.messageId)
108
+ break
109
+ default:
110
+ // Other plugins' events do not change message feedback.
111
+ break
112
+ }
113
+ }
114
+ return [...items.values()]
115
+ }
116
+
117
+ /** Session-log service; cold operations never construct a Session or Agent. */
118
+ export class MessageFeedbackService extends TypertRemoteService {
119
+ static inject = ['sessionPersistence', 'sessions']
120
+
121
+ /** Loader validation for the required note-size policy. */
122
+ static Config: s<Config> = s.object({
123
+ maxNoteBytes: s.number().step(1).min(1).required(),
124
+ })
125
+
126
+ private readonly maxNoteBytes: number
127
+ private readonly operationTails = new Map<SessionId, Promise<void>>()
128
+ private mutationAdmissionOpen = true
129
+
130
+ /**
131
+ * @param ctx - Host context carrying Session persistence and live owners.
132
+ * @param config - Required note-size policy.
133
+ */
134
+ constructor(ctx: Context, config: Config) {
135
+ super(ctx, 'messageFeedback')
136
+ if (!Number.isSafeInteger(config.maxNoteBytes) || config.maxNoteBytes < 1) {
137
+ throw new TypeError('message-feedback: maxNoteBytes must be a positive safe integer')
138
+ }
139
+ this.maxNoteBytes = config.maxNoteBytes
140
+ }
141
+
142
+ protected [Service.init](): void {
143
+ this.ctx.effect(() => async () => {
144
+ this.mutationAdmissionOpen = false
145
+ await Promise.all(this.operationTails.values())
146
+ }, 'message-feedback.drain')
147
+ }
148
+
149
+ /**
150
+ * Read current feedback from the canonical log.
151
+ * @param request - Session to inspect.
152
+ * @returns immutable items or a definite persistence miss.
153
+ */
154
+ @Remote('list')
155
+ list(request: MessageFeedbackListRequest): Promise<MessageFeedbackListResult> {
156
+ return this.enqueue(request.sessionId, () => this.withSession(request.sessionId, false, events =>
157
+ success(Object.freeze({ items: Object.freeze(currentItems(request.sessionId, events).map(snapshotItem)) }))))
158
+ }
159
+
160
+ /**
161
+ * Create or replace feedback after checking its current version.
162
+ * Matching no-ops retain the version and append no event.
163
+ * @param request - Target, desired value, and observed item version.
164
+ * @returns the durable item or an explicit business failure.
165
+ */
166
+ @Remote('put')
167
+ put(request: MessageFeedbackPutRequest): Promise<MessageFeedbackPutResult> {
168
+ const note = this.resolveNote(request.note)
169
+ if (!note.ok) return Promise.resolve(note)
170
+ return this.enqueue(request.sessionId, () => this.withSession(request.sessionId, true, async (events, append) => {
171
+ const items = currentItems(request.sessionId, events)
172
+ if (!events.some(event => event.type === 'assistant/message'
173
+ && isAppendSurfaceEvent(event)
174
+ && deriveEventMessage(event)?.id === request.messageId)) {
175
+ return rejected({ code: 'target-not-found', sessionId: request.sessionId, messageId: request.messageId })
176
+ }
177
+ const existing = items.find(item => item.messageId === request.messageId)
178
+ if (request.ifVersion !== (existing?.version ?? null)) {
179
+ return rejected(this.versionConflict(existing ?? null))
180
+ }
181
+ if (existing !== undefined && existing.rating === request.rating && existing.note === note.value
182
+ && existing.category === request.category) {
183
+ await append()
184
+ return success(snapshotItem(existing))
185
+ }
186
+ const now = Date.now()
187
+ const item: MessageFeedbackItem = {
188
+ messageId: request.messageId,
189
+ rating: request.rating,
190
+ ...(note.value === undefined ? {} : { note: note.value }),
191
+ ...(request.category === undefined ? {} : { category: request.category }),
192
+ version: randomUUID() as MessageFeedbackVersion,
193
+ createdAt: existing?.createdAt ?? now,
194
+ updatedAt: existing === undefined ? now : Math.max(now, existing.updatedAt),
195
+ }
196
+ await append({ type: 'feedback/message-put', data: { sessionId: request.sessionId, item } })
197
+ return success(snapshotItem(item))
198
+ }))
199
+ }
200
+
201
+ /**
202
+ * Delete one item after checking its version; absence succeeds without an event.
203
+ * @param request - Session, message, and observed item version.
204
+ * @returns the stable absent postcondition or an explicit failure.
205
+ */
206
+ @Remote('delete')
207
+ delete(request: MessageFeedbackDeleteRequest): Promise<MessageFeedbackDeleteResult> {
208
+ return this.enqueue(request.sessionId, () => this.withSession(request.sessionId, true, async (events, append) => {
209
+ const existing = currentItems(request.sessionId, events).find(item => item.messageId === request.messageId)
210
+ if (existing !== undefined) {
211
+ if (request.ifVersion !== existing.version) return rejected(this.versionConflict(existing))
212
+ await append({ type: 'feedback/message-delete', data: { sessionId: request.sessionId, messageId: request.messageId } })
213
+ } else {
214
+ await append()
215
+ }
216
+ return success(Object.freeze({ absent: true as const }))
217
+ }))
218
+ }
219
+
220
+ /** Hold cold write ownership across read/compare/append; use live owners directly. */
221
+ private async withSession<T>(
222
+ sessionId: SessionId,
223
+ write: boolean,
224
+ operation: (events: readonly SessionEvent[], append: Append) => T | Promise<T>,
225
+ ): Promise<T | MissingSession> {
226
+ if (this.ctx.sessions.get(sessionId) === undefined
227
+ && await this.ctx.sessionPersistence.stat(sessionId) === undefined
228
+ && this.ctx.sessions.get(sessionId) === undefined) {
229
+ return rejected({ code: 'session-not-found', sessionId })
230
+ }
231
+ const live = this.ctx.sessions.get(sessionId)
232
+ if (live !== undefined) {
233
+ // oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
234
+ return operation(live.snapshotEvents(), async (event) => {
235
+ if (event !== undefined) {
236
+ live.append(event.type, event.data)
237
+ }
238
+ // oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
239
+ const last = live.snapshotEvents().at(-1)
240
+ if (!(await this.ctx.sessions.flush(live))) {
241
+ throw new Error(
242
+ `message-feedback: no durability listener participated for live session '${sessionId}'`,
243
+ )
244
+ }
245
+ // Listener participation alone does not prove this Session has a persistence writer.
246
+ const handle = await this.ctx.sessionPersistence.open(sessionId, 'read')
247
+ try {
248
+ const { events: stored } = await handle.read(last?.seq ?? 0, 1)
249
+ if (!isDeepStrictEqual(
250
+ [handle.header.id, handle.header.createdAt, handle.header.cwd],
251
+ [live.header.id, live.header.createdAt, live.header.cwd],
252
+ )
253
+ || (last !== undefined && !isDeepStrictEqual(stored[0], last))) {
254
+ throw new Error(`message-feedback: feedback prefix is not durable for live session '${sessionId}'`)
255
+ }
256
+ } finally {
257
+ await handle.close()
258
+ }
259
+ })
260
+ }
261
+ const handle = await this.ctx.sessionPersistence.open(sessionId, write ? 'write' : 'read')
262
+ try {
263
+ const { events } = await handle.read()
264
+ return await operation(events, async (event) => {
265
+ const entry: FeedbackEvent | undefined = event === undefined ? undefined
266
+ : { ...event, seq: SessionSeq(events.length), time: Date.now() }
267
+ if (entry !== undefined) await handle.append([entry])
268
+ await handle.flush()
269
+ if (entry !== undefined) {
270
+ try {
271
+ await this.ctx.parallel('feedback/committed', {
272
+ meta: handle.header,
273
+ inheritedEventCount: handle.inheritedEventCount,
274
+ events: [...events, entry],
275
+ })
276
+ } catch (error) {
277
+ this.ctx.logger.warn('message-feedback: committed feedback observer failed', error)
278
+ }
279
+ }
280
+ })
281
+ } finally {
282
+ await handle.close()
283
+ }
284
+ }
285
+
286
+ private resolveNote(note: string | undefined): ResolvedNote {
287
+ if (note === undefined) return success(undefined)
288
+ if (note.trim().length === 0) return rejected({ code: 'note-blank' })
289
+ const actualBytes = Buffer.byteLength(note, 'utf8')
290
+ if (actualBytes > this.maxNoteBytes) {
291
+ return rejected({ code: 'note-too-large', maxBytes: this.maxNoteBytes, actualBytes })
292
+ }
293
+ return success(note)
294
+ }
295
+
296
+ private versionConflict(current: MessageFeedbackItem | null): MessageFeedbackVersionConflict {
297
+ return { code: 'version-conflict', current: current === null ? null : snapshotItem(current) }
298
+ }
299
+
300
+ /** Serialize complete operations and drain their handles before disposal. */
301
+ private enqueue<T>(sessionId: SessionId, operation: () => Promise<T>): Promise<T> {
302
+ if (!this.mutationAdmissionOpen) return Promise.reject(new Error('message-feedback: service is disposing'))
303
+ const previous = this.operationTails.get(sessionId) ?? Promise.resolve()
304
+ const result = previous.then(operation)
305
+ const tail = result.then(() => undefined, () => undefined)
306
+ this.operationTails.set(sessionId, tail)
307
+ return result.finally(() => {
308
+ if (this.operationTails.get(sessionId) === tail) this.operationTails.delete(sessionId)
309
+ })
310
+ }
311
+ }
312
+
313
+ export default MessageFeedbackService
package/src/types.ts ADDED
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Public request, value, and failure vocabulary for per-message feedback.
3
+ * This module contains types only so generated Remote clients can consume it
4
+ * without importing Host runtime code.
5
+ * @module @unieai/rabi-message-feedback/types
6
+ */
7
+
8
+ import type { Branded } from '@unieai/rabi-brand'
9
+ import type { MessageId } from '@unieai/rabi-llm/brand'
10
+ import type { SessionId } from '@unieai/rabi-session/types'
11
+ import type { FeedbackCategory } from '@unieai/rabi-command-feedback/types'
12
+
13
+ /** Opaque compare-and-set token for one exact feedback item revision. */
14
+ export type MessageFeedbackVersion = Branded<'MessageFeedbackVersion'>
15
+
16
+ /** The human's overall judgment of one assistant message. */
17
+ export type MessageFeedbackRating = 'positive' | 'negative'
18
+
19
+ /** One current feedback value and its opaque mutation token. */
20
+ export interface MessageFeedbackItem {
21
+ /** Stable identity of the assistant message inside the owning Session. */
22
+ readonly messageId: MessageId
23
+ /** Overall positive or negative judgment. */
24
+ readonly rating: MessageFeedbackRating
25
+ /** Optional explanation, preserved verbatim after validation. */
26
+ readonly note?: string
27
+ /** Category the human filed the judgment under. */
28
+ readonly category?: FeedbackCategory
29
+ /** Equality-only token replaced by every material create or update. */
30
+ readonly version: MessageFeedbackVersion
31
+ /** Host-assigned creation time in Unix epoch milliseconds. */
32
+ readonly createdAt: number
33
+ /** Host-assigned time of the most recent material update. */
34
+ readonly updatedAt: number
35
+ }
36
+
37
+ /** A material creation or edit, retaining its complete current value. */
38
+ export interface MessageFeedbackPut {
39
+ /** Owning Session; inherited feedback in a fork belongs to its parent. */
40
+ readonly sessionId: SessionId
41
+ /** Value after this mutation, including the original creation time. */
42
+ readonly item: MessageFeedbackItem
43
+ }
44
+
45
+ /** A material deletion of one current feedback item. */
46
+ export interface MessageFeedbackDelete {
47
+ /** Session that owns the deleted feedback. */
48
+ readonly sessionId: SessionId
49
+ /** Message whose feedback was removed. */
50
+ readonly messageId: MessageId
51
+ }
52
+
53
+ declare module '@unieai/rabi-session/types' {
54
+ interface SessionEventMap {
55
+ /** Log-only human feedback; never enters model history. */
56
+ 'feedback/message-put': MessageFeedbackPut
57
+ /** Log-only deletion; earlier ratings and notes remain in the log. */
58
+ 'feedback/message-delete': MessageFeedbackDelete
59
+ }
60
+ }
61
+
62
+ /** Read all message feedback belonging to one persisted Session lifecycle. */
63
+ export interface MessageFeedbackListRequest {
64
+ /** Session whose feedback events should be read. */
65
+ readonly sessionId: SessionId
66
+ }
67
+
68
+ /** Current feedback values for one Session, in first-creation order. */
69
+ export interface MessageFeedbackListValue {
70
+ /** Fresh immutable item snapshots. */
71
+ readonly items: readonly MessageFeedbackItem[]
72
+ }
73
+
74
+ /** Create or replace feedback for one assistant message. */
75
+ export interface MessageFeedbackPutRequest {
76
+ /** Persisted Session that owns the target message. */
77
+ readonly sessionId: SessionId
78
+ /** Target assistant-message identity. */
79
+ readonly messageId: MessageId
80
+ /** Desired overall judgment. */
81
+ readonly rating: MessageFeedbackRating
82
+ /** Optional non-blank explanation. */
83
+ readonly note?: string
84
+ /** Optional category; absent keeps the item uncategorized. */
85
+ readonly category?: FeedbackCategory
86
+ /** Observed item version, or `null` to require that no item exists. */
87
+ readonly ifVersion: MessageFeedbackVersion | null
88
+ }
89
+
90
+ /** Delete feedback for one message after observing its current version. */
91
+ export interface MessageFeedbackDeleteRequest {
92
+ /** Session that owns the feedback. */
93
+ readonly sessionId: SessionId
94
+ /** Message whose feedback should be absent after this operation. */
95
+ readonly messageId: MessageId
96
+ /** Observed item version; ignored when the item is already absent. */
97
+ readonly ifVersion: MessageFeedbackVersion
98
+ }
99
+
100
+ /** Idempotent deletion acknowledgement. */
101
+ export interface MessageFeedbackDeleteValue {
102
+ /** Stable postcondition shared by the first deletion and every retry. */
103
+ readonly absent: true
104
+ }
105
+
106
+ /** No persisted Session header exists for the requested id. */
107
+ export interface MessageFeedbackSessionNotFound {
108
+ readonly code: 'session-not-found'
109
+ readonly sessionId: SessionId
110
+ }
111
+
112
+ /** The id does not name a derived, append-origin assistant message. */
113
+ export interface MessageFeedbackTargetNotFound {
114
+ readonly code: 'target-not-found'
115
+ readonly sessionId: SessionId
116
+ readonly messageId: MessageId
117
+ }
118
+
119
+ /** A material mutation did not match the addressed item's current version. */
120
+ export interface MessageFeedbackVersionConflict {
121
+ readonly code: 'version-conflict'
122
+ /** Authoritative current item, or `null` when it does not exist. */
123
+ readonly current: MessageFeedbackItem | null
124
+ }
125
+
126
+ /** A supplied note contains no non-whitespace character. */
127
+ export interface MessageFeedbackNoteBlank {
128
+ readonly code: 'note-blank'
129
+ }
130
+
131
+ /** A supplied note exceeds the configured UTF-8 byte limit. */
132
+ export interface MessageFeedbackNoteTooLarge {
133
+ readonly code: 'note-too-large'
134
+ readonly maxBytes: number
135
+ readonly actualBytes: number
136
+ }
137
+
138
+ /** Failures shared by the public message-feedback operations. */
139
+ export type MessageFeedbackFailure =
140
+ | MessageFeedbackSessionNotFound
141
+ | MessageFeedbackTargetNotFound
142
+ | MessageFeedbackVersionConflict
143
+ | MessageFeedbackNoteBlank
144
+ | MessageFeedbackNoteTooLarge
145
+
146
+ /** Successful public operation result. */
147
+ export interface MessageFeedbackSuccess<T> {
148
+ readonly ok: true
149
+ readonly value: T
150
+ }
151
+
152
+ /** Rejected public operation result with a stable business failure. */
153
+ export interface MessageFeedbackRejected<E extends MessageFeedbackFailure> {
154
+ readonly ok: false
155
+ readonly error: E
156
+ }
157
+
158
+ /** Result returned by the message-feedback `list` operation. */
159
+ export type MessageFeedbackListResult =
160
+ | MessageFeedbackSuccess<MessageFeedbackListValue>
161
+ | MessageFeedbackRejected<MessageFeedbackSessionNotFound>
162
+
163
+ /** Result returned by the message-feedback `put` operation. */
164
+ export type MessageFeedbackPutResult =
165
+ | MessageFeedbackSuccess<MessageFeedbackItem>
166
+ | MessageFeedbackRejected<
167
+ | MessageFeedbackSessionNotFound
168
+ | MessageFeedbackTargetNotFound
169
+ | MessageFeedbackVersionConflict
170
+ | MessageFeedbackNoteBlank
171
+ | MessageFeedbackNoteTooLarge
172
+ >
173
+
174
+ /** Result returned by the message-feedback `delete` operation. */
175
+ export type MessageFeedbackDeleteResult =
176
+ | MessageFeedbackSuccess<MessageFeedbackDeleteValue>
177
+ | MessageFeedbackRejected<MessageFeedbackSessionNotFound | MessageFeedbackVersionConflict>