@knowlearning/agents 0.9.103 → 0.9.105

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.
@@ -50,7 +50,8 @@ export default function Agent({ Connection, domain, token, uuid, fetch, applyPat
50
50
  interact,
51
51
  fetch,
52
52
  synced,
53
- metadata
53
+ metadata,
54
+ log
54
55
  }
55
56
 
56
57
  const [ watch, removeWatcher ] = watchImplementation(internalReferences)
@@ -119,19 +120,18 @@ export default function Agent({ Connection, domain, token, uuid, fetch, applyPat
119
120
  // if we are watching this scope, we want to keep track of last interaction we fired
120
121
  const qualifiedScope = isUUID(scope) ? scope : `//${scope}`
121
122
  if (manageLocalState && states[qualifiedScope] !== undefined) {
122
- let resolve
123
- lastInteractionResponse[qualifiedScope] = new Promise(r => resolve = r)
124
-
125
- const resolveAndUnwatch = async (update) => {
126
- const { ii } = await response
127
- if (update.ii === ii) {
128
- resolve(ii)
129
- removeWatcher(qualifiedScope, resolveAndUnwatch)
123
+ lastInteractionResponse[qualifiedScope] = new Promise(resolve => {
124
+ const resolveAndUnwatch = async update => {
125
+ log('AWAITING INTERACTION RESPONSE', qualifiedScope, update)
126
+ const { ii } = await response
127
+ log('GOT INTERACTION RESPONSE', qualifiedScope, await response)
128
+ if (update.ii === ii) {
129
+ resolve(ii)
130
+ removeWatcher(qualifiedScope, resolveAndUnwatch)
131
+ }
130
132
  }
131
- }
132
-
133
- watchers[qualifiedScope].push(resolveAndUnwatch)
134
-
133
+ watchers[qualifiedScope].push(resolveAndUnwatch)
134
+ })
135
135
  return response
136
136
  }
137
137
  else {
@@ -1,7 +1,7 @@
1
1
  import { v4 as uuid, validate as isUUID } from 'uuid'
2
2
  import MutableProxy from '../../persistence/json.js'
3
3
 
4
- export default function(scope='[]', user, domain, { keyToSubscriptionId, watchers, states, create, environment, lastMessageResponse, lastInteractionResponse, tagIfNotYetTaggedInSession, interact }) {
4
+ export default function(scope='[]', user, domain, { keyToSubscriptionId, watchers, states, create, environment, lastMessageResponse, lastInteractionResponse, tagIfNotYetTaggedInSession, interact, log }) {
5
5
  let resolveMetadataPromise
6
6
  let metadataPromise = new Promise(resolve => resolveMetadataPromise = resolve)
7
7
 
@@ -27,10 +27,14 @@ export default function(scope='[]', user, domain, { keyToSubscriptionId, watcher
27
27
  })
28
28
  }
29
29
 
30
+ log('AWAITING LAST INTERACTION', qualifiedScope)
30
31
  await lastInteractionResponse[qualifiedScope]
32
+ log('GOT LAST INTERACTION', qualifiedScope)
31
33
 
32
34
  try {
35
+ log('GETTING STATE FOR', qualifiedScope)
33
36
  const data = structuredClone(await states[qualifiedScope])
37
+ log('GOT STATE FOR', qualifiedScope)
34
38
  const active = data.active
35
39
  delete data.active
36
40
  resolveMetadataPromise(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.103",
3
+ "version": "0.9.105",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",