@knowlearning/agents 0.9.43 → 0.9.45
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/generic/index.js +14 -6
- package/package.json +1 -1
package/agents/generic/index.js
CHANGED
|
@@ -49,6 +49,15 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
|
|
|
49
49
|
|
|
50
50
|
const [ watch, removeWatcher ] = watchImplementation(internalReferences)
|
|
51
51
|
|
|
52
|
+
const sessionPromise = new Promise(async resolve => {
|
|
53
|
+
const { session } = await environment()
|
|
54
|
+
const sessions = await state('sessions')
|
|
55
|
+
sessions[session] = {
|
|
56
|
+
queries: {}
|
|
57
|
+
}
|
|
58
|
+
resolve(sessions[session])
|
|
59
|
+
})
|
|
60
|
+
|
|
52
61
|
function state(scope, user, domain) { return stateImplementation(scope, user, domain, internalReferences) }
|
|
53
62
|
|
|
54
63
|
function download(id) { return downloadImplementation(id, internalReferences) }
|
|
@@ -168,14 +177,13 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
|
|
|
168
177
|
}
|
|
169
178
|
|
|
170
179
|
async function query(query, params, domain) {
|
|
180
|
+
const session = await sessionPromise
|
|
171
181
|
const id = uuid()
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
active: { query, params, domain, requested: Date.now() },
|
|
176
|
-
})
|
|
182
|
+
const requested = Date.now()
|
|
183
|
+
await new Promise(r => r()) // ensure next interaction gets sent on its own
|
|
184
|
+
session.queries[id] = { query, params, domain }
|
|
177
185
|
const { rows } = await lastMessageResponse()
|
|
178
|
-
|
|
186
|
+
session.queries[id].agent_latency = Date.now() - requested
|
|
179
187
|
return rows
|
|
180
188
|
}
|
|
181
189
|
|