@siduri-x/core 1.0.5 → 1.0.8

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 (85) hide show
  1. package/dist/action-executor.d.ts +12 -0
  2. package/dist/action-executor.js +50 -0
  3. package/dist/action-policy.d.ts +45 -0
  4. package/dist/action-policy.js +219 -0
  5. package/dist/action-policy.test.d.ts +1 -0
  6. package/dist/action-policy.test.js +193 -0
  7. package/dist/action.d.ts +72 -0
  8. package/dist/action.js +2 -0
  9. package/dist/adversarial.test.d.ts +1 -0
  10. package/dist/adversarial.test.js +489 -0
  11. package/dist/architecture-boundary.test.d.ts +1 -0
  12. package/dist/architecture-boundary.test.js +117 -0
  13. package/dist/capability.d.ts +65 -0
  14. package/dist/capability.js +157 -0
  15. package/dist/capability.test.d.ts +1 -0
  16. package/dist/capability.test.js +268 -0
  17. package/dist/chat-contract.d.ts +81 -0
  18. package/dist/chat-contract.js +68 -0
  19. package/dist/cognition-planner.d.ts +15 -0
  20. package/dist/cognition-planner.js +23 -0
  21. package/dist/context-retriever.d.ts +24 -0
  22. package/dist/context-retriever.js +90 -0
  23. package/dist/context.d.ts +44 -0
  24. package/dist/context.js +72 -0
  25. package/dist/context.test.d.ts +1 -0
  26. package/dist/context.test.js +76 -0
  27. package/dist/dispatcher.d.ts +14 -0
  28. package/dist/dispatcher.js +40 -0
  29. package/dist/dispatcher.test.d.ts +1 -0
  30. package/dist/dispatcher.test.js +58 -0
  31. package/dist/ear-types.d.ts +33 -0
  32. package/dist/ear-types.js +2 -0
  33. package/dist/evidence.d.ts +73 -0
  34. package/dist/evidence.js +27 -0
  35. package/dist/evidence.test.d.ts +1 -0
  36. package/dist/evidence.test.js +75 -0
  37. package/dist/experience-emitter.d.ts +21 -0
  38. package/dist/experience-emitter.js +47 -0
  39. package/dist/experience.d.ts +55 -0
  40. package/dist/experience.js +74 -0
  41. package/dist/experience.test.d.ts +1 -0
  42. package/dist/experience.test.js +55 -0
  43. package/dist/gating.d.ts +45 -0
  44. package/dist/gating.js +183 -0
  45. package/dist/gating.test.d.ts +1 -0
  46. package/dist/gating.test.js +186 -0
  47. package/dist/index.d.ts +250 -0
  48. package/dist/index.js +43 -0
  49. package/dist/input-normalizer.d.ts +14 -0
  50. package/dist/input-normalizer.js +58 -0
  51. package/dist/input-normalizer.test.d.ts +1 -0
  52. package/dist/input-normalizer.test.js +39 -0
  53. package/dist/intent-classifier.d.ts +24 -0
  54. package/dist/intent-classifier.js +53 -0
  55. package/dist/intent-classifier.test.d.ts +1 -0
  56. package/dist/intent-classifier.test.js +67 -0
  57. package/dist/memory-settler.d.ts +27 -0
  58. package/dist/memory-settler.js +92 -0
  59. package/dist/mouth-types.d.ts +85 -0
  60. package/dist/mouth-types.js +2 -0
  61. package/dist/perception-cycle.test.d.ts +1 -0
  62. package/dist/perception-cycle.test.js +153 -0
  63. package/dist/prompt-compiler.d.ts +20 -0
  64. package/dist/prompt-compiler.js +54 -0
  65. package/dist/prompt-compiler.test.d.ts +1 -0
  66. package/dist/prompt-compiler.test.js +75 -0
  67. package/dist/proposals.d.ts +29 -0
  68. package/dist/proposals.js +2 -0
  69. package/dist/response-envelope.d.ts +25 -0
  70. package/dist/response-envelope.js +64 -0
  71. package/dist/runtime-facades.test.d.ts +1 -0
  72. package/dist/runtime-facades.test.js +69 -0
  73. package/dist/runtime.d.ts +114 -0
  74. package/dist/runtime.js +412 -0
  75. package/dist/session-history.d.ts +20 -0
  76. package/dist/session-history.js +55 -0
  77. package/dist/session-history.test.d.ts +1 -0
  78. package/dist/session-history.test.js +38 -0
  79. package/dist/sqlite-action-store.d.ts +20 -0
  80. package/dist/sqlite-action-store.js +225 -0
  81. package/dist/sqlite-action-store.test.d.ts +1 -0
  82. package/dist/sqlite-action-store.test.js +251 -0
  83. package/dist/teaching.d.ts +15 -0
  84. package/dist/teaching.js +132 -0
  85. package/package.json +1 -1
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractDeterministicTeaching = extractDeterministicTeaching;
4
+ function cleanValue(value, limit = 160) {
5
+ return value.replace(/\s+/g, ' ').replace(/^[ .,!?:;"']+|[ .,!?:;"']+$/g, '').slice(0, limit);
6
+ }
7
+ /**
8
+ * Deterministically extracts teaching candidates from user messages according to single-owner model.
9
+ *
10
+ * Rules:
11
+ * - Scoped to the requesting actor context (subject: `actor:${actorId}`), NEVER `primary_user`.
12
+ * - Candidates are pending proposals only, never active/approved.
13
+ * - In a single-owner companion, preferences apply across the companion instance without audience partitioning.
14
+ * - Companion identity is isolated.
15
+ */
16
+ function extractDeterministicTeaching(message, context, sourceEventId) {
17
+ const text = cleanValue(message, 1000);
18
+ const claims = [];
19
+ const behaviorProposals = [];
20
+ if (!text) {
21
+ return { claims, behaviorProposals };
22
+ }
23
+ const actorId = context?.actor?.actorId;
24
+ const actorSubject = actorId ? `actor:${actorId}` : 'actor:anonymous';
25
+ const companionId = context?.companionId || 'default';
26
+ const sensitivity = context?.conversation?.channel === 'public' ? 'public' : 'private';
27
+ // 1. Companion's Name: "your name is X" / "you are called X"
28
+ const companionNameMatch = text.match(/\b(?:your name is|you are called)\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
29
+ if (companionNameMatch) {
30
+ const name = cleanValue(companionNameMatch[1], 80);
31
+ claims.push({
32
+ subject: `companion:${companionId}`,
33
+ predicate: 'name',
34
+ value: name,
35
+ content: `The companion's name is ${name}.`,
36
+ claimType: 'semantic',
37
+ provenance: 'deterministic_teaching',
38
+ sensitivity: 'public',
39
+ sourceEventId,
40
+ });
41
+ behaviorProposals.push({
42
+ directive: `Acknowledge configured name as ${name}`,
43
+ priority: 70,
44
+ subject: `companion:${companionId}`,
45
+ predicate: 'name',
46
+ value: name,
47
+ memoryClass: 'identity',
48
+ sourceEventId,
49
+ });
50
+ }
51
+ // 2. Actor's Name: "my name is X"
52
+ const myNameMatch = text.match(/\bmy name is\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
53
+ if (myNameMatch && !/\b(?:private|public|everywhere)\b/i.test(text)) {
54
+ const name = cleanValue(myNameMatch[1], 80);
55
+ claims.push({
56
+ subject: actorSubject,
57
+ predicate: 'name',
58
+ value: name,
59
+ content: `The actor's name is ${name}.`,
60
+ claimType: 'preference',
61
+ provenance: 'deterministic_teaching',
62
+ sensitivity,
63
+ sourceEventId,
64
+ });
65
+ }
66
+ // 3. Preferred Address / Call me X: "call me X"
67
+ const callMeMatch = text.match(/\b(?:(?:from now on|only),?\s*)?call me\s+(.+?)(?:\s+(?:in private|privately|in public|publicly|everywhere|in direct conversations))?(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
68
+ if (callMeMatch) {
69
+ const address = cleanValue(callMeMatch[1], 80);
70
+ const directiveInstruction = `Address ${actorSubject} as ${address}`;
71
+ claims.push({
72
+ subject: actorSubject,
73
+ predicate: 'preferred_address',
74
+ value: address,
75
+ content: `The actor's preferred address is ${address}.`,
76
+ claimType: 'relationship',
77
+ provenance: 'deterministic_teaching',
78
+ sensitivity,
79
+ sourceEventId,
80
+ });
81
+ behaviorProposals.push({
82
+ directive: directiveInstruction,
83
+ priority: 80,
84
+ subject: actorSubject,
85
+ predicate: 'preferred_address',
86
+ value: address,
87
+ memoryClass: 'behavioral',
88
+ sourceEventId,
89
+ });
90
+ }
91
+ // 4. Stated relationship: "I am your X" / "I'm your creator"
92
+ const relMatch = text.match(/\b(?:i am|i'm)\s+your\s+([A-Za-z0-9_\s-]+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
93
+ if (relMatch) {
94
+ const relationship = cleanValue(relMatch[1], 60);
95
+ claims.push({
96
+ subject: actorSubject,
97
+ predicate: 'stated_relationship',
98
+ value: relationship,
99
+ content: `The actor stated their relationship as ${relationship}.`,
100
+ claimType: 'relationship',
101
+ provenance: 'deterministic_teaching',
102
+ sensitivity: 'private',
103
+ sourceEventId,
104
+ });
105
+ behaviorProposals.push({
106
+ directive: `Recognize ${actorSubject} stated relationship as ${relationship}`,
107
+ priority: 75,
108
+ subject: actorSubject,
109
+ predicate: 'stated_relationship',
110
+ value: relationship,
111
+ memoryClass: 'relationship',
112
+ sourceEventId,
113
+ });
114
+ }
115
+ // 5. Explicit Domain / Preference fact: "my preferred X is Y" / "my X is Y"
116
+ const prefMatch = text.match(/\bmy\s+preferred\s+([A-Za-z0-9_]+)\s+is\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
117
+ if (prefMatch) {
118
+ const predicate = cleanValue(prefMatch[1], 40);
119
+ const val = cleanValue(prefMatch[2], 100);
120
+ claims.push({
121
+ subject: actorSubject,
122
+ predicate: `preferred_${predicate}`,
123
+ value: val,
124
+ content: `The actor's preferred ${predicate} is ${val}.`,
125
+ claimType: 'preference',
126
+ provenance: 'deterministic_teaching',
127
+ sensitivity,
128
+ sourceEventId,
129
+ });
130
+ }
131
+ return { claims, behaviorProposals };
132
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siduri-x/core",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "Core runtime types, evidence protocol, action dispatcher, capability validation, and SiduriRuntime protocol",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {