tpmkms 9.8.0 → 9.9.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 (95) hide show
  1. package/common/actions.instance.json +10 -8
  2. package/common/actions.js +13 -11
  3. package/common/angle.instance.json +25 -17
  4. package/common/animals.instance.json +54 -28
  5. package/common/askfor.instance.json +89 -192
  6. package/common/askfor.js +49 -12
  7. package/common/asking.js +13 -5
  8. package/common/avatar.js +3 -3
  9. package/common/can.instance.json +32 -20
  10. package/common/can.js +2 -2
  11. package/common/colors.instance.json +44 -16
  12. package/common/colors.js +1 -1
  13. package/common/comparable.instance.json +25 -22
  14. package/common/compass.instance.json +9 -3
  15. package/common/concept.instance.json +14 -6
  16. package/common/concept.js +2 -0
  17. package/common/conjunction.js +17 -9
  18. package/common/control.js +10 -18
  19. package/common/countable.js +4 -3
  20. package/common/crew.instance.json +95 -27
  21. package/common/dateTimeSelectors.instance.json +4 -4
  22. package/common/dateTimeSelectors.js +4 -7
  23. package/common/dates.instance.json +52 -28
  24. package/common/dates.js +16 -11
  25. package/common/debug.instance.json +48 -0
  26. package/common/debug.js +50 -0
  27. package/common/debug.test.json +1 -0
  28. package/common/dialogues.js +126 -70
  29. package/common/dimension.instance.json +239 -495
  30. package/common/dimension.js +51 -9
  31. package/common/drone.instance.json +395 -84
  32. package/common/drone.js +43 -50
  33. package/common/drone_v1.instance.json +36 -12
  34. package/common/drone_v1.js +14 -9
  35. package/common/edible.instance.json +96 -32
  36. package/common/emotions.instance.json +15 -1
  37. package/common/evaluate.js +10 -13
  38. package/common/fastfood.instance.json +282 -100
  39. package/common/fastfood.js +30 -15
  40. package/common/formulas.instance.json +162 -24
  41. package/common/formulas.js +18 -9
  42. package/common/gdefaults.js +20 -96
  43. package/common/helpers/concept.js +2 -9
  44. package/common/helpers/conjunction.js +11 -1
  45. package/common/helpers/dialogues.js +48 -24
  46. package/common/helpers/gdefaults.js +15 -5
  47. package/common/helpers/properties.js +125 -326
  48. package/common/helpers.js +28 -58
  49. package/common/hierarchy.js +71 -41
  50. package/common/kirk.instance.json +3 -1
  51. package/common/latin.instance.json +10 -10
  52. package/common/latin.js +5 -5
  53. package/common/length.instance.json +247 -61
  54. package/common/math.instance.json +144 -5
  55. package/common/math.js +18 -5
  56. package/common/menus.instance.json +29 -11
  57. package/common/menus.js +8 -5
  58. package/common/meta.js +14 -13
  59. package/common/nameable.js +9 -5
  60. package/common/numbers.instance.json +5 -3
  61. package/common/numbers.js +28 -28
  62. package/common/ordering.instance.json +53 -4
  63. package/common/ordinals.js +25 -25
  64. package/common/people.instance.json +66 -12
  65. package/common/percentages.js +4 -2
  66. package/common/pipboy.instance.json +89 -44
  67. package/common/pipboy.js +21 -14
  68. package/common/pokemon.instance.json +39 -13
  69. package/common/pressure.instance.json +14 -6
  70. package/common/properties.instance.json +2370 -511
  71. package/common/properties.js +496 -78
  72. package/common/punctuation.js +1 -0
  73. package/common/rates.instance.json +2 -2
  74. package/common/rates.js +3 -3
  75. package/common/reminders.instance.json +16 -0
  76. package/common/reminders.js +24 -20
  77. package/common/reports.instance.json +11 -12
  78. package/common/reports.js +12 -12
  79. package/common/scorekeeper.js +20 -10
  80. package/common/sdefaults.js +30 -9
  81. package/common/spock.instance.json +3 -1
  82. package/common/stm.js +16 -21
  83. package/common/temperature.instance.json +19 -11
  84. package/common/testing.js +2 -2
  85. package/common/time.instance.json +104 -47
  86. package/common/time.js +9 -8
  87. package/common/ui.instance.json +4 -2
  88. package/common/ui.js +5 -5
  89. package/common/weight.instance.json +86 -21
  90. package/common/weight.js +5 -1
  91. package/common/words.js +113 -2
  92. package/common/wp.instance.json +125 -18
  93. package/common/wp.js +6 -2
  94. package/main.js +2 -0
  95. package/package.json +7 -3
