tpmkms_4wp 9.2.0 → 9.3.0-beta.0

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.
Files changed (52) hide show
  1. package/common/animals.instance.json +21 -8
  2. package/common/avatar.js +2 -10
  3. package/common/colors.instance.json +32 -46
  4. package/common/comparable.instance.json +3 -0
  5. package/common/comparable.js +2 -2
  6. package/common/crew.instance.json +4736 -964
  7. package/common/crew.test.json +1904 -0
  8. package/common/dates.instance.json +28643 -0
  9. package/common/dates.js +167 -0
  10. package/common/dates.test.json +16226 -0
  11. package/common/dialogues.js +28 -9
  12. package/common/dimension.instance.json +3 -2
  13. package/common/edible.instance.json +1474 -759
  14. package/common/emotions.instance.json +7 -14
  15. package/common/emotions.js +4 -5
  16. package/common/fastfood.instance.json +3914 -722
  17. package/common/fastfood.js +7 -0
  18. package/common/formulas.instance.json +1 -0
  19. package/common/gdefaults.js +18 -0
  20. package/common/helpers/concept.js +1 -0
  21. package/common/helpers/dialogues.js +3 -0
  22. package/common/helpers/properties.js +2 -27
  23. package/common/helpers.js +70 -1
  24. package/common/hierarchy.js +4 -3
  25. package/common/kirk.instance.json +186 -124
  26. package/common/length.instance.json +17 -2
  27. package/common/math.instance.json +1 -0
  28. package/common/menus.instance.json +7 -0
  29. package/common/menus.js +1 -0
  30. package/common/menus.test.json +2418 -1355
  31. package/common/meta.js +3 -3
  32. package/common/ordering.instance.json +4 -2
  33. package/common/people.instance.json +8 -0
  34. package/common/pipboy.instance.json +29 -68
  35. package/common/pokemon.instance.json +24 -3
  36. package/common/pressure.instance.json +6 -2
  37. package/common/properties.instance.json +1 -0
  38. package/common/properties.js +19 -5
  39. package/common/punctuation.js +3 -0
  40. package/common/reports.instance.json +24 -14
  41. package/common/reports.js +2 -2
  42. package/common/self.instance.json +2 -0
  43. package/common/self.js +49 -0
  44. package/common/self.test.json +2 -0
  45. package/common/spock.instance.json +186 -124
  46. package/common/temperature.instance.json +6 -2
  47. package/common/ui.instance.json +1 -0
  48. package/common/weight.instance.json +12 -0
  49. package/common/wp.instance.json +777 -151
  50. package/common/wp.js +15 -2
  51. package/main.js +4 -0
  52. package/package.json +10 -2
@@ -369,6 +369,7 @@ const template = {
369
369
  hierarchy: [
370
370
  ['meal', 'toAble'],
371
371
  ['drink', 'toAble'],
372
+ ['smoothie_modifier', 'sizeable'],
372
373
  ],
373
374
  bridges: [
374
375
  {
@@ -433,6 +434,12 @@ const template = {
433
434
  }
434
435
  },
435
436
  ],
437
+ associations: {
438
+ positive: [
439
+ { context: [['combo', 0], ['integer', 0]], choose: 0 },
440
+ { context: [['combo', 0], ['integer', 1]], choose: 0 },
441
+ ],
442
+ },
436
443
  },
437
444
  ],
438
445
  }
@@ -1203,6 +1203,7 @@
1203
1203
  }
1204
1204
  ],
1205
1205
  "learned_contextual_priorities": [],
1206
+ "rtf_associations": [],
1206
1207
  "query": "formulas are concepts",
