@knowlearning/agents 0.9.43 → 0.9.44

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.
@@ -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,12 @@ 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
- create({
173
- id,
174
- active_type: POSTGRES_QUERY_TYPE,
175
- active: { query, params, domain, requested: Date.now() },
176
- })
182
+ const requested = Date.now()
183
+ session.queries[id] = { query, params, domain }
177
184
  const { rows } = await lastMessageResponse()
178
- interact(id, [{ op: 'add', path: ['active', 'responded'], value: Date.now() }])
185
+ session.queries[id].agent_latency = Date.now() - requested
179
186
  return rows
180
187
  }
181
188
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.43",
3
+ "version": "0.9.44",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",