tpmkms 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.
Files changed (37) hide show
  1. package/common/actions.instance.json +99 -0
  2. package/common/actions.js +67 -0
  3. package/common/actions.test.json +656 -0
  4. package/common/angle.instance.json +20 -0
  5. package/common/colors.instance.json +0 -28
  6. package/common/compass.instance.json +15 -0
  7. package/common/dates.instance.json +0 -84
  8. package/common/dialogues.js +1 -1
  9. package/common/dimension.instance.json +96 -12
  10. package/common/dimension.js +12 -3
  11. package/common/drone.instance.json +10130 -1641
  12. package/common/drone.js +217 -71
  13. package/common/drone.test.json +192134 -3455
  14. package/common/drone_v1.instance.json +38 -31
  15. package/common/drone_v1.js +20 -15
  16. package/common/drone_v1.test.json +659 -389
  17. package/common/edible.instance.json +0 -128
  18. package/common/fastfood.instance.json +72 -392
  19. package/common/gdefaults.js +5 -1
  20. package/common/helpers/conjunction.js +9 -5
  21. package/common/helpers/drone.js +13 -1
  22. package/common/length.instance.json +135 -0
  23. package/common/nameable.js +63 -24
  24. package/common/nameable.test.json +3270 -3912
  25. package/common/ordinals.js +13 -0
  26. package/common/pipboy.instance.json +0 -56
  27. package/common/pressure.instance.json +20 -0
  28. package/common/properties.js +16 -6
  29. package/common/reports.instance.json +1 -1
  30. package/common/stm.js +119 -25
  31. package/common/temperature.instance.json +20 -0
  32. package/common/time.instance.json +45 -0
  33. package/common/time.test.json +3403 -0
  34. package/common/weight.instance.json +60 -0
  35. package/common/wp.instance.json +0 -56
  36. package/main.js +2 -0
  37. package/package.json +6 -2
@@ -364,7 +364,11 @@ function initializer({config}) {
364
364
  value = { ...value, ...element.context }
365
365
  }
366
366
  strings.push(separator)
367
- strings.push(await args.gp(value))
367
+ if (Array.isArray(value)) {
368
+ strings.push(await args.gsp(value))
369
+ } else {
370
+ strings.push(await args.gp(value))
371
+ }
368
372
  separator = ' '
369
373
  }
