angelia-gateway 0.3.23 → 0.3.24

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.
@@ -249,9 +249,16 @@ export class TelegramAdapter {
249
249
  else
250
250
  note(`a file over ${MAX_INBOUND >> 20} MB was sent and not downloaded`);
251
251
  }
252
+ else {
253
+ this.log(`telegram: getFile gave no file_path chat=${chat}`);
254
+ note('the file sent could not be downloaded');
255
+ }
252
256
  }
253
257
  catch (e) {
258
+ // Said to the agent too (#35): a file with no caption would otherwise be no turn at all, and one
259
+ // with a caption would be answered as if nothing was attached.
254
260
  this.log(`telegram: media download failed chat=${chat}: ${String(e.message ?? e).split(this.opts.token).join('<token>').slice(0, 160)}`);
261
+ note('the file sent could not be downloaded');
255
262
  }
256
263
  }
257
264
  if (!head.text && !media.length)
@@ -11,6 +11,8 @@ import { SentMessages } from './sent.js';
11
11
  import { isOpus } from '../../core/deliver/media.js';
12
12
  import { asVoice } from '../../voice/opus.js';
13
13
  const MAX_MEDIA = MAX_INBOUND;
14
+ /** How a note to the agent names a kind of file: "a photo", "a voice note", never "a image". */
15
+ const KIND_NAME = { image: 'photo', audio: 'voice note', video: 'video', document: 'document', sticker: 'sticker' };
14
16
  const EXT = { 'image/jpeg': '.jpg', 'image/png': '.png', 'image/webp': '.webp', 'video/mp4': '.mp4', 'audio/ogg; codecs=opus': '.ogg', 'audio/ogg': '.ogg', 'audio/mpeg': '.mp3', 'application/pdf': '.pdf' };
15
17
  /**
16
18
  * WhatsApp as a linked device (Baileys, in-process). One socket per daemon. Pairing by code
@@ -208,7 +210,7 @@ export class WhatsAppAdapter extends EventEmitter {
208
210
  if (inbox && p.media && p.media.kind !== 'sticker') {
209
211
  if ((p.media.size ?? 0) > MAX_MEDIA) {
210
212
  this.log(`whatsapp: media over ${MAX_MEDIA >> 20} MB not downloaded chat=${p.chat.slice(0, 8)}…`);
211
- note(`a ${p.media.kind} over ${MAX_MEDIA >> 20} MB was sent and not downloaded`);
213
+ note(`a ${KIND_NAME[p.media.kind] ?? p.media.kind} over ${MAX_MEDIA >> 20} MB was sent and not downloaded`);
212
214
  }
213
215
  else if (!this.quota.take(senderId)) {
214
216
  this.log(`whatsapp: media not downloaded chat=${p.chat.slice(0, 8)}… reason=sender-hourly-limit`);
@@ -229,11 +231,13 @@ export class WhatsAppAdapter extends EventEmitter {
229
231
  media.push(dest);
230
232
  else {
231
233
  this.log(`whatsapp: media passed ${MAX_MEDIA >> 20} MB while downloading, dropped chat=${p.chat.slice(0, 8)}…`);
232
- note(`a ${p.media.kind} over ${MAX_MEDIA >> 20} MB was sent and not downloaded`);
234
+ note(`a ${KIND_NAME[p.media.kind] ?? p.media.kind} over ${MAX_MEDIA >> 20} MB was sent and not downloaded`);
233
235
  }
234
236
  }
235
237
  catch (e) {
238
+ // Said to the agent too (#35): a file with no caption would otherwise be no turn at all.
236
239
  this.log(`whatsapp: media download failed chat=${p.chat.slice(0, 8)}…: ${String(e.message ?? e).slice(0, 160)}`);
240
+ note(`the ${KIND_NAME[p.media.kind] ?? p.media.kind} sent could not be downloaded`);
237
241
  }
238
242
  }
239
243
  if (!head.text && !media.length)
@@ -29,10 +29,22 @@ export class SeenIds {
29
29
  return true;
30
30
  }
31
31
  }
32
- /** Unwrap ephemeral / view-once / caption wrappers to the message body Baileys nests them in. */
32
+ /**
33
+ * Unwrap ephemeral / view-once / caption wrappers to the message body Baileys nests them in. WhatsApp
34
+ * stacks them (a document with a caption in a disappearing chat is ephemeral > documentWithCaption >
35
+ * document), so this peels up to five layers, as Baileys' own normalizeMessageContent does (#34).
36
+ * Baileys also peels editedMessage and the group status wrappers; those are left out on purpose, an edit
37
+ * holds a protocol message and a group status post must not become a turn.
38
+ */
33
39
  export function messageContent(m) {
34
- const c = m.message ?? {};
35
- return c.ephemeralMessage?.message ?? c.viewOnceMessage?.message ?? c.viewOnceMessageV2?.message ?? c.documentWithCaptionMessage?.message ?? c;
40
+ let c = m.message ?? {};
41
+ for (let i = 0; i < 5; i++) {
42
+ const inner = c.ephemeralMessage ?? c.viewOnceMessage ?? c.viewOnceMessageV2 ?? c.viewOnceMessageV2Extension ?? c.documentWithCaptionMessage;
43
+ if (!inner?.message)
44
+ break;
45
+ c = inner.message;
46
+ }
47
+ return c;
36
48
  }
