@knowlearning/agents 0.9.110 → 0.9.112
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.
|
@@ -10,6 +10,10 @@ function standardJSONPatch(patch) {
|
|
|
10
10
|
})
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function activePatch(patch) {
|
|
14
|
+
return structuredClone(patch).filter(({ path }) => 'active' === path.shift())
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
function sanitizeJSONPatchPathSegment(s) {
|
|
14
18
|
if (typeof s === "string") return s.replaceAll('~', '~0').replaceAll('/', '~1')
|
|
15
19
|
else return s
|
|
@@ -52,7 +56,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
52
56
|
}
|
|
53
57
|
else {
|
|
54
58
|
si += 1
|
|
55
|
-
if (responses[si]) console.log('ERROR! response for si already set!', si, scope, patch)
|
|
56
59
|
lastSynchronousScopePatchPromise = new Promise((resolve, reject) => responses[si] = [[resolve, reject]])
|
|
57
60
|
messageQueue.push({ scope, patch, si, ts: Date.now()})
|
|
58
61
|
lastSynchronousScopePatched = scope
|
|
@@ -73,7 +76,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
73
76
|
try {
|
|
74
77
|
connection.send(messageQueue[lastSentSI + 1])
|
|
75
78
|
lastSentSI += 1
|
|
76
|
-
console.log('SENDING MESSAGE!!!!!!!!!!', lastSentSI, messageQueue[lastSentSI])
|
|
77
79
|
// async so we don't try and push more to a closed connection
|
|
78
80
|
await new Promise(r=>r())
|
|
79
81
|
}
|
|
@@ -168,7 +170,6 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
else if (message.si !== undefined) {
|
|
171
|
-
console.log('GOT RESPONSE', message.si, message, responses)
|
|
172
173
|
if (responses[message.si]) {
|
|
173
174
|
// TODO: remove "acknowledged" messages from queue and do accounting with si
|
|
174
175
|
responses[message.si]
|
|
@@ -207,7 +208,7 @@ export default function messageQueue({ token, domain, Connection, watchers, stat
|
|
|
207
208
|
watchers[qualifiedScope]
|
|
208
209
|
.forEach(fn => {
|
|
209
210
|
const state = structuredClone(states[qualifiedScope].active)
|
|
210
|
-
fn({ ...message, state })
|
|
211
|
+
fn({ ...message, patch: activePatch(message.patch), state })
|
|
211
212
|
})
|
|
212
213
|
}
|
|
213
214
|
}
|
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)
|