@aichatwar/shared 1.0.121 → 1.0.123

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.
@@ -103,4 +103,31 @@ interface ModelUpdatedEvent extends BaseEvent {
103
103
  updatedAt: string;
104
104
  };
105
105
  }
106
- export { FeedbackCreatedEvent, AgentLearningUpdatedEvent, TrainingDatasetReadyEvent, ModelUpdatedEvent };
106
+ interface FeedbackReplyReceivedEvent extends BaseEvent {
107
+ subject: Subjects.FeedbackReplyReceived;
108
+ data: {
109
+ roomId: string;
110
+ messageId: string;
111
+ replyToMessageId: string;
112
+ agentId: string;
113
+ agentMessageContent: string;
114
+ replySenderId: string;
115
+ replySenderType: 'human' | 'agent';
116
+ replyContent: string;
117
+ createdAt: string;
118
+ };
119
+ }
120
+ interface FeedbackReactionReceivedEvent extends BaseEvent {
121
+ subject: Subjects.FeedbackReactionReceived;
122
+ data: {
123
+ roomId: string;
124
+ messageId: string;
125
+ agentId: string;
126
+ agentMessageContent: string;
127
+ reactionUserId: string;
128
+ reactionUserType: 'human' | 'agent';
129
+ emoji: string;
130
+ createdAt: string;
131
+ };
132
+ }
133
+ export { FeedbackCreatedEvent, FeedbackReplyReceivedEvent, FeedbackReactionReceivedEvent, AgentLearningUpdatedEvent, TrainingDatasetReadyEvent, ModelUpdatedEvent };
@@ -76,21 +76,33 @@ class Listener {
76
76
  // Reset retry count on successful connection
77
77
  this.retryCount = 0;
78
78
  yield this.consumer.run({
79
+ // CRITICAL: Disable auto-commit to prevent message loss during rebalancing
80
+ // Offsets are only committed when we explicitly call ack()
81
+ autoCommit: false,
79
82
  eachMessage: (payload) => __awaiter(this, void 0, void 0, function* () {
80
- if (!payload.message.value)
83
+ if (!payload.message.value) {
84
+ // Acknowledge empty messages to avoid blocking
85
+ yield this.consumer.commitOffsets([{
86
+ topic: payload.topic,
87
+ partition: payload.partition,
88
+ offset: (BigInt(payload.message.offset) + BigInt(1)).toString()
89
+ }]);
81
90
  return;
82
- console.log(`Message received -> topic: ${this.topic}, groupId: ${this.groupId}`);
91
+ }
92
+ console.log(`Message received -> topic: ${this.topic}, groupId: ${this.groupId}, offset: ${payload.message.offset}`);
83
93
  // Store current payload for manual ack
84
94
  this.currentPayload = payload;
85
95
  try {
86
96
  const data = JSON.parse(payload.message.value.toString());
87
97
  yield this.onMessage(data, payload);
88
- // Note: Child listeners must call this.ack() manually after successful processing
89
- // If they don't call ack(), the message will be redelivered
98
+ // Note: Child listeners MUST call this.ack() manually after successful processing
99
+ // If they don't call ack(), the message will be redelivered after session timeout
100
+ // This ensures at-least-once delivery semantics
90
101
  }
91
102
  catch (error) {
92
- console.error(`Error processing message for topic: ${this.topic}`, error);
103
+ console.error(`Error processing message for topic: ${this.topic}, offset: ${payload.message.offset}`, error);
93
104
  // In case of error, we don't commit the offset, so the message will be redelivered
105
+ // This ensures failed messages are retried
94
106
  throw error;
95
107
  }
96
108
  finally {
@@ -51,6 +51,8 @@ export declare enum Subjects {
51
51
  ReactionCreated = "reaction.created",
52
52
  ReactionDeleted = "reaction.deleted",
53
53
  FeedbackCreated = "feedback.created",
54
+ FeedbackReplyReceived = "feedback.reply.received",
55
+ FeedbackReactionReceived = "feedback.reaction.received",
54
56
  AgentLearningUpdated = "agent.learning.updated",
55
57
  TrainingDatasetReady = "training.dataset.ready",
56
58
  ModelUpdated = "model.updated",
@@ -55,6 +55,8 @@ var Subjects;
55
55
  Subjects["ReactionCreated"] = "reaction.created";
56
56
  Subjects["ReactionDeleted"] = "reaction.deleted";
57
57
  Subjects["FeedbackCreated"] = "feedback.created";
58
+ Subjects["FeedbackReplyReceived"] = "feedback.reply.received";
59
+ Subjects["FeedbackReactionReceived"] = "feedback.reaction.received";
58
60
  Subjects["AgentLearningUpdated"] = "agent.learning.updated";
59
61
  Subjects["TrainingDatasetReady"] = "training.dataset.ready";
60
62
  Subjects["ModelUpdated"] = "model.updated";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aichatwar/shared",
3
- "version": "1.0.121",
3
+ "version": "1.0.123",
4
4
  "main": "./build/index.js",
5
5
  "typs": "./build/index.d.ts",
6
6
  "files": [