37
49
  /**
38
50
  * Baileys message -> the router's view of it, or null when it is nothing we act on
package/dist/build.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "commit": "1265a8aef35fa55da288c44537d347fbc31d0f9f",
2
+ "commit": "7741b7e7acfbb0f41798898db304823fb720d450",
3
3
  "dirty": false,
4
- "built": "2026-10-27T21:20:43.836Z",
5
- "tag": "v0.3.23"
4
+ "built": "2026-10-30T16:18:46.546Z",
5
+ "tag": "v0.3.24"
6
6
  }
@@ -57,13 +57,25 @@ function fenceCost(f) {
57
57
  function prefix(fence) {
58
58
  return fence ? fence.opener + '\n' : '';
59
59
  }
60
- /** Returns the fence still open at the end of `piece` (given the state at its start). */
60
+ /**
61
+ * Returns the fence still open at the end of `piece` (given the state at its start). CommonMark's
62
+ * rules (#36): a backtick opener's info string holds no backtick, so a line of inline code such as
63
+ * "```x``` is the flag" opens nothing; a closer is at least as long as its opener and carries no info
64
+ * string, so a ``` line inside a ```` block, or a tagged one, is content.
65
+ */
61
66
  function fenceState(piece, open) {
62
67
  let state = open;
63
68
  for (const line of piece.split('\n')) {
64
- const m = /^\s*(`{3,10})(?!`)([\w+#.-]{0,20})/.exec(line);
65
- if (m)
66
- state = state ? null : { opener: m[1] + m[2], closer: m[1] };
69
+ const m = /^\s*(`{3,10})(?!`)(.*)$/.exec(line);
70
+ if (!m)
71
+ continue;
72
+ const info = m[2].trim();
73
+ if (state) {
74
+ if (m[1].length >= state.closer.length && !info)
75
+ state = null;
76
+ }
77
+ else if (!info.includes('`'))
78
+ state = { opener: m[1] + (/^[\w+#.-]{0,20}/.exec(info)?.[0] ?? ''), closer: m[1] };
67
79
  }
68
80
  return state;
69
81
  }
@@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:
3
3
  import { homedir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { secretFindings } from './secrets.js';
6
+ import { STAGED_DIFF, secretFindings } from './secrets.js';
7
7
  /**
8
8
  * Where one person's Angelia lives.
9
9
  *
@@ -201,10 +201,19 @@ export function syncWorkspace(workspace = workspaceDir(), now = new Date(), run
201
201
  run(['add', '-A'], workspace);
202
202
  // The same scan workspace commit runs: agents write their own memory, and a pasted key must not
203
203
  // reach the remote because the nightly save took everything. A flagged file is left out, and said.
204
- const leaks = secretFindings(run(['diff', '--cached', '-U0', '--no-color'], workspace));
204
+ const leaks = secretFindings(run(STAGED_DIFF, workspace));
205
205
  const held = [...new Set(leaks.map((l) => l.slice(0, l.lastIndexOf(': '))))];
206
- if (held.length)
206
+ if (held.length) {
207
207
  run(['reset', '-q', '--', ...held], workspace);
208
+ // Scanned again: a path the reset did not match (a name git wrote differently from the index)
209
+ // would be saved and pushed while this says it was left out. Then nothing is committed, and the
210
+ // job reports it.
211
+ const still = secretFindings(run(STAGED_DIFF, workspace));
212
+ if (still.length) {
213
+ run(['reset', '-q'], workspace);
214
+ throw new Error(`secret-shaped content still staged after the reset, nothing committed: ${still.join('; ')}`);
215
+ }
216
+ }
208
217
  const files = run(['diff', '--cached', '--name-only'], workspace).split('\n').filter(Boolean);
209
218
  if (files.length)
210
219
  run(['-c', 'commit.gpgsign=false', 'commit', '-q', '-m', `Workspace sync ${now.toISOString().slice(0, 10)}: ${files.length} file${files.length > 1 ? 's' : ''}`], workspace);
@@ -49,9 +49,10 @@ function iban(s) {
49
49
  return r === 1;
50
50
  }
51
51
  /** A path from a diff header, as git wrote it: quoted, with octal escapes, when it holds a byte
52
- * outside ASCII (a Hebrew file name). Taken literally, `git reset -- <name>` would match nothing. */
52
+ * outside ASCII (a Hebrew file name), and ended with a tab when it holds a space ("+++ b/my notes.md\t").
53
+ * Taken literally, `git reset -- <name>` would match nothing, and the file would be committed after all. */
53
54
  function diffPath(header) {
54
- let p = header.slice(4);
55
+ let p = header.slice(4).replace(/\t$/, '');
55
56
  if (p.startsWith('"') && p.endsWith('"')) {
56
57
  const bytes = [];
57
58
  const body = p.slice(1, -1);
@@ -73,12 +74,28 @@ function diffPath(header) {
73
74
  }
74
75
  return p.replace(/^b\//, '');
75
76
  }
77
+ /**
78
+ * The diff the scan reads, staged. The prefixes are pinned, because diff.mnemonicPrefix, diff.noprefix
79
+ * or diff.dstPrefix in the user's own git config would name a path the reset then misses; --no-ext-diff
80
+ * keeps a difftool out of the output (an empty one scans clean); --text keeps a `*.md -diff` attribute
81
+ * from turning a file into "Binary files differ", which has no lines to read.
82
+ */
83
+ export const STAGED_DIFF = ['diff', '--cached', '-U0', '--no-color', '--no-ext-diff', '--text', '--src-prefix=a/', '--dst-prefix=b/'];
76
84
  /** Each added line in a unified diff that holds a secret-shaped value, as `file: what`. Never the value. */
77
85
  export function secretFindings(diff) {
78
86
  const out = [];
79
87
  let file = '';
88
+ let inHunk = false; // "+++ " names the file only before its first @@; after it, it is an added "++ " line
80
89
  for (const line of diff.split('\n')) {
81
- if (line.startsWith('+++ ')) {
90
+ if (line.startsWith('diff --git ')) {
91
+ inHunk = false;
92
+ continue;
93
+ }
94
+ if (line.startsWith('@@')) {
95
+ inHunk = true;
96
+ continue;
97
+ }
98
+ if (!inHunk && line.startsWith('+++ ')) {
82
99
  file = diffPath(line);
83
100
  continue;
84
101
  }
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, relative, resolve, sep } from 'node:path';
2
2
  import { git, isRepo, pushWorkspace } from './instance.js';
3
- import { secretFindings } from './secrets.js';
3
+ import { STAGED_DIFF, secretFindings } from './secrets.js';
4
4
  export { secretFindings } from './secrets.js';
5
5
  export function commitWorkspace(o) {
6
6
  const run = o.run ?? git;
@@ -22,7 +22,7 @@ export function commitWorkspace(o) {
22
22
  if (!files.length)
23
23
  return 'nothing to commit';
24
24
  const failed = [];
25
- const leaks = secretFindings(run(['diff', '--cached', '-U0', '--no-color'], ws));
25
+ const leaks = secretFindings(run(STAGED_DIFF, ws));
26
26
  if (leaks.length)
27
27
  failed.push(`secret scan: ${leaks.join('; ')}`);
28
28
  for (const g of o.gates ?? []) {
package/package.json CHANGED
@@ -1,7 +1,21 @@
1
1
  {
2
2
  "name": "angelia-gateway",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "Turn the coding agent CLI you already know into the brain of your personal assistants, on WhatsApp and Telegram. One chat, one folder, one session.",
5
+ "keywords": [
6
+ "claude-code",
7
+ "codex",
8
+ "grok",
9
+ "pi",
10
+ "whatsapp",
11
+ "telegram",
12
+ "telegram-bot",
13
+ "whatsapp-bot",
14
+ "claude",
15
+ "coding-agent",
16
+ "self-hosted",
17
+ "macos"
18
+ ],
5
19
  "type": "module",
6
20
  "license": "MIT",
7
21
  "homepage": "https://useangelia.com",