@clawling/clawchat-plugin-openclaw 2026.8.5-1 → 2026.8.5-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.
@@ -2803,6 +2803,37 @@ export async function startOpenclawClawlingGateway(params) {
2803
2803
  conversationId: claimedBootstrap.conversationId,
2804
2804
  }));
2805
2805
  };
2806
+ const markBootstrapSent = (reason) => {
2807
+ if (!bootstrap)
2808
+ return;
2809
+ const claimedBootstrap = bootstrap;
2810
+ const marked = recordConnection("activation bootstrap sent", () => store.markActivationBootstrapSent?.({
2811
+ platform: "openclaw",
2812
+ accountId,
2813
+ conversationId: claimedBootstrap.conversationId,
2814
+ }));
2815
+ if (marked !== true) {
2816
+ // The UPDATE is guarded on bootstrap_sent = 0 AND bootstrap_claimed_at
2817
+ // IS NOT NULL, so a stale re-claim makes this a no-op — and the row
2818
+ // then stays re-greetable on every later reconnect. Never swallow it.
2819
+ log?.error?.(`[${accountId}] clawchat-plugin-openclaw activation bootstrap not marked sent (${reason}); the greeting may repeat on reconnect`);
2820
+ }
2821
+ // Delivered — stop any pending retry.
2822
+ clearBootstrapRetry();
2823
+ };
2824
+ // Single decision point for every exit after the claim. The greeting is
2825
+ // emitted *inside* the dispatched turn, so once it has reached the user the
2826
+ // claim must never be rolled back: releasing it lets the next connection
2827
+ // claim again and greet a second time. Only a turn that delivered nothing
2828
+ // is safe to retry.
2829
+ const settleBootstrap = (reason) => {
2830
+ if (bootstrapGreetingDelivered) {
2831
+ markBootstrapSent(reason);
2832
+ return;
2833
+ }
2834
+ releaseBootstrap();
2835
+ armBootstrapRetry();
2836
+ };
2806
2837
  try {
2807
2838
  bootstrap = recordConnection("activation bootstrap claim", () => store.claimPendingActivationBootstrap?.({ platform: "openclaw", accountId }));
2808
2839
  if (!bootstrap) {
@@ -2819,8 +2850,7 @@ export async function startOpenclawClawlingGateway(params) {
2819
2850
  bootstrapGreetingDelivered = false;
2820
2851
  const result = await handleInboundEnvelope(buildActivationBootstrapEnvelope({ account, conversationId: claimedBootstrap.conversationId }));
2821
2852
  if (result !== "submitted") {
2822
- releaseBootstrap();
2823
- armBootstrapRetry();
2853
+ settleBootstrap("turn was not submitted");
2824
2854
  return;
2825
2855
  }
2826
2856
  // Only mark the bootstrap done once the greeting was actually delivered
@@ -2831,21 +2861,11 @@ export async function startOpenclawClawlingGateway(params) {
2831
2861
  // rather than silently consuming it forever or waiting for the next reconnect.
2832
2862
  if (!bootstrapGreetingDelivered) {
2833
2863
  log?.info?.(`[${accountId}] clawchat-plugin-openclaw activation bootstrap dispatched but greeting was not delivered; leaving pending for retry`);
2834
- releaseBootstrap();
2835
- armBootstrapRetry();
2836
- return;
2837
2864
  }
2838
- recordConnection("activation bootstrap sent", () => store.markActivationBootstrapSent?.({
2839
- platform: "openclaw",
2840
- accountId,
2841
- conversationId: claimedBootstrap.conversationId,
2842
- }));
2843
- // Delivered — stop any pending retry.
2844
- clearBootstrapRetry();
2865
+ settleBootstrap("turn submitted");
2845
2866
  }
2846
2867
  catch (err) {
2847
- releaseBootstrap();
2848
- armBootstrapRetry();
2868
+ settleBootstrap("dispatch threw");
2849
2869
  log?.error?.(`[${accountId}] clawchat-plugin-openclaw activation bootstrap failed: ${err instanceof Error ? err.message : String(err)}`);
2850
2870
  }
2851
2871
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawling/clawchat-plugin-openclaw",
3
- "version": "2026.8.5-1",
3
+ "version": "2026.8.5-2",
4
4
  "description": "OpenClaw ClawChat channel plugin",
5
5
  "license": "MIT",
6
6
  "author": "CLAWLING PTE. LTD.",
package/src/runtime.ts CHANGED
@@ -3333,6 +3333,40 @@ export async function startOpenclawClawlingGateway(params: StartGatewayParams):
3333
3333
  }),
3334
3334
  );
