@knowlearning/agents 0.9.36 → 0.9.38

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.
@@ -70,8 +70,8 @@ export default function EmbeddedAgent() {
70
70
  }
71
71
  })
72
72
 
73
- function environment() {
74
- return send({ type: 'environment' })
73
+ function environment(user) {
74
+ return send({ type: 'environment', user })
75
75
  }
76
76
 
77
77
  function create({ id=uuid(), active_type, active }) {
@@ -58,8 +58,8 @@ function embed(environment, iframe) {
58
58
  if (listeners.close) listeners.close(message.info)
59
59
  }
60
60
  else if (type === 'environment') {
61
- const { context } = message
62
- const env = await (listeners.environment ? listeners.environment() : Agent.environment())
61
+ const { user } = message
62
+ const env = await (listeners.environment ? listeners.environment(user) : Agent.environment(user))
63
63
  sendDown({ ...env, context: [...(env.context || []), environment.id], mode: environment.mode })
64
64
  }
65
65
  else if (type === 'interact') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.36",
3
+ "version": "0.9.38",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -26,6 +26,10 @@ export default {
26
26
  mode: {
27
27
  type: String,
28
28
  required: false
29
+ },
30
+ environmentProxy: {
31
+ type: Function,
32
+ required: false
29
33
  }
30
34
  },
31
35
  data() {
@@ -59,9 +63,9 @@ export default {
59
63
 
60
64
  this.iframe = iframe
61
65
  this.embedding = Agent.embed({ id, mode }, iframe)
66
+ this.embedding.on('environment', e => this.environmentProxy ? this.environmentProxy(e) : Agent.environment(e))
62
67
  this.embedding.on('state', e => this.$emit('state', e))
63
68
  this.embedding.on('mutate', e => this.$emit('mutate', e))
64
- this.embedding.on('environment', e => this.$emit('environment', e))
65
69
  this.embedding.on('close', e => this.$emit('close', e))
66
70
  }
67
71
  }