theprogrammablemind 9.6.0-beta.1 → 9.6.0-beta.12

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 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
- let queries = query.split('\\n')
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 = {
@@ -1222,6 +1224,7 @@ const knowledgeModuleImpl = async ({
1222
1224
  errorHandler = defaultErrorHandler,
1223
1225
  process: processResults = defaultProcess,
1224
1226
  stopAtFirstFailure = true,
1227
+ demoInitializer,
1225
1228
  ...rest
1226
1229
  } = {}) => {
1227
1230
  const unknownArgs = Object.keys(rest)
@@ -1271,13 +1274,13 @@ const knowledgeModuleImpl = async ({
1271
1274
  config.stop_auto_rebuild()
1272
1275
  await config.add(...(includes || []))
1273
1276
  if (api) {
1274
- config.setApi(api)
1277
+ await config.setApi(api)
1275
1278
  }
1276
1279
  if (multiApiInitializer) {
1277
1280
  await config.setMultiApi(multiApiInitializer)
1278
1281
  }
1279
1282
  if (initializer) {
1280
- config.initializer(initializer)
1283
+ await config.initializer(initializer)
1281
1284
  }
1282
1285
  await config.restart_auto_rebuild()
1283
1286
  return config
@@ -1375,6 +1378,10 @@ const knowledgeModuleImpl = async ({
1375
1378
  }
1376
1379
  config = await createConfig(true, configStruct.name)
1377
1380
 
1381
+ if (demoInitializer) {
1382
+ await config.setDemoInitializer(demoInitializer)
1383
+ }
1384
+
1378
1385
  // 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
1386
  if (args.rebuildTemplate) {
1380
1387
  global.pauseDebugging = true
@@ -2011,6 +2018,9 @@ const knowledgeModuleImpl = async ({
2011
2018
  }
2012
2019
  const config = await createConfig(rootIsProcess, testingModuleName)
2013
2020
  await initConfig(config)
2021
+ if (demoInitializer) {
2022
+ config.setDemoInitializer(demoInitializer)
2023
+ }
2014
2024
  // config.rebuild({ isModule: true })
2015
2025
  createConfig.cached = config
2016
2026
  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.1",
76
+ "version": "9.6.0-beta.12",
76
77
  "license": "UNLICENSED"
77
78
  }
package/src/config.js CHANGED
@@ -2140,6 +2140,11 @@ class Config {
2140
2140
  }
2141
2141
  }
2142
2142
 
2143
+ async setDemoInitializer(demoInitializer) {
2144
+ this.demoInitializer = demoInitializer
2145
+ // await this.demoInitializer(this)
2146
+ }
2147
+
2143
2148
  // configs = [ { config, namespace } ... ]
2144
2149
  constructor (config, module, clientProcess, apiKMs, rootIsProcess, testingModuleName) {
2145
2150
  if (config instanceof Config) {
@@ -2163,6 +2168,7 @@ class Config {
2163
2168
  config.priorities = config.priorities || []
2164
2169
  }
2165
2170
 
2171
+ this.demoInitializer = null
2166
2172
  this.contextChecksFromBridges = []
2167
2173
 
2168
2174
  this._enable = []
@@ -2276,7 +2282,7 @@ class Config {
2276
2282
 
2277
2283
  async restart_auto_rebuild () {
2278
2284
  this._stop_auto_rebuild = false
2279
- await this.rebuild()
2285
+ return await this.rebuild()
2280
2286
  }
2281
2287
 
2282
2288
  getAddedArgs (args) {
@@ -2479,6 +2485,7 @@ class Config {
2479
2485
  this.valid()
2480
2486
  const cp = new Config()
2481
2487
  cp.logs = []
2488
+ cp.demoInitializer = this.demoInitializer
2482
2489
  cp.maxDepth = this.maxDepth
2483
2490
  cp.debugLoops = this.debugLoops
2484
2491
  cp.transitoryMode = this.transitoryMode
@@ -2553,6 +2560,11 @@ class Config {
2553
2560
  cp.config.objects.namespaced[km._uuid] = {}
2554
2561
  })
2555
2562
  }
2563
+
2564
+ if (cp.demoInitializer) {
2565
+ await cp.demoInitializer(cp)
2566
+ }
2567
+
2556
2568
  cp.valid()
2557
2569
  return cp
2558
2570
  }
@@ -3077,6 +3089,15 @@ class Config {
3077
3089
  this.removeDevelopmentElements(this.config)
3078
3090
  }
3079
3091
 
3092
+ if (this.testConfig?.testModuleName) {
3093
+ const km = this.km(this.testConfig.testModuleName)
3094
+ if (km.demoInitializer) {
3095
+ await km.demoInitializer(km)
3096
+ }
3097
+ } else if (this.demoInitializer) {
3098
+ await this.demoInitializer(this)
3099
+ }
3100
+
3080
3101
  this.valid()
3081
3102
  this.checks()
3082
3103
  }
@@ -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/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
  }