entodicton 9.6.1 → 9.6.2
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/client.js +13 -6
- package/package.json +1 -1
- package/src/configHelpers.js +22 -10
- package/src/project2.js +11 -1
package/client.js
CHANGED
|
@@ -12,7 +12,7 @@ const _ = require('lodash')
|
|
|
12
12
|
const stringify = require('json-stable-stringify')
|
|
13
13
|
const Lines = require('./lines')
|
|
14
14
|
const flattens = require('./src/flatten')
|
|
15
|
-
const { sortJson, appendNoDups, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
|
15
|
+
const { sortJson, appendNoDups, InitCalls, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
|
16
16
|
const runtime = require('./runtime')
|
|
17
17
|
const db = require('./src/debug')
|
|
18
18
|
|
|
@@ -319,6 +319,13 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
|
319
319
|
|
|
320
320
|
let startCounter = 0
|
|
321
321
|
let contextIdCounter = 0
|
|
322
|
+
let calls
|
|
323
|
+
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
|
324
|
+
calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
|
325
|
+
} else {
|
|
326
|
+
calls = new InitCalls(config.getName())
|
|
327
|
+
}
|
|
328
|
+
|
|
322
329
|
while (true) {
|
|
323
330
|
if (queries.length === 0) {
|
|
324
331
|
break
|
|
@@ -330,7 +337,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
|
330
337
|
let resetData = false
|
|
331
338
|
if (json.code === 'NOT_IN_CACHE') {
|
|
332
339
|
resetData = true
|
|
333
|
-
const setupB = setupProcessB({ config, allowDelta: false })
|
|
340
|
+
const setupB = setupProcessB({ config, calls, allowDelta: false })
|
|
334
341
|
data = setupB.data
|
|
335
342
|
hierarchy = setupB.hierarchy
|
|
336
343
|
data.utterance = queries[0]
|
|
@@ -360,7 +367,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
|
360
367
|
const summary = { summaries: json.summaries, length: json.contexts.length }
|
|
361
368
|
summaries.push(summary)
|
|
362
369
|
const { updatedContextIdCounter, contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
|
|
363
|
-
await processContextsB({ contextIdCounter, isTest, isProcess, isModule, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
|
370
|
+
await processContextsB({ contextIdCounter, calls, isTest, isProcess, isModule, rebuildingTemplate, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
|
364
371
|
contextIdCounter = updatedContextIdCounter
|
|
365
372
|
if (isTest) {
|
|
366
373
|
const end = runtime.performance.performance.now()
|
|
@@ -657,11 +664,11 @@ const saveTestsHelper = async (testFile, config, tests, todo, testConfig, saveDe
|
|
|
657
664
|
return
|
|
658
665
|
}
|
|
659
666
|
const test = todo.pop()
|
|
660
|
-
await config.rebuild()
|
|
667
|
+
// await config.rebuild()
|
|
661
668
|
const result = await saveTest(testFile, config, test, tests[test], testConfig, saveDeveloper)
|
|
662
669
|
// initialize in between test so state is not preserved since the test was adding without state
|
|
663
670
|
// config.initialize({force: true})
|
|
664
|
-
await config.rebuild()
|
|
671
|
+
// await config.rebuild()
|
|
665
672
|
return saveTestsHelper(testFile, config, tests, todo, testConfig, saveDeveloper)
|
|
666
673
|
}
|
|
667
674
|
|
|
@@ -755,7 +762,7 @@ const defaultErrorHandler = async (error) => {
|
|
|
755
762
|
console.log('trace: ', error.trace)
|
|
756
763
|
}
|
|
757
764
|
|
|
758
|
-
if (error.config) {
|
|
765
|
+
if (false && error.config) {
|
|
759
766
|
console.log('objects', runtime.util.inspect(error.config.get('objects'), { depth: Infinity, sorted: true }))
|
|
760
767
|
}
|
|
761
768
|
|
package/package.json
CHANGED
package/src/configHelpers.js
CHANGED
|
@@ -99,10 +99,18 @@ class ContextHierarchy {
|
|
|
99
99
|
this.contexts.pop()
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
under(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
under(markers) {
|
|
103
|
+
if (!markers || markers.length == 0) {
|
|
104
|
+
return this.contexts.length == 0
|
|
105
|
+
}
|
|
106
|
+
if (!Array.isArray(markers)) {
|
|
107
|
+
markers = [markers]
|
|
108
|
+
}
|
|
109
|
+
for (const marker of markers) {
|
|
110
|
+
for (let i = this.contexts.length - 1; i >= 0; --i) {
|
|
111
|
+
if (this.contexts[i].marker == marker) {
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
}
|
|
@@ -123,9 +131,12 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
123
131
|
hierarchy = config.getHierarchy()
|
|
124
132
|
}
|
|
125
133
|
// callId
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
args.calls = new InitCalls(
|
|
134
|
+
// debug.counter('InitCalls', { breakAt: 641 })
|
|
135
|
+
if (!args.calls) {
|
|
136
|
+
args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.getName()}` : config.getName())
|
|
137
|
+
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
|
138
|
+
args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
|
139
|
+
}
|
|
129
140
|
}
|
|
130
141
|
args.contextHierarchy = new ContextHierarchy()
|
|
131
142
|
args.cleanAssign = cleanAssign
|
|
@@ -356,7 +367,7 @@ const setupContexts = (rawContexts) => {
|
|
|
356
367
|
return contexts
|
|
357
368
|
}
|
|
358
369
|
|
|
359
|
-
const processContextsB = async ({ config, hierarchy, semantics, generators, json, isTest, isProcess, isModule, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs, forTemplate, contextIdCounter }) => {
|
|
370
|
+
const processContextsB = async ({ config, calls, hierarchy, semantics, generators, json, isTest, isProcess, isModule, rebuildingTemplate, isInstance, instance, query, data, retries, url, commandLineArgs, forTemplate, contextIdCounter }) => {
|
|
360
371
|
// TODO fix this name to contextsPrime
|
|
361
372
|
const contextsPrime = []
|
|
362
373
|
const generatedPrime = []
|
|
@@ -367,7 +378,7 @@ const processContextsB = async ({ config, hierarchy, semantics, generators, json
|
|
|
367
378
|
const contexts = setupContexts(json.contexts)
|
|
368
379
|
|
|
369
380
|
const objects = config.get('objects')
|
|
370
|
-
const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), instance, contexts, isProcess, isModule }
|
|
381
|
+
const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), instance, contexts, isProcess, isModule, calls }
|
|
371
382
|
if (!json.logs) {
|
|
372
383
|
json.logs = []
|
|
373
384
|
}
|
|
@@ -578,5 +589,6 @@ module.exports = {
|
|
|
578
589
|
gs,
|
|
579
590
|
processContextsB,
|
|
580
591
|
loadInstance,
|
|
581
|
-
isA
|
|
592
|
+
isA,
|
|
593
|
+
ContextHierarchy,
|
|
582
594
|
}
|
package/src/project2.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const debug = require('./debug')
|
|
2
|
+
|
|
1
3
|
function areFirstNEqual(arr1, arr2, n) {
|
|
2
4
|
if (n <= 0) return true;
|
|
3
5
|
if (arr1.length < n || arr2.length < n) return false;
|
|
@@ -89,7 +91,15 @@ function project(source, filters, path=[]) {
|
|
|
89
91
|
if (typeof source[prop.property] === 'object' && source[prop.property] !== null) {
|
|
90
92
|
result[prop.property] = {}
|
|
91
93
|
for (const key of prop.check) {
|
|
92
|
-
|
|
94
|
+
if (typeof key == 'string') {
|
|
95
|
+
result[prop.property][key] = project(source[prop.property][key], filters, [...path, prop.property, key]);
|
|
96
|
+
} else {
|
|
97
|
+
const f = {
|
|
98
|
+
match: () => true,
|
|
99
|
+
apply: () => key.check
|
|
100
|
+
}
|
|
101
|
+
result[prop.property][key.property] = project(source[prop.property][key.property], [f], [...path, prop.property, key.property]);
|
|
102
|
+
}
|
|
93
103
|
}
|
|
94
104
|
} else {
|
|
95
105
|
// Copy primitive or null properties directly
|