@knowlearning/agents 0.9.156 → 0.9.158

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.
@@ -62,11 +62,11 @@ export default function EmbeddedAgent() {
62
62
  if (sentUpdates[key] === undefined || sentUpdates[key] + 1 === data.ii) {
63
63
  sendUpdate()
64
64
  } else if (data.ii === sentUpdates[key]) {
65
- console.warn('Repeated update for', key, data, sentUpdates[key])
65
+ //console.warn('Repeated update for', key, data, sentUpdates[key])
66
66
  } else if (data.ii < sentUpdates[key]) {
67
- console.warn('Out of order update, from past', key, JSON.stringify(data, null, 4), sentUpdates[key])
67
+ //console.warn('Out of order update, from past', key, JSON.stringify(data, null, 4), sentUpdates[key])
68
68
  } else {
69
- console.warn('Out of order update, fast forward', key, JSON.stringify(data, null, 4), sentUpdates[key])
69
+ //console.warn('Out of order update, fast forward', key, JSON.stringify(data, null, 4), sentUpdates[key])
70
70
  sendUpdate()
71
71
  }
72
72
  }
@@ -81,8 +81,22 @@ function embed(environment, iframe) {
81
81
  }
82
82
  else if (type === 'environment') {
83
83
  const { user } = message
84
+ const { mode, variables } = environment
85
+
84
86
  const env = await (listeners.environment ? listeners.environment(user) : Agent.environment(user))
85
- sendDown({ ...env, context: [...(env.context || []), environment.id], mode: environment.mode })
87
+
88
+ sendDown({
89
+ ...env,
90
+ context: [
91
+ ...(env.context || []),
92
+ environment.id
93
+ ],
94
+ variables: {
95
+ ...(env.variables || {}),
96
+ ...(variables || {})
97
+ },
98
+ mode // TODO: deprecate
99
+ })
86
100
  }
87
101
  else if (type === 'interact') {
88
102
  let { scope, patch } = message
@@ -8,6 +8,7 @@ const SECURE = window.location.protocol === 'https:'
8
8
  const DEVELOPMENT_HOST = `localhost:3200${ SECURE ? '1' : '2' }`
9
9
  const ENVIRONMENT_API_HOST = localStorage.getItem('API_HOST')
10
10
  const REMOTE_HOST = window.location.hostname === TEST_DOMAIN && ENVIRONMENT_API_HOST ? ENVIRONMENT_API_HOST : 'api.knowlearning.systems'
11
+ const LANGUAGES = navigator.languages
11
12
 
12
13
  function isLocal() { return localStorage.getItem('api') === 'local' }
13
14
 
@@ -68,6 +69,7 @@ export default options => {
68
69
  applyPatch,
69
70
  login,
70
71
  logout,
72
+ variables: { LANGUAGES },
71
73
  reboot: () => window.location.reload()
72
74
  })
73
75
 
@@ -18,7 +18,6 @@ export default function Agent({ Connection, domain, token, sid, uuid, fetch, app
18
18
  const keyToSubscriptionId = {}
19
19
  const lastInteractionResponse = {}
20
20
  const tagTypeToTargetCache = {}
21
- let mode = 'normal'
22
21
 
23
22
  log('INITIALIZING AGENT CONNECTION')
24
23
  const [
@@ -59,7 +58,8 @@ export default function Agent({ Connection, domain, token, sid, uuid, fetch, app
59
58
 
60
59
  function download(id) { return downloadImplementation(id, internalReferences) }
61
60
 
62
- function debug() { mode = 'debug' }
61
+ // TODO: deprecate
62
+ function debug() {}
63
63
 
64
64
  function log() { passedLog(...arguments) }
65
65
 
@@ -8,7 +8,7 @@ function activePatch(patch) {
8
8
  return structuredClone(patch).filter(({ path }) => 'active' === path.shift())
9
9
  }
10
10
 
11
- export default function messageQueue({ token, sid, domain, Connection, watchers, states, applyPatch, log, login, reboot, handleDomainMessage, trigger }) {
11
+ export default function messageQueue({ token, sid, domain, Connection, watchers, states, applyPatch, log, login, reboot, handleDomainMessage, trigger, variables={} }) {
12
12
  let connection
13
13
  let user
14
14
  let authed = false
@@ -36,7 +36,7 @@ export default function messageQueue({ token, sid, domain, Connection, watchers,
36
36
  authenticated: null
37
37
  }
38
38
 
39
- async function environment() { return { ...(await environmentPromise), context: [] } }
39
+ async function environment() { return { variables, ...(await environmentPromise), context: [] } }
40
40
 
41
41
  function queueMessage({ scope, patch }) {
42
42
  if (lastSynchronousScopePatched === scope) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.156",
3
+ "version": "0.9.158",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",