@knowlearning/agents 0.5.4 → 0.5.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",
@@ -7,10 +7,10 @@ const copy = x => JSON.parse(JSON.stringify(x))
7
7
  export default async function (storeDefinition) {
8
8
  // Set up persistance
9
9
  const { scope } = await Agent.environment()
10
- const state = await Agent.state(scope)
10
+ let state = copy(await Agent.state(scope))
11
11
 
12
12
  const scopedPaths = getScopedPaths(storeDefinition)
13
- const stateAttachedStore = await attachModuleState(savedState, storeDefinition, scopedPaths)
13
+ const stateAttachedStore = await attachModuleState(state, storeDefinition, scopedPaths)
14
14
  const s = stateAttachedStore.state
15
15
  const originalState = s instanceof Function ? s() : s
16
16
  const handlePatch = patch => Agent.interact(scope, patch)
@@ -61,7 +61,7 @@ async function attachModuleState(state, module, scopedPaths, path='') {
61
61
  const handlePatch = patch => Agent.interact(scope, patch)
62
62
  const initState = await Agent.state(scope)
63
63
  const ephemeralPaths = descendantPaths(path, scopedPaths)
64
- state = MutableProxy(JSON.parse(JSON.stringify(initState)), handlePatch, ephemeralPaths)
64
+ state = MutableProxy(copy(initState), handlePatch, ephemeralPaths)
65
65
  if (Object.keys(initState).length === 0) Object.assign(state, module.state())
66
66
  }
67
67