@unieai/rabi-message-feedback 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +7 -2
- package/lib/index.js +331 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +391 -0
- package/lib/typert.remote-client.d.ts +31 -0
- package/lib/typert.remote-client.js +232 -0
- package/lib/types/index.d.ts +73 -0
- package/lib/types/index.js +293 -0
- package/lib/types/types.d.ts +138 -0
- package/lib/types/types.js +7 -0
- package/locale/de.json +6 -0
- package/locale/en.json +5 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +59 -4
- package/src/index.ts +313 -0
- package/src/types.ts +177 -0
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>
|