@knowlearning/agents 0.9.42 → 0.9.43
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.
|
@@ -63,7 +63,8 @@ function embed(environment, iframe) {
|
|
|
63
63
|
sendDown({ ...env, context: [...(env.context || []), environment.id], mode: environment.mode })
|
|
64
64
|
}
|
|
65
65
|
else if (type === 'interact') {
|
|
66
|
-
|
|
66
|
+
let { scope, patch } = message
|
|
67
|
+
if (environment.namespace && !validateUUID(scope)) scope = environment.namespace + '/' + scope
|
|
67
68
|
// TODO: should use a better approach to instruct agent
|
|
68
69
|
// not to generate a tag from this interaction
|
|
69
70
|
await Agent.interact(scope, patch, false)
|
|
@@ -81,12 +82,13 @@ function embed(environment, iframe) {
|
|
|
81
82
|
}
|
|
82
83
|
else if (type === 'state') {
|
|
83
84
|
const { scope, user, domain } = message
|
|
85
|
+
const namespacedScope = environment.namespace && !validateUUID(scope) ? `${environment.namespace}/${scope}` : scope
|
|
84
86
|
|
|
85
|
-
const statePromise = Agent.state(
|
|
87
|
+
const statePromise = Agent.state(namespacedScope, user, domain)
|
|
86
88
|
|
|
87
|
-
const key = `${ domain || ''}/${user || ''}/${
|
|
89
|
+
const key = `${ domain || ''}/${user || ''}/${namespacedScope}`
|
|
88
90
|
if (!watchers[key]) {
|
|
89
|
-
watchers[key] = Agent.watch(
|
|
91
|
+
watchers[key] = Agent.watch(namespacedScope, m => postMessage({ ...m, scope }), user, domain)
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
if (listeners.state) listeners.state({ scope })
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<iframe
|
|
3
3
|
:v-if="resolvedId"
|
|
4
4
|
:key="resolvedId + mode"
|
|
5
|
-
:ref="el => setup(el, resolvedId, mode)"
|
|
5
|
+
:ref="el => setup(el, resolvedId, mode, namespace)"
|
|
6
6
|
style="
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 100%;
|
|
@@ -27,6 +27,10 @@ export default {
|
|
|
27
27
|
type: String,
|
|
28
28
|
required: false
|
|
29
29
|
},
|
|
30
|
+
namespace: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
30
34
|
environmentProxy: {
|
|
31
35
|
type: Function,
|
|
32
36
|
required: false
|
|
@@ -58,11 +62,11 @@ export default {
|
|
|
58
62
|
}
|
|
59
63
|
else this.resolvedId = this.id
|
|
60
64
|
},
|
|
61
|
-
async setup(iframe, id, mode) {
|
|
65
|
+
async setup(iframe, id, mode, namespace) {
|
|
62
66
|
if (!iframe || this.iframe === iframe) return
|
|
63
67
|
|
|
64
68
|
this.iframe = iframe
|
|
65
|
-
this.embedding = Agent.embed({ id, mode }, iframe)
|
|
69
|
+
this.embedding = Agent.embed({ id, mode, namespace }, iframe)
|
|
66
70
|
this.embedding.on('environment', e => this.environmentProxy ? this.environmentProxy(e) : Agent.environment(e))
|
|
67
71
|
this.embedding.on('state', e => this.$emit('state', e))
|
|
68
72
|
this.embedding.on('mutate', e => this.$emit('mutate', e))
|