@c4t4/heyamigo 0.11.0 → 0.11.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.
@@ -182,6 +182,7 @@ export async function processIncomingMessage(incoming, opts = {}) {
182
182
  const trigger = checkTrigger({
183
183
  mode: decision.triggerMode,
184
184
  text: stored.text,
185
+ audioTranscript: audioTranscript ?? undefined,
185
186
  mentionedBot: incoming.triggerHints?.mentionedBot,
186
187
  replyToBot: incoming.triggerHints?.replyToBot,
187
188
  });
@@ -1,4 +1,68 @@
1
1
  import { config } from '../config.js';
2
+ const AUDIO_ALIAS_VARIANTS = {
3
+ heyamigo: [
4
+ 'hey amigo',
5
+ 'hey amigos',
6
+ 'hey amego',
7
+ 'hey amico',
8
+ 'hey a migo',
9
+ 'hay amigo',
10
+ 'hi amigo',
11
+ ],
12
+ amigo: [
13
+ 'a migo',
14
+ 'amego',
15
+ 'amico',
16
+ 'amigos',
17
+ 'amiga',
18
+ 'migo',
19
+ ],
20
+ claude: [
21
+ 'cloud',
22
+ 'clawd',
23
+ 'clawed',
24
+ 'clod',
25
+ 'clode',
26
+ 'cload',
27
+ 'clout',
28
+ 'claut',
29
+ 'clause',
30
+ 'claus',
31
+ ],
32
+ clawd: [
33
+ 'claude',
34
+ 'cloud',
35
+ 'clawed',
36
+ 'clod',
37
+ 'clode',
38
+ 'cload',
39
+ 'clout',
40
+ 'claut',
41
+ ],
42
+ grok: [
43
+ 'grock',
44
+ 'grog',
45
+ 'gronk',
46
+ 'grawk',
47
+ 'groc',
48
+ ],
49
+ codex: [
50
+ 'code x',
51
+ 'codec',
52
+ 'codecs',
53
+ 'codecks',
54
+ 'codicks',
55
+ 'kodeks',
56
+ 'codacs',
57
+ ],
58
+ xai: [
59
+ 'x ai',
60
+ 'x a i',
61
+ 'ex ai',
62
+ 'ex a i',
63
+ 'x.ai',
64
+ ],
65
+ };
2
66
  function escapeRegex(s) {
3
67
  return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
4
68
  }
@@ -10,6 +74,42 @@ function aliasMatches(text, aliases) {
10
74
  }
11
75
  return null;
12
76
  }
77
+ function normalizeAudioText(text) {
78
+ return text
79
+ .toLowerCase()
80
+ .normalize('NFKD')
81
+ .replace(/[\u0300-\u036f]/g, '')
82
+ .replace(/[^a-z0-9]+/g, ' ')
83
+ .trim()
84
+ .replace(/\s+/g, ' ');
85
+ }
86
+ function phraseMatches(normalizedText, phrase) {
87
+ const normalizedPhrase = normalizeAudioText(phrase);
88
+ if (!normalizedPhrase)
89
+ return false;
90
+ const re = new RegExp(`(^| )${escapeRegex(normalizedPhrase)}($| )`, 'i');
91
+ return re.test(normalizedText);
92
+ }
93
+ function audioAliasMatches(transcript, aliases) {
94
+ const normalizedTranscript = normalizeAudioText(transcript);
95
+ if (!normalizedTranscript)
96
+ return null;
97
+ for (const alias of aliases) {
98
+ const normalizedAlias = normalizeAudioText(alias);
99
+ if (phraseMatches(normalizedTranscript, normalizedAlias)) {
100
+ return { alias, variant: normalizedAlias };
101
+ }
102
+ const variants = new Set([
103
+ ...(AUDIO_ALIAS_VARIANTS[normalizedAlias] ?? []),
104
+ ]);
105
+ for (const variant of variants) {
106
+ if (phraseMatches(normalizedTranscript, variant)) {
107
+ return { alias, variant: normalizeAudioText(variant) };
108
+ }
109
+ }
110
+ }
111
+ return null;
112
+ }
13
113
  export function checkTrigger(params) {
14
114
  const { mode, text } = params;
15
115
  if (mode === 'off')
@@ -27,6 +127,15 @@ export function checkTrigger(params) {
27
127
  const alias = aliasMatches(text, config.triggers.aliases);
28
128
  if (alias)
29
129
  return { triggered: true, reason: `alias:${alias}` };
130
+ const audioAlias = params.audioTranscript
131
+ ? audioAliasMatches(params.audioTranscript, config.triggers.aliases)
132
+ : null;
133
+ if (audioAlias) {
134
+ return {
135
+ triggered: true,
136
+ reason: `audio-alias:${audioAlias.alias}~${audioAlias.variant}`,
137
+ };
138
+ }
30
139
  // 2. Channel-provided mention signal, e.g. WhatsApp @mention or
31
140
  // Telegram bot username mention.
32
141
  if (params.mentionedBot)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4t4/heyamigo",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "WhatsApp and Telegram AI bot powered by Claude, Codex, or Grok with long-term memory, browser control, and role-based access",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",