@knowlearning/agents 0.9.91 → 0.9.93

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.
@@ -3,7 +3,8 @@ import { applyPatch } from 'fast-json-patch'
3
3
  import { getToken, login, logout } from './auth.js'
4
4
  import GenericAgent from '../generic/index.js'
5
5
 
6
- const DEVELOPMENT_HOST = 'localhost:32001'
6
+ const SECURE = window.location.protocol === 'https:'
7
+ const DEVELOPMENT_HOST = `localhost:3200${ SECURE ? '1' : '2' }`
7
8
  const REMOTE_HOST = localStorage.getItem('mode') === 'staging' ? 'api.staging.knowlearning.systems' : 'api.knowlearning.systems'
8
9
 
9
10
  function isLocal() { return localStorage.getItem('api') === 'local' }
@@ -11,10 +12,10 @@ function isLocal() { return localStorage.getItem('api') === 'local' }
11
12
  const API_HOST = isLocal() ? DEVELOPMENT_HOST : REMOTE_HOST
12
13
 
13
14
  export default options => {
14
- const { host, protocol } = window.location
15
+ const { host } = window.location
15
16
 
16
17
  const Connection = function () {
17
- const ws = new WebSocket(`${protocol === 'https:' ? 'wss' : 'ws'}://${API_HOST}`)
18
+ const ws = new WebSocket(`ws${ SECURE ? 's' : '' }://${API_HOST}`)
18
19
 
19
20
  this.send = message => ws.send(JSON.stringify(message))
20
21
  this.close = info => {
package/deno.js CHANGED
@@ -34,6 +34,7 @@ const agent = new Agent({
34
34
  // concept probably has a place in the generic agent
35
35
  if (type === 'open') {
36
36
  const child = {
37
+ environment: data,
37
38
  on: (eventType, reaction) => {
38
39
  if (!listeners[session]) throw new Error('Error attaching listener, child is closed')
39
40
  if (!listeners[session][eventType]) throw new Error('Only "mutate" and "close" events can be listened to with Agent.on')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.91",
3
+ "version": "0.9.93",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",