clawgram 2.4.2 → 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
@@ -1293,14 +1293,22 @@ const createChannelPlugin = (runtimes) => {
1293
1293
  },
1294
1294
  outbound: {
1295
1295
  // Core's agent-delivery path (`--deliver`, subagent announces) calls this
1296
- // with `to: undefined` whenever a delivery has no explicit target and the
1297
- // session route yielded none — and it does not catch a rejection from
1298
- // here. A throw is therefore an unhandled rejection that takes down the
1299
- // entire gateway process, which is exactly what happened on 2026-08-06
1300
- // (systemd: Main process exited, status=1). The contract, read from
1301
- // core's resolveOutboundTargetWithPlugin: answer { ok: false, error } for
1302
- // anything unresolvable. Never throw.
1303
- async resolveTarget(ctx) {
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) {
1304
1312
  try {
1305
1313
  const raw = typeof ctx.to === "string" ? ctx.to.trim() : "";
1306
1314
  actionLog.info("clawgram outbound resolveTarget", {
@@ -1308,21 +1316,12 @@ const createChannelPlugin = (runtimes) => {
1308
1316
  rawTo: raw || null,
1309
1317
  });
1310
1318
  if (!raw) {
1311
- return { ok: false, error: "clawgram: no delivery target — pass `to` or use a session with a bound chat" };
1319
+ return { ok: false, error: new Error("clawgram: no delivery target — pass `to` or use a session with a bound chat") };
1312
1320
  }
1313
- const gram = runtimes.get(ctx.accountId);
1314
- if (!gram) {
1315
- return { ok: false, error: `clawgram: runtime not found for account ${ctx.accountId}` };
1316
- }
1317
- const targetKind = (0, helpers_1.inferOutboundTargetKind)(raw);
1318
- const target = (0, helpers_1.normalizeOutboundTarget)(raw);
1319
- return {
1320
- ok: true,
1321
- to: (await gram.resolvePeer(target, { kind: targetKind })).chatId ?? target,
1322
- };
1321
+ return { ok: true, to: (0, helpers_1.normalizeOutboundTarget)(raw) };
1323
1322
  }
1324
1323
  catch (err) {
1325
- return { ok: false, error: `clawgram: target resolution failed: ${String(err)}` };
1324
+ return { ok: false, error: err instanceof Error ? err : new Error(String(err)) };
1326
1325
  }
1327
1326
  },
1328
1327
  async sendText(ctx) {
@@ -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.2",
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.2",
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": {