1207
1208
  "key": {
1208
1209
  "query": "formulas are concepts"
@@ -4,6 +4,7 @@ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
5
  const gdefaults_tests = require('./gdefaults.test.json')
6
6
  const { getValue, isMany } = require('./helpers.js')
7
+ const helpers = require('./helpers')
7
8
 
8
9
  const config = {
9
10
  name: 'gdefaults',
@@ -29,6 +30,13 @@ const config = {
29
30
  apply: ({context, gp}) => gp(context.response),
30
31
  },
31
32
 
33
+ {
34
+ where: where(),
35
+ match: ({context}) => context.paraphrase && context.interpolate,
36
+ apply: async ({interpolate, context}) => {
37
+ return interpolate(context.interpolate, context)
38
+ }
39
+ },
32
40
  {
33
41
  where: where(),
34
42
  match: ({context}) => context.generate,
@@ -232,6 +240,16 @@ const initializer = ({config}) => {
232
240
  verbatim: (text) => {
233
241
  args.insert({ marker: 'verbatim', verbatim: text, isResponse: true })
234
242
  },
243
+ interpolate: async (interpolate, context) => {
244
+ const evaluator = async (key) => {
245
+ if (Array.isArray(context[key])) {
246
+ return args.gsp(context[key])
247
+ } else {
248
+ return args.gp(context[key])
249
+ }
250
+ }
251
+ return await helpers.processTemplateString(interpolate, evaluator)
252
+ }
235
253
  }
236
254
  })
237
255
  }
