@knowlearning/agents 0.9.77 → 0.9.79
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/deno.js +3 -8
- package/package.json +1 -1
package/deno.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import fastJSONPatch from 'fast-json-patch'
|
|
2
2
|
import Agent from './agents/generic/index.js'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const SERVICE_ACCOUNT_TOKEN = Deno.env.get("SERVICE_ACCOUNT_TOKEN")
|
|
4
|
+
const AGENT_TOKEN = Deno.env.get("AGENT_TOKEN")
|
|
6
5
|
|
|
7
6
|
const denoProcess = self
|
|
8
7
|
|
|
9
8
|
function Connection() {
|
|
10
|
-
console.log('Deno starting connection...')
|
|
11
9
|
const thisConnection = this
|
|
12
10
|
|
|
13
11
|
thisConnection.send = message => denoProcess.postMessage(message)
|
|
14
12
|
|
|
15
13
|
const delay = new Promise(r => setTimeout(r))
|
|
16
|
-
|
|
17
|
-
console.log('Deno connection onopen', thisConnection.onopen)
|
|
18
|
-
thisConnection.onopen && thisConnection.onopen()
|
|
19
|
-
})
|
|
14
|
+
delay.then(() => thisConnection.onopen())
|
|
20
15
|
|
|
21
16
|
// TODO: consider what onclose and onerror mean in this case
|
|
22
17
|
return thisConnection
|
|
@@ -24,7 +19,7 @@ function Connection() {
|
|
|
24
19
|
|
|
25
20
|
export default new Agent({
|
|
26
21
|
Connection,
|
|
27
|
-
token: () =>
|
|
22
|
+
token: () => AGENT_TOKEN,
|
|
28
23
|
uuid: () => crypto.randomUUID(),
|
|
29
24
|
fetch,
|
|
30
25
|
applyPatch: fastJSONPatch.applyPatch,
|