@knowlearning/agents 0.9.51 → 0.9.52
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/agents/browser/initialize.js +5 -2
- package/agents/generic/index.js +20 -13
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ function embed(environment, iframe) {
|
|
|
48
48
|
const handleMessage = async message => {
|
|
49
49
|
const { requestId, type } = message
|
|
50
50
|
|
|
51
|
-
const sendDown = response => postMessage({ requestId, response })
|
|
51
|
+
const sendDown = (response, error) => postMessage({ requestId, response, error })
|
|
52
52
|
|
|
53
53
|
if (type === 'error') {
|
|
54
54
|
console.error(message)
|
|
@@ -100,7 +100,10 @@ function embed(environment, iframe) {
|
|
|
100
100
|
}
|
|
101
101
|
else if (type === 'query') {
|
|
102
102
|
const { query, params, domain } = message
|
|
103
|
-
|
|
103
|
+
Agent
|
|
104
|
+
.query(query, params, domain)
|
|
105
|
+
.then(sendDown)
|
|
106
|
+
.catch(error => sendDown(null, error.error))
|
|
104
107
|
}
|
|
105
108
|
else if (type === 'upload') {
|
|
106
109
|
const { name, contentType, id } = message
|
package/agents/generic/index.js
CHANGED
|
@@ -185,19 +185,26 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
|
|
|
185
185
|
value: { query, params, domain }
|
|
186
186
|
}
|
|
187
187
|
])
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
188
|
+
try {
|
|
189
|
+
const response = await lastMessageResponse()
|
|
190
|
+
const { rows } = response
|
|
191
|
+
|
|
192
|
+
interact('sessions', [
|
|
193
|
+
{
|
|
194
|
+
op: 'add',
|
|
195
|
+
path: ['active', session, 'queries', id, 'agent_latency'],
|
|
196
|
+
value: Date.now() - requested
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
op: 'remove',
|
|
200
|
+
path: ['active', session, 'queries', id]
|
|
201
|
+
}
|
|
202
|
+
])
|
|
203
|
+
return rows
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
throw error
|
|
207
|
+
}
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
function tag(tag_type, target, context=[]) {
|