@deepseek-ai/dsh-message-feedback 0.0.1-rc.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/src/types.ts ADDED
@@ -0,0 +1,147 @@
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 @deepseek-ai/dsh-message-feedback/types
6
+ */
7
+
8
+ import type { Branded } from '@deepseek-ai/dsh-brand'
9
+ import type { MessageId } from '@deepseek-ai/dsh-llm/brand'
10
+ import type { SessionId } from '@deepseek-ai/dsh-session/types'
11
+
12
+ /** Opaque compare-and-set token for one exact feedback item revision. */
13
+ export type MessageFeedbackVersion = Branded<'MessageFeedbackVersion'>
14
+
15
+ /** The human's overall judgment of one assistant message. */
16
+ export type MessageFeedbackRating = 'positive' | 'negative'
17
+
18
+ /** One current feedback value and its opaque mutation token. */
19
+ export interface MessageFeedbackItem {
20
+ /** Stable identity of the assistant message inside the owning Session. */
21
+ readonly messageId: MessageId
22
+ /** Overall positive or negative judgment. */
23
+ readonly rating: MessageFeedbackRating
24
+ /** Optional explanation, preserved verbatim after validation. */
25
+ readonly note?: string
26
+ /** Equality-only token replaced by every material create or update. */
27
+ readonly version: MessageFeedbackVersion
28
+ /** Host-assigned creation time in Unix epoch milliseconds. */
29
+ readonly createdAt: number
30
+ /** Host-assigned time of the most recent material update. */
31
+ readonly updatedAt: number
32
+ }
33
+
34
+ /** Read all message feedback belonging to one persisted Session lifecycle. */
35
+ export interface MessageFeedbackListRequest {
36
+ /** Persisted Session whose sidecar should be read. */
37
+ readonly sessionId: SessionId
38
+ }
39
+
40
+ /** Current feedback values for one Session, in first-creation order. */
41
+ export interface MessageFeedbackListValue {
42
+ /** Fresh immutable item snapshots. */
43
+ readonly items: readonly MessageFeedbackItem[]
44
+ }
45
+
46
+ /** Create or replace feedback for one assistant message. */
47
+ export interface MessageFeedbackPutRequest {
48
+ /** Persisted Session that owns the target message. */
49
+ readonly sessionId: SessionId
50
+ /** Target assistant-message identity. */
51
+ readonly messageId: MessageId
52
+ /** Desired overall judgment. */
53
+ readonly rating: MessageFeedbackRating
54
+ /** Optional non-blank explanation. */
55
+ readonly note?: string
56
+ /** Observed item version, or `null` to require that no item exists. */
57
+ readonly ifVersion: MessageFeedbackVersion | null
58
+ }
59
+
60
+ /** Delete feedback for one message after observing its current version. */
61
+ export interface MessageFeedbackDeleteRequest {
62
+ /** Persisted Session that owns the sidecar. */
63
+ readonly sessionId: SessionId
64
+ /** Message whose feedback should be absent after this operation. */
65
+ readonly messageId: MessageId
66
+ /** Observed item version; ignored when the item is already absent. */
67
+ readonly ifVersion: MessageFeedbackVersion
68
+ }
69
+
70
+ /** Idempotent deletion acknowledgement. */
71
+ export interface MessageFeedbackDeleteValue {
72
+ /** Stable postcondition shared by the first deletion and every retry. */
73
+ readonly absent: true
74
+ }
75
+
76
+ /** No persisted Session header exists for the requested id. */
77
+ export interface MessageFeedbackSessionNotFound {
78
+ readonly code: 'session-not-found'
79
+ readonly sessionId: SessionId
80
+ }
81
+
82
+ /** The id does not name a derived, append-origin assistant message. */
83
+ export interface MessageFeedbackTargetNotFound {
84
+ readonly code: 'target-not-found'
85
+ readonly sessionId: SessionId
86
+ readonly messageId: MessageId
87
+ }
88
+
89
+ /** A material mutation did not match the addressed item's current version. */
90
+ export interface MessageFeedbackVersionConflict {
91
+ readonly code: 'version-conflict'
92
+ /** Authoritative current item, or `null` when it does not exist. */
93
+ readonly current: MessageFeedbackItem | null
94
+ }
95
+
96
+ /** A supplied note contains no non-whitespace character. */
97
+ export interface MessageFeedbackNoteBlank {
98
+ readonly code: 'note-blank'
99
+ }
100
+
101
+ /** A supplied note exceeds the configured UTF-8 byte limit. */
102
+ export interface MessageFeedbackNoteTooLarge {
103
+ readonly code: 'note-too-large'
104
+ readonly maxBytes: number
105
+ readonly actualBytes: number
106
+ }
107
+
108
+ /** Failures shared by the public message-feedback operations. */
109
+ export type MessageFeedbackFailure =
110
+ | MessageFeedbackSessionNotFound
111
+ | MessageFeedbackTargetNotFound
112
+ | MessageFeedbackVersionConflict
113
+ | MessageFeedbackNoteBlank
114
+ | MessageFeedbackNoteTooLarge
115
+
116
+ /** Successful public operation result. */
117
+ export interface MessageFeedbackSuccess<T> {
118
+ readonly ok: true
119
+ readonly value: T
120
+ }
121
+
122
+ /** Rejected public operation result with a stable business failure. */
123
+ export interface MessageFeedbackRejected<E extends MessageFeedbackFailure> {
124
+ readonly ok: false
125
+ readonly error: E
126
+ }
127
+
128
+ /** Result returned by the message-feedback `list` operation. */
129
+ export type MessageFeedbackListResult =
130
+ | MessageFeedbackSuccess<MessageFeedbackListValue>
131
+ | MessageFeedbackRejected<MessageFeedbackSessionNotFound>
132
+
133
+ /** Result returned by the message-feedback `put` operation. */
134
+ export type MessageFeedbackPutResult =
135
+ | MessageFeedbackSuccess<MessageFeedbackItem>
136
+ | MessageFeedbackRejected<
137
+ | MessageFeedbackSessionNotFound
138
+ | MessageFeedbackTargetNotFound
139
+ | MessageFeedbackVersionConflict
140
+ | MessageFeedbackNoteBlank
141
+ | MessageFeedbackNoteTooLarge
142
+ >
143
+
144
+ /** Result returned by the message-feedback `delete` operation. */
145
+ export type MessageFeedbackDeleteResult =
146
+ | MessageFeedbackSuccess<MessageFeedbackDeleteValue>
147
+ | MessageFeedbackRejected<MessageFeedbackSessionNotFound | MessageFeedbackVersionConflict>