theprogrammablemind 9.6.0-beta.2 → 9.6.0-beta.20
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 +16 -4
- package/package.json +2 -1
- package/src/config.js +34 -5
- package/src/configHelpers.js +13 -0
- package/src/fragments.js +13 -0
- package/src/helpers.js +27 -0
package/client.js
CHANGED
|
@@ -292,7 +292,9 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
|
292
292
|
if (rebuildingTemplate) {
|
|
293
293
|
data.errors_ignore_contextual_priorities_non_existant_ops = true
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
|
|
296
|
+
// '\\n' from tests of '\n' from users. the former is because newline is not a valid json character so the testfile has it encoded
|
|
297
|
+
let queries = query.split(/\\n|\n/)
|
|
296
298
|
const summaries = [] // for error
|
|
297
299
|
try {
|
|
298
300
|
const response = {
|
|
@@ -796,6 +798,8 @@ const defaultErrorHandler = async (error) => {
|
|
|
796
798
|
if (typeof runtime.process.exit === 'function' && doErrorExit) {
|
|
797
799
|
runtime.process.exit(-1)
|
|
798
800
|
}
|
|
801
|
+
|
|
802
|
+
error.config = null // otherwise it dumps to much on the console
|
|
799
803
|
|
|
800
804
|
throw error
|
|
801
805
|
}
|
|
@@ -1222,6 +1226,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1222
1226
|
errorHandler = defaultErrorHandler,
|
|
1223
1227
|
process: processResults = defaultProcess,
|
|
1224
1228
|
stopAtFirstFailure = true,
|
|
1229
|
+
demoInitializer,
|
|
1225
1230
|
...rest
|
|
1226
1231
|
} = {}) => {
|
|
1227
1232
|
const unknownArgs = Object.keys(rest)
|
|
@@ -1271,13 +1276,13 @@ const knowledgeModuleImpl = async ({
|
|
|
1271
1276
|
config.stop_auto_rebuild()
|
|
1272
1277
|
await config.add(...(includes || []))
|
|
1273
1278
|
if (api) {
|
|
1274
|
-
config.setApi(api)
|
|
1279
|
+
await config.setApi(api)
|
|
1275
1280
|
}
|
|
1276
1281
|
if (multiApiInitializer) {
|
|
1277
1282
|
await config.setMultiApi(multiApiInitializer)
|
|
1278
1283
|
}
|
|
1279
1284
|
if (initializer) {
|
|
1280
|
-
config.initializer(initializer)
|
|
1285
|
+
await config.initializer(initializer)
|
|
1281
1286
|
}
|
|
1282
1287
|
await config.restart_auto_rebuild()
|
|
1283
1288
|
return config
|
|
@@ -1375,6 +1380,10 @@ const knowledgeModuleImpl = async ({
|
|
|
1375
1380
|
}
|
|
1376
1381
|
config = await createConfig(true, configStruct.name)
|
|
1377
1382
|
|
|
1383
|
+
if (demoInitializer) {
|
|
1384
|
+
await config.setDemoInitializer(demoInitializer)
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1378
1387
|
// dont debug the load of the KM's if rebuild template is on since we want to debug the template rebuild not the load
|
|
1379
1388
|
if (args.rebuildTemplate) {
|
|
1380
1389
|
global.pauseDebugging = true
|
|
@@ -1457,7 +1466,7 @@ const knowledgeModuleImpl = async ({
|
|
|
1457
1466
|
let tests = JSON.parse(runtime.fs.readFileSync(testConfig.name))
|
|
1458
1467
|
tests = tests.filter((test) => test.query !== args.deleteTest)
|
|
1459
1468
|
writeTestFile(testConfig.name, tests)
|
|
1460
|
-
console.log(`
|
|
1469
|
+
console.log(`Delete the test for "${args.deleteTest}"`)
|
|
1461
1470
|
return
|
|
1462
1471
|
}
|
|
1463
1472
|
|
|
@@ -2011,6 +2020,9 @@ const knowledgeModuleImpl = async ({
|
|
|
2011
2020
|
}
|
|
2012
2021
|
const config = await createConfig(rootIsProcess, testingModuleName)
|
|
2013
2022
|
await initConfig(config)
|
|
2023
|
+
if (demoInitializer) {
|
|
2024
|
+
config.setDemoInitializer(demoInitializer)
|
|
2025
|
+
}
|
|
2014
2026
|
// config.rebuild({ isModule: true })
|
|
2015
2027
|
createConfig.cached = config
|
|
2016
2028
|
return createConfig.cached
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
|
5
5
|
"@typescript-eslint/parser": "^4.28.4",
|
|
6
6
|
"argparse": "^2.0.1",
|
|
7
|
+
"baseline-browser-mapping": "^2.9.19",
|
|
7
8
|
"eslint": "^7.32.0",
|
|
8
9
|
"eslint-config-standard": "^16.0.3",
|
|
9
10
|
"eslint-plugin-import": "^2.23.4",
|
|
@@ -72,6 +73,6 @@
|
|
|
72
73
|
"scriptjs": "^2.5.9",
|
|
73
74
|
"uuid": "^8.3.2"
|
|
74
75
|
},
|
|
75
|
-
"version": "9.6.0-beta.
|
|
76
|
+
"version": "9.6.0-beta.20",
|
|
76
77
|
"license": "UNLICENSED"
|
|
77
78
|
}
|
package/src/config.js
CHANGED
|
@@ -431,7 +431,12 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
|
431
431
|
const generator = {
|
|
432
432
|
where: bridge.generatorr.where || bridge.where || helpers.where(4),
|
|
433
433
|
// match: async (args) => bridge.id === args.context.marker && args.context.level === level && !args.context.paraphrase && (args.context.response || args.context.isResponse) && await match(args),
|
|
434
|
-
match: async (args) =>
|
|
434
|
+
match: async (args) => {
|
|
435
|
+
if (bridge.callId == args.callId) {
|
|
436
|
+
debugger
|
|
437
|
+
}
|
|
438
|
+
return args.isA(args.context.marker, bridge.id) && args.context.level === level && !args.context.paraphrase && (args.context.response != null || args.context.isResponse) && await match(args)
|
|
439
|
+
},
|
|
435
440
|
apply: (args) => apply(args),
|
|
436
441
|
applyWrapped: apply,
|
|
437
442
|
property: 'generatorr'
|
|
@@ -523,6 +528,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
523
528
|
'associations',
|
|
524
529
|
'before',
|
|
525
530
|
'bridge',
|
|
531
|
+
'callId',
|
|
526
532
|
'check',
|
|
527
533
|
'children',
|
|
528
534
|
'conditional',
|
|
@@ -536,6 +542,7 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
536
542
|
'generatorr',
|
|
537
543
|
'generators',
|
|
538
544
|
'id',
|
|
545
|
+
'init',
|
|
539
546
|
'inverted',
|
|
540
547
|
'isA',
|
|
541
548
|
'level',
|
|
@@ -1224,10 +1231,10 @@ class Config {
|
|
|
1224
1231
|
async getEvaluator (s, calls, log, context, args) {
|
|
1225
1232
|
const instance = await s({ ...args, ...context, evaluate: true })
|
|
1226
1233
|
calls.touch(instance)
|
|
1227
|
-
if (
|
|
1234
|
+
if (instance.evalue == null && !instance.verbatim && !instance.value) {
|
|
1228
1235
|
this.warningNotEvaluated(log, context)
|
|
1229
1236
|
}
|
|
1230
|
-
if (
|
|
1237
|
+
if (instance.evalue == null) {
|
|
1231
1238
|
instance.evalue = instance.value
|
|
1232
1239
|
instance.edefault = true
|
|
1233
1240
|
}
|
|
@@ -2140,6 +2147,11 @@ class Config {
|
|
|
2140
2147
|
}
|
|
2141
2148
|
}
|
|
2142
2149
|
|
|
2150
|
+
async setDemoInitializer(demoInitializer) {
|
|
2151
|
+
this.demoInitializer = demoInitializer
|
|
2152
|
+
// await this.demoInitializer(this)
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2143
2155
|
// configs = [ { config, namespace } ... ]
|
|
2144
2156
|
constructor (config, module, clientProcess, apiKMs, rootIsProcess, testingModuleName) {
|
|
2145
2157
|
if (config instanceof Config) {
|
|
@@ -2163,6 +2175,7 @@ class Config {
|
|
|
2163
2175
|
config.priorities = config.priorities || []
|
|
2164
2176
|
}
|
|
2165
2177
|
|
|
2178
|
+
this.demoInitializer = null
|
|
2166
2179
|
this.contextChecksFromBridges = []
|
|
2167
2180
|
|
|
2168
2181
|
this._enable = []
|
|
@@ -2276,7 +2289,7 @@ class Config {
|
|
|
2276
2289
|
|
|
2277
2290
|
async restart_auto_rebuild () {
|
|
2278
2291
|
this._stop_auto_rebuild = false
|
|
2279
|
-
await this.rebuild()
|
|
2292
|
+
return await this.rebuild()
|
|
2280
2293
|
}
|
|
2281
2294
|
|
|
2282
2295
|
getAddedArgs (args) {
|
|
@@ -2479,6 +2492,7 @@ class Config {
|
|
|
2479
2492
|
this.valid()
|
|
2480
2493
|
const cp = new Config()
|
|
2481
2494
|
cp.logs = []
|
|
2495
|
+
cp.demoInitializer = this.demoInitializer
|
|
2482
2496
|
cp.maxDepth = this.maxDepth
|
|
2483
2497
|
cp.debugLoops = this.debugLoops
|
|
2484
2498
|
cp.transitoryMode = this.transitoryMode
|
|
@@ -2553,6 +2567,11 @@ class Config {
|
|
|
2553
2567
|
cp.config.objects.namespaced[km._uuid] = {}
|
|
2554
2568
|
})
|
|
2555
2569
|
}
|
|
2570
|
+
|
|
2571
|
+
if (cp.demoInitializer) {
|
|
2572
|
+
await cp.demoInitializer(cp)
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2556
2575
|
cp.valid()
|
|
2557
2576
|
return cp
|
|
2558
2577
|
}
|
|
@@ -3077,6 +3096,15 @@ class Config {
|
|
|
3077
3096
|
this.removeDevelopmentElements(this.config)
|
|
3078
3097
|
}
|
|
3079
3098
|
|
|
3099
|
+
if (this.testConfig?.testModuleName) {
|
|
3100
|
+
const km = this.km(this.testConfig.testModuleName)
|
|
3101
|
+
if (km.demoInitializer) {
|
|
3102
|
+
await km.demoInitializer(km)
|
|
3103
|
+
}
|
|
3104
|
+
} else if (this.demoInitializer) {
|
|
3105
|
+
await this.demoInitializer(this)
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3080
3108
|
this.valid()
|
|
3081
3109
|
this.checks()
|
|
3082
3110
|
}
|
|
@@ -3462,7 +3490,8 @@ class Config {
|
|
|
3462
3490
|
}
|
|
3463
3491
|
|
|
3464
3492
|
// TODO get rid of useOldVersion arg
|
|
3465
|
-
addInternal (more,
|
|
3493
|
+
addInternal (more,
|
|
3494
|
+
{ uuid, km, addFirst = false, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false, handleCalculatedProps: hcps = false } = {}) {
|
|
3466
3495
|
validConfigProps(more)
|
|
3467
3496
|
if (more instanceof Config) {
|
|
3468
3497
|
more.initialize({ force: false })
|
package/src/configHelpers.js
CHANGED
|
@@ -151,12 +151,22 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
151
151
|
// debugger
|
|
152
152
|
// }
|
|
153
153
|
const { assumed = {}, options = {} } = rest
|
|
154
|
+
// have it default to paraphrase
|
|
155
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
156
|
+
return `${c}`
|
|
157
|
+
}
|
|
158
|
+
if (false && !(assumed.isResponse && assumed.response)) {
|
|
159
|
+
assumed.paraphrase = true
|
|
160
|
+
}
|
|
154
161
|
return config.getGenerators(logs).apply(addAssumed(args, assumed), c, assumed, options)
|
|
155
162
|
}
|
|
156
163
|
args.gp = (c, rest = {}) => {
|
|
157
164
|
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
158
165
|
// debugger
|
|
159
166
|
// }
|
|
167
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
168
|
+
return `${c}`
|
|
169
|
+
}
|
|
160
170
|
const { assumed = {}, options = {} } = rest
|
|
161
171
|
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: true, isResponse: false, response: false }), c, { paraphrase: true, isResponse: false, response: false }, options)
|
|
162
172
|
}
|
|
@@ -164,6 +174,9 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
164
174
|
// if (JSON.stringify(rest) !== '{}' && !(rest.assumed || rest.options)) {
|
|
165
175
|
// debugger
|
|
166
176
|
// }
|
|
177
|
+
if (['number', 'string', 'boolean'].includes(typeof c)) {
|
|
178
|
+
return `${c}`
|
|
179
|
+
}
|
|
167
180
|
const { assumed = {}, options = {} } = rest
|
|
168
181
|
return config.getGenerators(logs).apply(addAssumed(args, assumed, { paraphrase: false, isResponse: true }), { ...c, paraphrase: false, isResponse: true }, options)
|
|
169
182
|
}
|
package/src/fragments.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
const helpers = require('./helpers')
|
|
3
3
|
|
|
4
|
+
function pathEquals (p1, p2) {
|
|
5
|
+
if (p1.length !== p2.length) {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
for (let i = 0; i < p1.length; ++i) {
|
|
9
|
+
if (p1[i] !== p2[i]) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
function fragmentInstantiator (args, contexts) {
|
|
5
17
|
return new Object({
|
|
6
18
|
contexts: () => {
|
|
@@ -10,6 +22,7 @@ function fragmentInstantiator (args, contexts) {
|
|
|
10
22
|
const instantiated = _.cloneDeep(contexts)
|
|
11
23
|
const todo = [{ context: instantiated, path: [] }]
|
|
12
24
|
args = { ...args }
|
|
25
|
+
args.pathEquals = pathEquals
|
|
13
26
|
while (todo.length > 0) {
|
|
14
27
|
const { context, path } = todo.pop()
|
|
15
28
|
args.context = context
|
package/src/helpers.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
const deepEqual = require('deep-equal')
|
|
2
2
|
const stringify = require('json-stable-stringify')
|
|
3
3
|
|
|
4
|
+
function watchProperty(obj, propName) {
|
|
5
|
+
let value = obj[propName];
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(obj, propName, {
|
|
8
|
+
get() {
|
|
9
|
+
return value;
|
|
10
|
+
},
|
|
11
|
+
set(newValue) {
|
|
12
|
+
console.log(`%c${propName} changed →`, 'color: #e83', newValue);
|
|
13
|
+
debugger; // ← Chrome/Firefox will pause here automatically
|
|
14
|
+
value = newValue;
|
|
15
|
+
},
|
|
16
|
+
configurable: true // allows us to delete/restore later if needed
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function assignAssumed(object, assumed) {
|
|
21
|
+
for (const key in assumed) {
|
|
22
|
+
if (object[key] == null) {
|
|
23
|
+
object[key] = assumed[key]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return object
|
|
27
|
+
}
|
|
28
|
+
|
|
4
29
|
function where (goUp = 2) {
|
|
5
30
|
const e = new Error()
|
|
6
31
|
const regexForm1 = /\((.*):(\d+):(\d+)\)$/
|
|
@@ -567,4 +592,6 @@ module.exports = {
|
|
|
567
592
|
suggestAssociationsFixFromSummaries,
|
|
568
593
|
getByPath,
|
|
569
594
|
setByPath,
|
|
595
|
+
assignAssumed,
|
|
596
|
+
watchProperty,
|
|
570
597
|
}
|