clawgram 2.4.1 → 2.4.3

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.
package/dist/channel.js CHANGED
@@ -1292,21 +1292,37 @@ const createChannelPlugin = (runtimes) => {
1292
1292
  },
1293
1293
  },
1294
1294
  outbound: {
1295
- async resolveTarget(ctx) {
1296
- actionLog.info("clawgram outbound resolveTarget", {
1297
- accountId: ctx.accountId,
1298
- rawTo: ctx.to,
1299
- });
1300
- const gram = runtimes.get(ctx.accountId);
1301
- if (!gram) {
1302
- throw new Error(`clawgram: runtime not found for account ${ctx.accountId}`);
1295
+ // Core's agent-delivery path (`--deliver`, subagent announces) calls this
1296
+ // hook under three constraints, all learned live on 2026-08-06:
1297
+ //
1298
+ // - `to` may be undefined (no explicit target, session route yielded
1299
+ // none), and a rejection is NOT caught: a throw here is an unhandled
1300
+ // rejection that takes down the entire gateway process.
1301
+ // - `resolveAgentDeliveryPlanWithSessionRoute` calls it WITHOUT await.
1302
+ // An async hook hands core a Promise, `promise.ok` reads undefined and
1303
+ // the error branch dereferences `promise.error.message` — the crash
1304
+ // every subagent announce died on. The hook must return a plain value;
1305
+ // the call sites that do await are unaffected, await of a value works.
1306
+ // - In a not-ok result core reads `error.message`, so the error must be
1307
+ // Error-like, not a bare string.
1308
+ //
1309
+ // Peer resolution deliberately does not happen here: `sendText` resolves
1310
+ // the peer itself, and doing it here would force the hook async again.
1311
+ resolveTarget(ctx) {
1312
+ try {
1313
+ const raw = typeof ctx.to === "string" ? ctx.to.trim() : "";
1314
+ actionLog.info("clawgram outbound resolveTarget", {
1315
+ accountId: ctx.accountId,
1316
+ rawTo: raw || null,
1317
+ });
1318
+ if (!raw) {
1319
+ return { ok: false, error: new Error("clawgram: no delivery target — pass `to` or use a session with a bound chat") };
1320
+ }
1321
+ return { ok: true, to: (0, helpers_1.normalizeOutboundTarget)(raw) };
1322
+ }
1323
+ catch (err) {
1324
+ return { ok: false, error: err instanceof Error ? err : new Error(String(err)) };
1303
1325
  }
1304
- const targetKind = (0, helpers_1.inferOutboundTargetKind)(ctx.to);
1305
- const target = (0, helpers_1.normalizeOutboundTarget)(ctx.to);
1306
- return {
1307
- ok: true,
1308
- to: (await gram.resolvePeer(target, { kind: targetKind })).chatId ?? target,
1309
- };
1310
1326
  },
1311
1327
  async sendText(ctx) {
1312
1328
  // Never log `text`: outbound bodies are private correspondence and the
@@ -2,7 +2,7 @@
2
2
  "id": "clawgram",
3
3
  "name": "Clawgram",
4
4
  "description": "Clawgram — personal Telegram (MTProto userbot) channel for OpenClaw. Your AI assistant reads and responds as you.",
5
- "version": "2.4.1",
5
+ "version": "2.4.3",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawgram",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "Clawgram — personal Telegram (MTProto userbot) channel for OpenClaw. Your AI assistant reads and responds as you.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {