@knowlearning/agents 0.9.109 → 0.9.111
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
CHANGED
|
@@ -120,20 +120,7 @@ export default function Agent({ Connection, domain, token, uuid, fetch, applyPat
|
|
|
120
120
|
// if we are watching this scope, we want to keep track of last interaction we fired
|
|
121
121
|
const qualifiedScope = isUUID(scope) ? scope : `//${scope}`
|
|
122
122
|
if (manageLocalState && states[qualifiedScope] !== undefined) {
|
|
123
|
-
lastInteractionResponse[qualifiedScope] =
|
|
124
|
-
const resolveAndUnwatch = async update => {
|
|
125
|
-
console.log('AWAITING INTERACTION RESPONSE', qualifiedScope, update)
|
|
126
|
-
const { ii } = await response
|
|
127
|
-
console.log('GOT INTERACTION RESPONSE', qualifiedScope, await response)
|
|
128
|
-
if (update.ii === ii) {
|
|
129
|
-
resolve(ii)
|
|
130
|
-
removeWatcher(qualifiedScope, resolveAndUnwatch)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
watchers[qualifiedScope].push(resolveAndUnwatch)
|
|
134
|
-
console.log('SETTING LAST INTERACTION RESPONSE PROMISE', qualifiedScope)
|
|
135
|
-
response.then(r => console.log('GOT INTERACTION RESPONSE FOR', qualifiedScope, r))
|
|
136
|
-
})
|
|
123
|
+
lastInteractionResponse[qualifiedScope] = response.then(r => r.ii)
|
|
137
124
|
return response
|
|
138
125
|
}
|
|
139
126
|
else {
|
|
@@ -52,7 +52,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
54
|
si += 1
|
|
55
|
-
if (responses[si]) console.log('ERROR! response for si already set!', si, scope, patch)
|
|
56
55
|
lastSynchronousScopePatchPromise = new Promise((resolve, reject) => responses[si] = [[resolve, reject]])
|
|
57
56
|
messageQueue.push({ scope, patch, si, ts: Date.now()})
|
|
58
57
|
lastSynchronousScopePatched = scope
|
|
@@ -73,7 +72,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
73
72
|
try {
|
|
74
73
|
connection.send(messageQueue[lastSentSI + 1])
|
|
75
74
|
lastSentSI += 1
|
|
76
|
-
console.log('SENDING MESSAGE!!!!!!!!!!', lastSentSI, messageQueue[lastSentSI])
|
|
77
75
|
// async so we don't try and push more to a closed connection
|
|
78
76
|
await new Promise(r=>r())
|
|
79
77
|
}
|
|
@@ -168,7 +166,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
168
166
|
}
|
|
169
167
|
}
|
|
170
168
|
else if (message.si !== undefined) {
|
|
171
|
-
console.log('GOT RESPONSE', message.si, message, responses)
|
|
172
169
|
if (responses[message.si]) {
|
|
173
170
|
// TODO: remove "acknowledged" messages from queue and do accounting with si
|
|
174
171
|
responses[message.si]
|
package/agents/generic/state.js
CHANGED
|
@@ -27,14 +27,10 @@ export default function(scope='[]', user, domain, { keyToSubscriptionId, watcher
|
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
log('AWAITING LAST INTERACTION', qualifiedScope)
|
|
31
30
|
await lastInteractionResponse[qualifiedScope]
|
|
32
|
-
log('GOT LAST INTERACTION', qualifiedScope)
|
|
33
31
|
|
|
34
32
|
try {
|
|
35
|
-
log('GETTING STATE FOR', qualifiedScope)
|
|
36
33
|
const data = structuredClone(await states[qualifiedScope])
|
|
37
|
-
log('GOT STATE FOR', qualifiedScope)
|
|
38
34
|
const active = data.active
|
|
39
35
|
delete data.active
|
|
40
36
|
resolveMetadataPromise(data)
|