@@ -11,15 +11,38 @@
11
11
  {
12
12
  "operators": [
13
13
  "([askfor_askfor|] ([for_askfor|] (@<= concept)))",
14
- "([information])"
14
+ "([information])",
15
+ "(([known]) [knownAbout|about] (*))"
16
+ ],
17
+ "generators": [
18
+ {
19
+ "match": "({context}) => context.marker == 'is' && context.one.marker == 'known'",
20
+ "apply": "async ({context, g}) => {\n return await g(context.two)\n }"
21
+ }
15
22
  ],
16
23
  "bridges": [
24
+ {
25
+ "id": "knownAbout",
26
+ "isA": [
27
+ "preposition"
28
+ ],
29
+ "bridge": "{\n ...before[0],\n subjects: append(after[0].subjects, after),\n known: before[0],\n about: operator,\n interpolate: '${known} ${about} ${subjects}'\n }"
30
+ },
31
+ {
32
+ "id": "known",
33
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:77",
34
+ "isA": [
35
+ "queryable"
36
+ ],
37
+ "semantic": "async ({kms, context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {\n const known = await kms.properties.api.getProperty(context.subjects[0], 'property')\n resolveEvaluate(context, known)\n }"
38
+ },
17
39
  {
18
40
  "id": "information",
41
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:86",
19
42
  "isA": [
20
43
  "noun"
21
44
  ],
22
- "evaluator": "async ({context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {\n const properties = objects.askFor\n const values = []\n for (const property of properties) {\n // const value = toEValue(await e(property))\n const value = (await e(property)).evalue\n values.push({ marker: 'labelledValue', label: property, value })\n }\n resolveEvaluate(context, toList(values))\n }"
45
+ "semantic": "async ({context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {\n const properties = objects.askFor\n const values = []\n for (const property of properties) {\n try {\n const value = (await e(property, where())).evalue\n values.push({ marker: 'labelledValue', label: property, value })\n } catch( e ) {\n }\n }\n resolveEvaluate(context, toList(values))\n }"
23
46
  },
24
47
  {
25
48
  "id": "for_askfor",
@@ -36,6 +59,7 @@
36
59
  },
37
60
  {
38
61
  "id": "askfor_askfor",
62
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:114",
39
63
  "isA": [
40
64
  "verb"
41
65
  ],
@@ -43,7 +67,7 @@
43
67
  "ask"
44
68
  ],
45
69
  "bridge": "{\n ...next(operator),\n properties: after[0],\n interpolate: [{ self: true }, { property: 'properties' }]\n }",
46
- "semantic": "async ({e, s, gp, objects, flatten, context, ask, fragments, toEValue}) => {\n const argument = context.properties.argument\n const getValue = (property) => async (args) => {\n const value = toEValue(await e(property))\n if (value.marker == 'answerNotKnown') {\n return\n }\n return value\n }\n\n const setValue = (property) => async ({ context, namespaced, tag }) => {\n const is = { marker: 'is', one: property, two: context }\n namespaced.set('dialogs', is, 'allowHierarchy', false)\n await s(is)\n }\n\n const properties = flattenInPlace(argument)\n counter = 0\n for (const property of properties.reverse()) {\n counter += 1\n const query = memoizeAsync(async () => await(gp(await fragments(\"what is the concept?\", { concept: property }))))\n const compatible_types = property.compatible_types || [property.marker]\n const matchr = ({context, isA}) => {\n return !context.same && !context.evaluate && isA(context, compatible_types)\n }\n objects.askFor.push(property);\n askForProperty({\n ask,\n tag: `ask#${counter}`,\n getValue: getValue(property),\n setValue: setValue(property),\n query,\n matchr,\n })\n }\n }"
70
+ "semantic": "async ({e, gp, objects, flatten, context, ask, fragments, toEValue}) => {\n const argument = context.properties.argument\n const getValue = (property) => async (args) => {\n try {\n const value = toEValue(await e(property, where()))\n if (value.marker === 'undefined') {\n return\n }\n return value\n } catch (e) {\n }\n }\n\n const setValue = (property) => async ({ context, namespaced, tag }) => {\n const is = { marker: 'is', one: property, two: context }\n namespaced.set('dialogs', is, 'allowHierarchy', false)\n await e(is, where())\n }\n\n const properties = flattenInPlace(argument)\n counter = 0\n for (const property of properties.reverse()) {\n counter += 1\n const query = memoizeAsync(async () => await(gp(await fragments(\"what is the concept?\", { concept: property }))))\n const compatible_types = property.compatible_types || [property.marker]\n const matchr = ({context, isA}) => {\n return !context.same && isA(context, compatible_types)\n }\n objects.askFor.push(property);\n askForProperty({\n ask,\n tag: `ask#${counter}`,\n getValue: getValue(property),\n setValue: setValue(property),\n query,\n matchr,\n })\n }\n }"
47
71
  }
48
72
  ]