3335
3335
  };
3336
+ const markBootstrapSent = (reason: string) => {
3337
+ if (!bootstrap) return;
3338
+ const claimedBootstrap = bootstrap;
3339
+ const marked = recordConnection("activation bootstrap sent", () =>
3340
+ store.markActivationBootstrapSent?.({
3341
+ platform: "openclaw",
3342
+ accountId,
3343
+ conversationId: claimedBootstrap.conversationId,
3344
+ }),
3345
+ );
3346
+ if (marked !== true) {
3347
+ // The UPDATE is guarded on bootstrap_sent = 0 AND bootstrap_claimed_at
3348
+ // IS NOT NULL, so a stale re-claim makes this a no-op — and the row
3349
+ // then stays re-greetable on every later reconnect. Never swallow it.
3350
+ log?.error?.(
3351
+ `[${accountId}] clawchat-plugin-openclaw activation bootstrap not marked sent (${reason}); the greeting may repeat on reconnect`,
3352
+ );
3353
+ }
3354
+ // Delivered — stop any pending retry.
3355
+ clearBootstrapRetry();
3356
+ };
3357
+ // Single decision point for every exit after the claim. The greeting is
3358
+ // emitted *inside* the dispatched turn, so once it has reached the user the
3359
+ // claim must never be rolled back: releasing it lets the next connection
3360
+ // claim again and greet a second time. Only a turn that delivered nothing
3361
+ // is safe to retry.
3362
+ const settleBootstrap = (reason: string) => {
3363
+ if (bootstrapGreetingDelivered) {
3364
+ markBootstrapSent(reason);
3365
+ return;
3366
+ }
3367
+ releaseBootstrap();
3368
+ armBootstrapRetry();
3369
+ };
3336
3370
  try {
3337
3371
  bootstrap = recordConnection("activation bootstrap claim", () =>
3338
3372
  store.claimPendingActivationBootstrap?.({ platform: "openclaw", accountId }),
@@ -3352,8 +3386,7 @@ export async function startOpenclawClawlingGateway(params: StartGatewayParams):
3352
3386
  buildActivationBootstrapEnvelope({ account, conversationId: claimedBootstrap.conversationId }),
3353
3387
  );
3354
3388
  if (result !== "submitted") {
3355
- releaseBootstrap();
3356
- armBootstrapRetry();
3389
+ settleBootstrap("turn was not submitted");
3357
3390
  return;
3358
3391
  }
3359
3392
  // Only mark the bootstrap done once the greeting was actually delivered
@@ -3366,22 +3399,10 @@ export async function startOpenclawClawlingGateway(params: StartGatewayParams):
3366
3399
  log?.info?.(
3367
3400
  `[${accountId}] clawchat-plugin-openclaw activation bootstrap dispatched but greeting was not delivered; leaving pending for retry`,
3368
3401
  );
3369
- releaseBootstrap();
3370
- armBootstrapRetry();
3371
- return;
3372
3402
  }
3373
- recordConnection("activation bootstrap sent", () =>
3374
- store.markActivationBootstrapSent?.({
3375
- platform: "openclaw",
3376
- accountId,
3377
- conversationId: claimedBootstrap.conversationId,
3378
- }),
3379
- );
3380
- // Delivered — stop any pending retry.
3381
- clearBootstrapRetry();
3403
+ settleBootstrap("turn submitted");
3382
3404
  } catch (err) {
3383
- releaseBootstrap();
3384
- armBootstrapRetry();
3405
+ settleBootstrap("dispatch threw");
3385
3406
  log?.error?.(
3386
3407
  `[${accountId}] clawchat-plugin-openclaw activation bootstrap failed: ${err instanceof Error ? err.message : String(err)}`,
3387
3408
  );