@@ -106,6 +106,7 @@ class API {
106
106
  level: 0,
107
107
  convolution: true,
108
108
  isA: [{ parent: 'adjective', instance: true }],
109
+ associator_return_type: [modifiersObjectId, 0],
109
110
  // isA: ['adjective'],
110
111
  before: ['verb'],
111
112
  bridge: `{ ...after[0], ${modifierProperties}, atomic: true, dead: true, marker: next(operator('${modifiersObjectId}')), value: '${modifiersObjectId}', modifiers: append([${modifierList}], after[0].modifiers)}`,
@@ -83,6 +83,9 @@ class API {
83
83
  return context.value
84
84
  }
85
85
  */
86
+ if (typeof context == 'string') {
87
+ context = { word: context, value: context }
88
+ }
86
89
  const { word, value, number } = context;
87
90
  if (!value) {
88
91
  return
@@ -548,8 +548,7 @@ class API {
548
548
 
549
549
  makeObject(args) {
550
550
  const types = [ 'hierarchyAble', 'object', 'property' ];
551
- const { config } = args;
552
- return this._km("dialogues").api.makeObject({ ...args, types });
551
+ return args.km("dialogues").api.makeObject({ ...args, types: (args.types || []).concat(types) });
553
552
  }
554
553
 
555
554
  relation_add (relations) {
@@ -704,6 +703,7 @@ class API {
704
703
  }
705
704
 
706
705
  setProperty(object, property, value, has, skipHandler) {
706
+ // debugger
707
707
  if (!skipHandler) {
708
708
  const handler = this.propertiesFH.getHandler([object, property])
709
709
  if (handler) {
@@ -794,31 +794,6 @@ class API {
794
794
 
795
795
  learnWords(config, context) {
796
796
  }
797
- /*
798
- ensureDefault(map, key, default) {
799
- if (!this._objects[map][key]) {
800
- this._objects[map][key] = default
801
- }
802
- return this._objects[map][key]
803
- }
804
-
805
- pushListNoDups(list, value) {
806
- if (list.includes(value)) {
807
- return
808
- }
809
- list.push(value)
810
- }
811
-
812
- ensureConcept(concept) {
813
- ensureDefault(this.properties, concept, {})
814
- ensureDefault(this.concepts, concept, [])
815
- }
816
-
817
- canDo(object, ability) {
818
- this.ensureConcept(object)
819
- this.pushListNoDups(this.ensureList('abilities', object), ability)
820
- }
821
- */
822
797
  isA(child, ancestor) {
823
798
  // return this._objects.parents[child].includes(parent);
824
799
  const todo = [child];
package/common/helpers.js CHANGED
@@ -151,11 +151,39 @@ const toEValue = (context) => {
151
151
  return context;
152
152
  }
153
153
 
154
+ const defaultContextCheckValidify = (properties) => {
155
+ for (const value of properties) {
156
+ if (typeof value == 'string') {
157
+ continue
158
+ }
159
+ if (typeof value.property == 'string' && value.filter) {
160
+ continue
161
+ }
162
+ throw new Error("Expected the <checks> argument to defaultContextCheck to be a list of <property> or { property: <property>, filter: <checks> }. Where <property> is a string.")
163
+ }
164
+ }
165
+
154
166
  const defaultContextCheckProperties = ['marker', 'text', 'verbatim', 'isResponse', { property: 'response', filter: ['marker', 'text', 'verbatim'] }]
167
+
168
+ const expand_checks = (properties) => {
169
+ const expanded = []
170
+ for (const property of properties) {
171
+ defaultContextCheckValidify(properties)
172
+ if (typeof property == 'string') {
173
+ expanded.push({ property, filter: defaultContextCheckProperties })
174
+ } else {
175
+ expanded.push({ property: property.property, filter: [...defaultContextCheckProperties, ...expand_checks(property.filter)] })
176
+ }
177
+ }
178
+ return expanded
179
+ }
180
+
155
181
  const defaultContextCheck = (properties = []) => {
182
+ defaultContextCheckValidify(properties)
156
183
  return [
157
184
  ...defaultContextCheckProperties,
158
- ...properties.map((property) => { return { property, filter: defaultContextCheckProperties } }),
185
+ // ...properties.map((property) => { return { property, filter: defaultContextCheckProperties } }),
186
+ ...expand_checks(properties),
159
187
  (object) => {
160
188
  if (typeof object.value == 'object') {
161
189
  return { property: 'value', filter: defaultContextCheckProperties }
@@ -220,7 +248,48 @@ const getValue = (propertyPath, object) => {
220
248
  return value
221
249
  }
222
250
 
251
+ const processTemplateString = async (template, evaluate) => {
252
+ async function resolveWithCallback(strings, ...keys) {
253
+ // const resolvedValues = await Promise.all(keys.map(key => lookupVariable(key)));
254
+ const resolvedValues = await Promise.all(keys.map(async (key) => {
255
+ return await evaluate(key)
256
+ }))
257
+
258
+ let result = strings[0];
259
+ for (let i = 0; i < resolvedValues.length; i++) {
260
+ result += resolvedValues[i] + strings[(i + 1)*2];
261
+ }
262
+ return result;
263
+ }
264
+
265
+ async function processTemplateString(template) {
266
+ // Split the template into strings and keys
267
+ const parts = template.split(/(\${[^}]+})/g);
268
+ const strings = [];
269
+ const keys = [];
270
+ for (const part of parts) {
271
+ if (part.startsWith("${") && part.endsWith("}")) {
272
+ keys.push(part.slice(2, -1)); // Extract key (e.g., "name" from "${name}")
273
+ strings.push(""); // Placeholder for interpolation
274
+ } else {
275
+ strings.push(part);
276
+ }
277
+ }
278
+
279
+ // Ensure the strings array has one more element than keys
280
+ if (strings.length === keys.length) {
281
+ strings.push("");
282
+ }
283
+
284
+ // Pass to the tagged template function
285
+ return resolveWithCallback(strings, ...keys);
286
+ }
287
+
288
+ return await processTemplateString(template)
289
+ }
290
+
223
291
  module.exports = {
292
+ processTemplateString,
224
293
  unshiftL,
225
294
  pushL,
226
295
  getValue,
@@ -246,14 +246,15 @@ const config = {
246
246
 
247
247
  return listable(context, 'hierarchyAble') && context.same && context.same.concept && !context.query
248
248
  },
249
- apply: ({callId, config, objects, km, context, asList, listable}) => {
249
+ apply: (args) => {
250
+ const {callId, config, objects, km, context, asList, listable} = args
250
251
  const api = km('properties').api
251
252
  const oneConcepts = asList(context);
252
253
  const twoConcepts = asList(context.same);
253
254
  for (const oneConcept of oneConcepts.value) {
254
255
  for (const twoConcept of twoConcepts.value) {
255
- oneConceptId = api.makeObject({config, context: oneConcept})
256
- twoConceptId = api.makeObject({config, context: twoConcept})
256
+ oneConceptId = api.makeObject({...args, context: oneConcept})
257
+ twoConceptId = api.makeObject({...args, context: twoConcept})
257
258
  api.rememberIsA(oneConceptId, twoConceptId)
258
259
  context.sameWasProcessed = true
259
260
  }