49
73
  },
@@ -114,7 +138,6 @@
114
138
  "level": 1,
115
139
  "context_index": 1,
116
140
  "topLevel": true,
117
- "context_id": 2,
118
141
  "touchedBy": [
119
142
  "askfor#call2"
120
143
  ]
@@ -205,6 +228,9 @@
205
228
  }
206
229
  ],
207
230
  "learned_contextual_priorities": [],
231
+ "explain_associations_details": [
232
+ null
233
+ ],
208
234
  "query": "setidsuffix _askfor",
209
235
  "key": {
210
236
  "query": "setidsuffix _askfor"
@@ -338,6 +364,7 @@
338
364
  "what"
339
365
  ],
340
366
  "determined": true,
367
+ "isVariable": true,
341
368
  "types": [
342
369
  "what"
343
370
  ],
@@ -416,190 +443,11 @@
416
443
  ],
417
444
  "level": 2,
418
445
  "context_index": 1,
419
- "topLevel": true,
420
- "context_id": 2,
421
- "evalue": {
422
- "default": true,
423
- "marker": "is",
424
- "one": {
425
- "marker": "concept",
426
- "value": "concept",
427
- "default": true,
428
- "text": "the concept",
429
- "dead": true,
430
- "word": "concept",
431
- "range": {
432
- "start": 8,
433
- "end": 18
434
- },
435
- "types": [
436
- "concept"
437
- ],
438
- "focusableForPhrase": true,
439
- "pullFromContext": true,
440
- "concept": true,
441
- "wantsValue": true,
442
- "checks": [
443
- "determiner"
444
- ],
445
- "determiner": {
446
- "modifiers": [],
447
- "text": "the",
448
- "marker": "the",
449
- "word": "the",
450
- "range": {
451
- "start": 8,
452
- "end": 10
453
- },
454
- "level": 0
455
- },
456
- "theable": {
457
- "marker": "concept",
458
- "value": "concept",
459
- "default": true,
460
- "text": "concept",
461
- "dead": true,
462
- "word": "concept",
463
- "range": {
464
- "start": 12,
465
- "end": 18
466
- },
467
- "types": [
468
- "concept"
469
- ],
470
- "level": 0
471
- },
472
- "flattenInPlace": [
473
- [
474
- "value",
475
- "theable"
476
- ]
477
- ],
478
- "flatten_ignore": [
479
- "theable"
480
- ],
481
- "interpolate": [
482
- {
483
- "property": "determiner"
484
- },
485
- {
486
- "property": "theable"
487
- }
488
- ],
489
- "level": 0
490
- },
491
- "two": {
492
- "marker": "concept",
493
- "value": {
494
- "marker": "surname",
495
- "isVariable": true,
496
- "evaluate": false,
497
- "pullFromContext": false,
498
- "value": "last_name",
499
- "fromSTM": true,
500
- "namespaced": {
501
- "stm": {
502
- "id": 1
503
- }
504
- }
505
- },
506
- "default": true,
507
- "text": "the concept",
508
- "dead": true,
509
- "word": "concept",
510
- "range": {
511
- "start": 8,
512
- "end": 18
513
- },
514
- "types": [
515
- "concept"
516
- ],
517
- "focusableForPhrase": true,
518
- "pullFromContext": true,
519
- "concept": true,
520
- "wantsValue": true,
521
- "checks": [
522
- "determiner"
523
- ],
524
- "determiner": {
525
- "modifiers": [],
526
- "text": "the",
527
- "marker": "the",
528
- "word": "the",
529
- "range": {
530
- "start": 8,
531
- "end": 10
532
- },
533
- "level": 0
534
- },
535
- "theable": {
536
- "marker": "concept",
537
- "value": "concept",
538
- "default": true,
539
- "text": "concept",
540
- "dead": true,
541
- "word": "concept",
542
- "range": {
543
- "start": 12,
544
- "end": 18
545
- },
546
- "types": [
547
- "concept"
548
- ],
549
- "level": 0
550
- },
551
- "flattenInPlace": [
552
- [
553
- "value",
554
- "theable"
555
- ]
556
- ],
557
- "flatten_ignore": [
558
- "theable"
559
- ],
560
- "interpolate": [
561
- {
562
- "property": "determiner"
563
- },
564
- {
565
- "property": "theable"
566
- }
567
- ],
568
- "level": 0,
569
- "evalue": {
570
- "marker": "surname",
571
- "isVariable": true,
572
- "evaluate": false,
573
- "pullFromContext": false,
574
- "value": "last_name",
575
- "fromSTM": true,
576
- "namespaced": {
577
- "stm": {
578
- "id": 1
579
- }
580
- }
581
- },
582
- "touchedBy": [
583
- "askfor#call3",
584
- "askfor#call2"
585
- ],
586
- "instance": true,
587
- "focus": true
588
- },
589
- "focusable": [
590
- "two",
591
- "one"
592
- ],
593
- "word": "is"
594
- },
595
- "isResponse": true,
596
- "touchedBy": [
597
- "askfor#call2"
598
- ]
446
+ "topLevel": true
599
447
  }