370
374
  } else if (element.context) {
@@ -1,6 +1,6 @@
1
1
  const { propertyToArray } = require('../helpers.js')
2
2
 
3
- function asList(context) {
3
+ function asList(context, maybe=false) {
4
4
  if (Array.isArray(context)) {
5
5
  return {
6
6
  marker: 'list',
@@ -10,10 +10,14 @@ function asList(context) {
10
10
  } else if (context.marker === 'list') {
11
11
  return context
12
12
  }
13
- return {
14
- marker: 'list',
15
- types: [context.marker],
16
- value: [context]
13
+ if (maybe) {
14
+ return context
15
+ } else {
16
+ return {
17
+ marker: 'list',
18
+ types: [context.marker],
19
+ value: [context]
20
+ }
17
21
  }
18
22
  }
19
23
 
@@ -32,8 +32,19 @@ function radiansToDegrees(radians) {
32
32
  return (radians * 180) / Math.PI;
33
33
  }
34
34
 
35
+ function smallestRotate(angle) {
36
+ angle = angle % (Math.PI*2)
37
+ if (angle > 0 && angle > Math.PI) {
38
+ angle = -(Math.PI*2 - angle)
39
+ }
40
+ if (angle < 0 && angle < -Math.PI) {
41
+ angle = Math.PI*2 + angle
42
+ }
43
+ return angle
44
+ }
45
+
35
46
  function rotateDelta(currentRadians, targetRadians) {
36
- return (((targetRadians - currentRadians + Math.PI) % (2 * Math.PI)) - Math.PI)
47
+ return smallestRotate(((targetRadians - currentRadians + Math.PI) % (2 * Math.PI)) - Math.PI)
37
48
  }
38
49
 
39
50
  module.exports = {
@@ -41,4 +52,5 @@ module.exports = {
41
52
  degreesToRadians,
42
53
  radiansToDegrees,
43
54
  rotateDelta,
55
+ smallestRotate,
44
56
  }
@@ -366,6 +366,11 @@
366
366
  "expression",
367
367
  false
368
368
  ],
369
+ [
370
+ "forQuantity",
371
+ "preposition",
372
+ false
373
+ ],
369
374
  [
370
375
  "forVariable",
371
376
  "preposition",
@@ -2568,6 +2573,11 @@
2568
2573
  "expression",
2569
2574
  false
2570
2575
  ],
2576
+ [
2577
+ "forQuantity",
2578
+ "preposition",
2579
+ false
2580
+ ],
2571
2581
  [
2572
2582
  "forVariable",
2573
2583
  "preposition",
@@ -6641,6 +6651,11 @@
6641
6651
  "unit_length",
6642
6652
  false
6643
6653
  ],
6654
+ [
6655
+ "forQuantity",
6656
+ "preposition",
6657
+ false
6658
+ ],
6644
6659
  [
6645
6660
  "forVariable",
6646
6661
  "preposition",
@@ -9781,6 +9796,11 @@
9781
9796
  "unit_length",
9782
9797
  false
9783
9798
  ],
9799
+ [
9800
+ "forQuantity",
9801
+ "preposition",
9802
+ false
9803
+ ],
9784
9804
  [
9785
9805
  "forVariable",
9786
9806
  "preposition",
@@ -12498,6 +12518,11 @@
12498
12518
  "unit_length",
12499
12519
  false
12500
12520
  ],
12521
+ [
12522
+ "forQuantity",
12523
+ "preposition",
12524
+ false
12525
+ ],
12501
12526
  [
12502
12527
  "forVariable",
12503
12528
  "preposition",
@@ -15244,6 +15269,11 @@
15244
15269
  "unit_length",
15245
15270
  false
15246
15271
  ],
15272
+ [
15273
+ "forQuantity",
15274
+ "preposition",
15275
+ false
15276
+ ],
15247
15277
  [
15248
15278
  "forVariable",
15249
15279
  "preposition",
@@ -17990,6 +18020,11 @@
17990
18020
  "unit_length",
17991
18021
  false
17992
18022
  ],
18023
+ [
18024
+ "forQuantity",
18025
+ "preposition",
18026
+ false
18027
+ ],
17993
18028
  [
17994
18029
  "forVariable",
17995
18030
  "preposition",
@@ -20736,6 +20771,11 @@
20736
20771
  "unit_length",
20737
20772
  false
20738
20773
  ],
20774
+ [
20775
+ "forQuantity",
20776
+ "preposition",
20777
+ false
20778
+ ],
20739
20779
  [
20740
20780
  "forVariable",
20741
20781
  "preposition",
@@ -23482,6 +23522,11 @@
23482
23522
  "unit_length",
23483
23523
  false
23484
23524
  ],
23525
+ [
23526
+ "forQuantity",
23527
+ "preposition",
23528
+ false
23529
+ ],
23485
23530
  [
23486
23531
  "forVariable",
23487
23532
  "preposition",
@@ -26228,6 +26273,11 @@
26228
26273
  "unit_length",
26229
26274
  false
26230
26275
  ],
26276
+ [
26277
+ "forQuantity",
26278
+ "preposition",
26279
+ false
26280
+ ],
26231
26281
  [
26232
26282
  "forVariable",
26233
26283
  "preposition",
@@ -28974,6 +29024,11 @@
28974
29024
  "unit_length",
28975
29025
  false
28976
29026
  ],
29027
+ [
29028
+ "forQuantity",
29029
+ "preposition",
29030
+ false
29031
+ ],
28977
29032
  [
28978
29033
  "forVariable",
28979
29034
  "preposition",
@@ -31720,6 +31775,11 @@
31720
31775
  "unit_length",
31721
31776
  false
31722
31777
  ],
31778
+ [
31779
+ "forQuantity",
31780
+ "preposition",
31781
+ false
31782
+ ],
31723
31783
  [
31724
31784
  "forVariable",
31725
31785
  "preposition",
@@ -34466,6 +34526,11 @@
34466
34526
  "unit_length",
34467
34527
  false
34468
34528
  ],
34529
+ [
34530
+ "forQuantity",
34531
+ "preposition",
34532
+ false
34533
+ ],
34469
34534
  [
34470
34535
  "forVariable",
34471
34536
  "preposition",
@@ -37212,6 +37277,11 @@
37212
37277
  "unit_length",
37213
37278
  false
37214
37279
  ],
37280
+ [
37281
+ "forQuantity",
37282
+ "preposition",
37283
+ false
37284
+ ],
37215
37285
  [
37216
37286
  "forVariable",
37217
37287
  "preposition",
@@ -39958,6 +40028,11 @@
39958
40028
  "unit_length",
39959
40029
  false
39960
40030
  ],
40031
+ [
40032
+ "forQuantity",
40033
+ "preposition",
40034
+ false
40035
+ ],
39961
40036
  [
39962
40037
  "forVariable",
39963
40038
  "preposition",
@@ -42704,6 +42779,11 @@
42704
42779
  "unit_length",
42705
42780
  false
42706
42781
  ],
42782
+ [
42783
+ "forQuantity",
42784
+ "preposition",
42785
+ false
42786
+ ],
42707
42787
  [
42708
42788
  "forVariable",
42709
42789
  "preposition",
@@ -45450,6 +45530,11 @@
45450
45530
  "unit_length",
45451
45531
  false
45452
45532
  ],
45533
+ [
45534
+ "forQuantity",
45535
+ "preposition",
45536
+ false
45537
+ ],
45453
45538
  [
45454
45539
  "forVariable",
45455
45540
  "preposition",
@@ -48573,6 +48658,11 @@
48573
48658
  "unit_length",
48574
48659
  false
48575
48660
  ],
48661
+ [
48662
+ "forQuantity",
48663
+ "preposition",
48664
+ false
48665
+ ],
48576
48666
  [
48577
48667
  "forVariable",
48578
48668
  "preposition",
@@ -51696,6 +51786,11 @@
51696
51786
  "unit_length",
51697
51787
  false
51698
51788
  ],
51789
+ [
51790
+ "forQuantity",
51791
+ "preposition",
51792
+ false
51793
+ ],
51699
51794
  [
51700
51795
  "forVariable",
51701
51796
  "preposition",
@@ -54819,6 +54914,11 @@
54819
54914
  "unit_length",
54820
54915
  false
54821
54916
  ],
54917
+ [
54918
+ "forQuantity",
54919
+ "preposition",
54920
+ false
54921
+ ],
54822
54922
  [
54823
54923
  "forVariable",
54824
54924
  "preposition",
@@ -57565,6 +57665,11 @@
57565
57665
  "unit_length",
57566
57666
  false
57567
57667
  ],
57668
+ [
57669
+ "forQuantity",
57670
+ "preposition",
57671
+ false
57672
+ ],
57568
57673
  [
57569
57674
  "forVariable",
57570
57675
  "preposition",
@@ -60555,6 +60660,11 @@
60555
60660
  "unit_length",
60556
60661
  false
60557
60662
  ],
60663
+ [
60664
+ "forQuantity",
60665
+ "preposition",
60666
+ false
60667
+ ],
60558
60668
  [
60559
60669
  "forVariable",
60560
60670
  "preposition",
@@ -63652,6 +63762,11 @@
63652
63762
  "unit_length",
63653
63763
  false
63654
63764
  ],
63765
+ [
63766
+ "forQuantity",
63767
+ "preposition",
63768
+ false
63769
+ ],
63655
63770
  [
63656
63771
  "forVariable",
63657
63772
  "preposition",
@@ -66398,6 +66513,11 @@
66398
66513
  "unit_length",
66399
66514
  false
66400
66515
  ],
66516
+ [
66517
+ "forQuantity",
66518
+ "preposition",
66519
+ false
66520
+ ],
66401
66521
  [
66402
66522
  "forVariable",
66403
66523
  "preposition",
@@ -69144,6 +69264,11 @@
69144
69264
  "unit_length",
69145
69265
  false
69146
69266
  ],
69267
+ [
69268
+ "forQuantity",
69269
+ "preposition",
69270
+ false
69271
+ ],
69147
69272
  [
69148
69273
  "forVariable",
69149
69274
  "preposition",
@@ -71890,6 +72015,11 @@
71890
72015
  "unit_length",
71891
72016
  false
71892
72017
  ],
72018
+ [
72019
+ "forQuantity",
72020
+ "preposition",
72021
+ false
72022
+ ],
71893
72023
  [
71894
72024
  "forVariable",
71895
72025
  "preposition",
@@ -74636,6 +74766,11 @@
74636
74766
  "unit_length",
74637
74767
  false
74638
74768
  ],
74769
+ [
74770
+ "forQuantity",
74771
+ "preposition",
74772
+ false
74773
+ ],
74639
74774
  [
74640
74775
  "forVariable",
74641
74776
  "preposition",
@@ -1,6 +1,7 @@
1
- const { knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
3
3
  const helpers = require('./helpers')
4
+ const englishHelpers = require('./english_helpers')
4
5
  const stm = require('./stm')
5
6
  const nameable_tests = require('./nameable.test.json')
6
7
 
@@ -14,18 +15,20 @@ class API {
14
15
 
15
16
  // report is a context
16
17
  setName(context, name) {
17
- context.stm ??= {}
18
- context.stm.names ??= []
19
- context.stm.names.push(name)
18
+ context.namespaced ??= {}
19
+ context.namespaced.nameable ??= {}
20
+ context.namespaced.nameable.names ??= []
21
+ context.namespaced.nameable.names.push(name)
20
22
  this.args.config.addWord(name, { id: context.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
21
23
  }
22
24
 
25
+ // used by mongo km
23
26
  get(type, name) {
24
27
  return this.args.kms.stm.api.mentions({
25
28
  context: type,
26
29
  condition: (context) => {
27
- if (context.stm && context.stm.names) {
28
- return context.stm.names.includes(name)
30
+ if (context.namespaced?.nameable && context.namespaced.nameable.names) {
31
+ return context.namespaced.nameable.names.includes(name)
29
32
  }
30
33
  }
31
34
  })
@@ -35,8 +38,8 @@ class API {
35
38
  const contexts = this.args.kms.stm.api.getByType(type)
36
39
  const names = new Set()
37
40
  for (const context of contexts) {
38
- if (context.stm.names) {
39
- for (const name of context.stm.names) {
41
+ if (context.namespaced?.nameable?.names) {
42
+ for (const name of context.namespaced.nameable.names) {
40
43
  names.add(name)
41
44
  }
42
45
  }
@@ -45,20 +48,9 @@ class API {
45
48
  }
46
49
 
47
50
  getNames(nameable) {
48
- return (nameable.stm && nameable.stm.names) || []
51
+ return (nameable.namespaced?.nameable && nameable.namespaced.nameable.names) || []
49
52
  }
50
53
 
51
- /*
52
- getNames() {
53
- const current = this.current()
54
- console.log('getReportNames current', JSON.stringify(current, null, 2))
55
- return Object.keys(this.objects.namedReports).map( (name) => {
56
- const selected = (current.names || []).includes(name)
57
- return { name, selected, id: name }
58
- })
59
- }
60
- */
61
-
62
54
  setCurrent(name) {
63
55
  const context = this.objects.named[name]
64
56
  if (context) {
@@ -83,7 +75,8 @@ const config = {
83
75
  name: 'nameable',
84
76
  operators: [
85
77
  // "([call] ([nameable]) (name))",
86
- "([call] ([nameable]) (!@<=endOfSentence)*)",
78
+ "([call|] ([nameable]) (!@<=endOfSentence)*)",
79
+ "((nameable) [isCalled|is] (call) (!@<=endOfSentence)*)",
87
80
  { pattern: "([getNamesByType] (type))", scope: "testing" },
88
81
  { pattern: "([m1])", scope: "testing" },
89
82
  ],
@@ -103,11 +96,33 @@ const config = {
103
96
  context.isResponse = true
104
97
  }
105
98
  },
99
+ {
100
+ id: 'isCalled',
101
+ before: ['verb'],
102
+ bridge: [
103
+ { "apply": true, "bridge": "{ ...after[0], isCalled: operator }", "set": "operator" },
104
+ {
105
+ "rewire": [
106
+ { "from": 'before[0]', "to": 'after[0]' },
107
+ { "from": 'after[1]', "to": 'after[1]' },
108
+ ]
109
+ },
110
+ { "apply": true, "operator": "operator", "set": "context" },
111
+ { "apply": true, bridge: "{ ...context, interpolate: [{ property: 'nameable' }, { property: 'isCalled' }, { property: 'operator' }, { property: 'name' }] }" },
112
+ ],
113
+ },
106
114
  {
107
115
  id: 'call',
108
116
  isA: ['verb'],
109
- bridge: "{ ...next(operator), nameable: after[0], name: after[1:][0] }",
110
- generatorp: async ({context, g, gs}) => `call ${await g(context.nameable)} ${await gs(context.name)}`,
117
+ words: englishHelpers.conjugateVerb('call'),
118
+ bridge: `{
119
+ ...next(operator),
120
+ nameable: after[0],
121
+ name: after[1:][0],
122
+ operator: operator,
123
+ interpolate: [ { property: 'operator' }, { property: 'nameable' }, { property: 'name' } ] }
124
+ `,
125
+ // generatorp: async ({context, g, gs}) => `call ${await g(context.nameable)} ${await gs(context.name)}`,
111
126
  semantic: async ({config, context, api, e, verbatim, g}) => {
112
127
  // TODO find report being referred to
113
128
  // debugger
@@ -133,7 +148,31 @@ const config = {
133
148
  { context: [['call', 0], ['that', 0]], choose: 0 },
134
149
  ],
135
150
  },
136
-
151
+ generators: [
152
+ {
153
+ where: where(),
154
+ match: ({context}) => context.namespaced?.nameable?.names,
155
+ apply: ({context}) => context.namespaced.nameable.names[0],
156
+ }
157
+ ],
158
+ semantics: [
159
+ {
160
+ where: where(),
161
+ match: ({context}) => context.marker == 'mentions' && context.evaluate && context.args.context.nameable_named,
162
+ apply: async ({callId, _continue, toList, context, kms, e, log, retry}) => {
163
+ context.args.condition ??= () => true
164
+ const oldCondition = context.args.condition
165
+ const name = context.args.context.value
166
+ context.args.condition = (context) => {
167
+ if (!context.namespaced?.nameable?.names?.includes(name)) {
168
+ return
169
+ }
170
+ return oldCondition(context)
171
+ }
172
+ _continue()
173
+ }
174
+ },
175
+ ],
137
176
  }
138
177
 
139
178
  knowledgeModule( {