a2acalling 0.6.37 → 0.6.38
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 +1 -1
- package/src/lib/conversation-driver.js +20 -17
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* 9. Call A2AClient.end() and conclude locally
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
const crypto = require('crypto');
|
|
16
17
|
const { A2AClient } = require('./client');
|
|
17
18
|
const {
|
|
18
19
|
buildAdaptiveConnectionPrompt,
|
|
@@ -141,7 +142,7 @@ Be concise but specific. No filler.`;
|
|
|
141
142
|
confidence: 0.25
|
|
142
143
|
};
|
|
143
144
|
|
|
144
|
-
//
|
|
145
|
+
// Placeholder until we get a real ID from the remote (or generate one)
|
|
145
146
|
conversationId = `conv_${Date.now()}_local`;
|
|
146
147
|
|
|
147
148
|
let nextMessage = openingMessage;
|
|
@@ -162,24 +163,26 @@ Be concise but specific. No filler.`;
|
|
|
162
163
|
break;
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
//
|
|
166
|
-
if (turn === 0 &&
|
|
167
|
-
|
|
166
|
+
// Start DB conversation on first turn
|
|
167
|
+
if (turn === 0 && this.convStore && !dbConversationStarted) {
|
|
168
|
+
// Prefer remote's conversation ID, fall back to generated local one
|
|
169
|
+
if (remoteResponse.conversation_id) {
|
|
170
|
+
conversationId = remoteResponse.conversation_id;
|
|
171
|
+
} else {
|
|
172
|
+
conversationId = `conv_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`;
|
|
173
|
+
}
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
const convResult = this.convStore.startConversation({
|
|
176
|
+
id: conversationId,
|
|
177
|
+
direction: 'outbound'
|
|
178
|
+
});
|
|
179
|
+
if (convResult.success === false) {
|
|
180
|
+
logger.warn('Failed to start conversation in DB', {
|
|
181
|
+
event: 'driver_start_conversation_failed',
|
|
182
|
+
error: convResult.error
|
|
174
183
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
event: 'driver_start_conversation_failed',
|
|
178
|
-
error: convResult.error
|
|
179
|
-
});
|
|
180
|
-
} else {
|
|
181
|
-
dbConversationStarted = true;
|
|
182
|
-
}
|
|
184
|
+
} else {
|
|
185
|
+
dbConversationStarted = true;
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|