600
448
  ],
601
449
  "generated": [
602
- "the concept is last_name"
450
+ ""
603
451
  ],
604
452
  "paraphrases": [
605
453
  "what is the concept?"
@@ -607,7 +455,7 @@
607
455
  "paraphrasesParenthesized": [],
608
456
  "generatedParenthesized": [],
609
457
  "responses": [
610
- "the concept is last_name"
458
+ ""
611
459
  ],
612
460
  "associations": [],
613
461
  "summaries": [
@@ -838,6 +686,9 @@
838
686
  }
839
687
  ],
840
688
  "learned_contextual_priorities": [],
689
+ "explain_associations_details": [
690
+ null
691
+ ],
841
692
  "query": "what is the concept?",
842
693
  "isFragment": true,
843
694
  "key": {
@@ -851,11 +702,30 @@
851
702
  "extraConfig": true,
852
703
  "operators": [
853
704
  "([askfor_askfor|] ([for_askfor|] (@<= concept)))",
854
- "([information])"
705
+ "([information])",
706
+ "(([known]) [knownAbout|about] (*))"
707
+ ],
708
+ "generators": [
709
+ {}
855
710
  ],
856
711
  "bridges": [
712
+ {
713
+ "id": "knownAbout",
714
+ "isA": [
715
+ "preposition"
716
+ ],
717
+ "bridge": "{\n ...before[0],\n subjects: append(after[0].subjects, after),\n known: before[0],\n about: operator,\n interpolate: '${known} ${about} ${subjects}'\n }"
718
+ },
719
+ {
720
+ "id": "known",
721
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:77",
722
+ "isA": [
723
+ "queryable"
724
+ ]
725
+ },
857
726
  {
858
727
  "id": "information",
728
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:86",
859
729
  "isA": [
860
730
  "noun"
861
731
  ]
@@ -875,6 +745,7 @@
875
745
  },
876
746
  {
877
747
  "id": "askfor_askfor",
748
+ "where": "/home/dev/code/theprogrammablemind/kms/common/askfor.js:114",
878
749
  "isA": [
879
750
  "verb"
880
751
  ],
@@ -906,7 +777,6 @@
906
777
  "level": 0,
907
778
  "context_index": 1,
908
779
  "topLevel": true,
909
- "context_id": 2,
910
780
  "touchedBy": [
911
781
  "askfor#call2"
912
782
  ]
@@ -947,6 +817,9 @@
947
817
  }
948
818
  ],
949
819
  "learned_contextual_priorities": [],
820
+ "explain_associations_details": [
821
+ null
822
+ ],
950
823
  "query": "resetIdSuffix",
951
824
  "key": {
952
825
  "query": "resetIdSuffix"
@@ -1119,6 +992,22 @@
1119
992
  "types": [
1120
993
  "ownee"
1121
994
  ],
995
+ "isEdProperties": [
996
+ "ownee",
997
+ "owner"
998
+ ],
999
+ "relationBacked": true,
1000
+ "orderingArgs": null,
1001
+ "relationArgs": [
1002
+ {
1003
+ "tag": "owner",
1004
+ "id": "owner"
1005
+ },
1006
+ {
1007
+ "tag": "ownee",
1008
+ "id": "ownee"
1009
+ }
1010
+ ],
1122
1011
  "constraints": [
1123
1012
  {
1124
1013
  "property": "ownee",
@@ -1154,6 +1043,8 @@
1154
1043
  },
1155
1044
  "dead": true,
1156
1045
  "constrained": true,
1046
+ "beforeTag": "owner",
1047
+ "afterTag": "ownee",
1157
1048
  "owner": {
1158
1049
  "marker": "unknown",
1159
1050
  "implicit": true,
@@ -1189,8 +1080,7 @@
1189
1080
  "dead": true,
1190
1081
  "level": 2,
1191
1082
  "context_index": 1,
1192
- "topLevel": true,
1193
- "context_id": 2
1083
+ "topLevel": true
1194
1084
  }
1195
1085
  ],
1196
1086
  "generated": [
@@ -1498,6 +1388,9 @@
1498
1388
  }
1499
1389
  ],
1500
1390
  "learned_contextual_priorities": [],
1391
+ "explain_associations_details": [
1392
+ null
1393
+ ],
1501
1394
  "query": "ownervar is owneevar owned by",
1502
1395
  "skipSemantics": true,
1503
1396
  "key": {
@@ -1646,6 +1539,8 @@
1646
1539
  "dead": true,
1647
1540
  "isEd": true,
1648
1541
  "subject": "ownee",
1542
+ "beforeTag": "owner",
1543
+ "afterTag": "ownee",
1649
1544
  "ownee": {
1650
1545
  "operator": {
1651
1546
  "marker": "owned",
@@ -1706,8 +1601,7 @@
1706
1601
  },
1707
1602
  "level": 1,
1708
1603
  "context_index": 1,
1709
- "topLevel": true,
1710
- "context_id": 2
1604
+ "topLevel": true
1711
1605
  }
1712
1606
  ],
1713
1607
  "generated": [
@@ -2015,6 +1909,9 @@
2015
1909
  }
2016
1910
  ],
2017
1911
  "learned_contextual_priorities": [],
1912
+ "explain_associations_details": [
1913
+ null
1914
+ ],
2018
1915
  "query": "owneevar is owned by ownervar",
2019
1916
  "skipSemantics": true,
2020
1917
  "key": {
package/common/askfor.js CHANGED
@@ -4,6 +4,7 @@ const { flattenInPlace } = require('./helpers/flatten_in_place')
4
4
  const tests = require('./askfor.test.json')
5
5
  const instance = require('./askfor.instance.json')
6
6
  const length = require('./length')
7
+ const time = require('./time')
7
8
  const dates = require('./dates')
8
9
  const people = require('./people')
9
10
 
@@ -49,18 +50,50 @@ const template = {
49
50
  operators: [
50
51
  "([askfor_askfor|] ([for_askfor|] (@<= concept)))",
51
52
  "([information])",
53
+ "(([known]) [knownAbout|about] (*))",
54
+ ],
55
+ generators: [
56
+ {
57
+ match: ({context}) => context.marker == 'is' && context.one.marker == 'known',
58
+ apply: async ({context, g}) => {
59
+ return await g(context.two)
60
+ }
61
+ },
52
62
  ],
53
63
  bridges: [
64
+ {
65
+ id: 'knownAbout',
66
+ isA: ['preposition'],
67
+ bridge: `{
68
+ ...before[0],
69
+ subjects: append(after[0].subjects, after),
70
+ known: before[0],
71
+ about: operator,
72
+ interpolate: '\${known} \${about} \${subjects}'
73
+ }`,
74
+ },
75
+ {
76
+ id: 'known',
77
+ where: where(),
78
+ isA: ['queryable'],
79
+ semantic: async ({kms, context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {
80
+ const known = await kms.properties.api.getProperty(context.subjects[0], 'property')
81
+ resolveEvaluate(context, known)
82
+ },
83
+ },
54
84
  {
55
85
  id: 'information',
86
+ where: where(),
56
87
  isA: ['noun'],
57
- evaluator: async ({context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {
88
+ semantic: async ({context, e, callId, toList, flatten, toEValue, resolveEvaluate, objects}) => {
58
89
  const properties = objects.askFor
59
90
  const values = []
60
91
  for (const property of properties) {
61
- // const value = toEValue(await e(property))
62
- const value = (await e(property)).evalue
63
- values.push({ marker: 'labelledValue', label: property, value })
92
+ try {
93
+ const value = (await e(property, where())).evalue
94
+ values.push({ marker: 'labelledValue', label: property, value })
95
+ } catch( e ) {
96
+ }
64
97
  }
65
98
  resolveEvaluate(context, toList(values))
66
99
  },
@@ -78,6 +111,7 @@ const template = {
78
111
  },
79
112
  {
80
113
  id: 'askfor_askfor',
114
+ where: where(),
81
115
  isA: ['verb'],
82
116
  words: ['ask'],
83
117
  bridge: `{
@@ -85,20 +119,23 @@ const template = {
85
119
  properties: after[0],
86
120
  interpolate: [{ self: true }, { property: 'properties' }]
87
121
  }`,
88
- semantic: async ({e, s, gp, objects, flatten, context, ask, fragments, toEValue}) => {
122
+ semantic: async ({e, gp, objects, flatten, context, ask, fragments, toEValue}) => {
89
123
  const argument = context.properties.argument
90
124
  const getValue = (property) => async (args) => {
91
- const value = toEValue(await e(property))
92
- if (value.marker == 'answerNotKnown') {
93
- return
125
+ try {
126
+ const value = toEValue(await e(property, where()))
127
+ if (value.marker === 'undefined') {
128
+ return
129
+ }
130
+ return value
131
+ } catch (e) {
94
132
  }
95
- return value
96
133
  }
97
134
 
98
135
  const setValue = (property) => async ({ context, namespaced, tag }) => {
99
136
  const is = { marker: 'is', one: property, two: context }
100
137
  namespaced.set('dialogs', is, 'allowHierarchy', false)
101
- await s(is)
138
+ await e(is, where())
102
139
  }
103
140
 
104
141
  const properties = flattenInPlace(argument)
@@ -108,7 +145,7 @@ const template = {
108
145
  const query = memoizeAsync(async () => await(gp(await fragments("what is the concept?", { concept: property }))))
109
146
  const compatible_types = property.compatible_types || [property.marker]
110
147
  const matchr = ({context, isA}) => {
111
- return !context.same && !context.evaluate && isA(context, compatible_types)
148
+ return !context.same && isA(context, compatible_types)
112
149
  }
113
150
  objects.askFor.push(property);
114
151
  askForProperty({
@@ -130,7 +167,7 @@ const template = {
130
167
 
131
168
  knowledgeModule( {
132
169
  config: { name: 'askfor' },
133
- includes: [length, dates, people],
170
+ includes: [time, length, dates, people],
134
171
 
135
172
  module,
136
173
  description: 'asking the system to interact with a user and find out information',
package/common/asking.js CHANGED
@@ -26,6 +26,7 @@ const config = {
26
26
  bridges: [
27
27
  {
28
28
  id: "nevermind",
29
+ where: where(),
29
30
  bridge: "{ ...next(operator), complete: true }",
30
31
  semantic: (args) => {
31
32
  const {config, context} = args
@@ -51,6 +52,7 @@ const config = {
51
52
 
52
53
  {
53
54
  id: "whichOnesTestSetup",
55
+ where: where(),
54
56
  scope: "testing",
55
57
  generatorp: async ({context, gs}) => `${context.marker} ${await gs(context.choices)}`,
56
58
  bridge: "{ ...next(operator), choices: after[0] }",
@@ -91,6 +93,7 @@ const config = {
91
93
 
92
94
  {
93
95
  id: "nevermindTestSetup",
96
+ where: where(),
94
97
  scope: "testing",
95
98
  bridge: "{ ...next(operator), type: after[0], postModifiers: ['type'] }",
96
99
  semantic: ({ask, context}) => {
@@ -139,7 +142,10 @@ function getAsk(config) {
139
142
 
140
143
  const semanticsr = ask.semanticsr || []
141
144
  if (semanticsr.length == 0) {
142
- semanticsr.push({ match: ask.matchr, apply: ask.applyr })
145
+ semanticsr.push({
146
+ match: (args) => args.callOnce(args, 'asking.matchr', ask.matchr),
147
+ apply: ask.applyr
148
+ })
143
149
  }
144
150
 
145
151
  for (const semantic of semanticsr) {
@@ -156,7 +162,9 @@ function getAsk(config) {
156
162
  oneShot: ask.oneShot ?? true,
157
163
  where: semantic.where || ask.where || where(2),
158
164
  source: 'response',
159
- match: (args) => !args.context.isResponse && !args.context.evaluate && !args.context.isControl && semantic.match(args),
165
+ match: async (args) => await args.callOnce(args, 'asking.1', async (args) => {
166
+ return !args.context.isResponse && args.context.topLevel && !args.context.isControl && await semantic.match(args)
167
+ }),
160
168
  apply: async (args) => {
161
169
  setWasApplied(true)
162
170
  await semantic.apply({ ...args, tag: ask.tag })
@@ -187,13 +195,13 @@ function getAsk(config) {
187
195
  matchq = () => !wasAsked,
188
196
  applyq = (args) => {
189
197
  wasAsked = true
190
- return ask.applyq({ ...args, tag: ask.tag })
198
+ return args.stack.wrap(() => ask.applyq({ ...args, tag: ask.tag }), where())
191
199
  }
192
200
  }
193
- if (await matchq(args)) {
201
+ if (await args.stack.wrap(() => matchq(args), where())) {
194
202
  setWasApplied(false)
195
203
  // args.context.motivationKeep = true
196
- const query = await applyq({ ...args, wasAsked: getWasAsked() })
204
+ const query = await args.stack.wrap(() => applyq({ ...args, wasAsked: getWasAsked() }), where())
197
205
  if (typeof query != 'string') {
198
206
  throw new Error(`ask expects the value return from applyq to be a string. ${ask.where}. Instead got ${JSON.stringify(query, null, 2)}.`)
199
207
  }
package/common/avatar.js CHANGED
@@ -27,7 +27,7 @@ const config = {
27
27
  {
28
28
  where: where(),
29
29
  notes: "unknown answer default response for avatar",
30
- match: ({context}) => context.marker == 'answerNotKnown',
30
+ match: ({context}) => context.marker === 'undefined',
31
31
  apply: ({context}) => `I don't know`,
32
32
  },
33
33
  {
@@ -50,9 +50,9 @@ const config = {
50
50
  {
51
51
  notes: 'you are x',
52
52
  where: where(),
53
- match: ({context, listable}) => context.marker == 'self',
53
+ match: ({context, listable}) => context.marker == 'same' && context.one.marker == 'self',
54
54
  apply: ({context, km}) => {
55
- km("stm").api.setVariable('self', context.same.value)
55
+ km("stm").api.setVariable('self', context.two.value)
56
56
  context.sameWasProcessed = true
57
57
  }
58
58
  },