@aka_openclaw_plugin/mychat 0.1.9 → 0.1.11

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/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as tryGetMychatRuntime, i as setMychatRuntime, n as init_runtime, t as getMychatRuntime } from "./runtime-PfFuZ2Rm.js";
2
- import { t as mychatPlugin } from "./channel-MvJfw3N_.js";
2
+ import { t as mychatPlugin } from "./channel-Notyh4R-.js";
3
3
  //#region api.ts
4
4
  init_runtime();
5
5
  //#endregion
@@ -3786,11 +3786,15 @@ function createMychatWsClient(params) {
3786
3786
  ws.on("open", () => {
3787
3787
  connected = true;
3788
3788
  currentDelay = initialDelay;
3789
- console.log(`[mychat] WS connected botSelfId=${botSelfId ?? "none"}`);
3790
- if (botSelfId) ws?.send(JSON.stringify({
3791
- type: "subscribe",
3792
- body: { subscribe: { conversationId: botSelfId } }
3793
- }));
3789
+ console.log(`[mychat] WS open event fired, connected=true botSelfId=${botSelfId ?? "none"}`);
3790
+ if (botSelfId) {
3791
+ const subMsg = JSON.stringify({
3792
+ type: "subscribe",
3793
+ body: { subscribe: { conversationId: botSelfId } }
3794
+ });
3795
+ console.log(`[mychat] WS subscribing to conversationId=${botSelfId}`);
3796
+ ws?.send(subMsg);
3797
+ }
3794
3798
  });
3795
3799
  ws.on("message", (data) => {
3796
3800
  try {
@@ -3833,7 +3837,9 @@ function createMychatWsClient(params) {
3833
3837
  };
3834
3838
  },
3835
3839
  isConnected() {
3836
- return connected;
3840
+ const state = connected;
3841
+ console.log(`[mychat] WS isConnected() called, returning ${state}`);
3842
+ return state;
3837
3843
  }
3838
3844
  };
3839
3845
  }
@@ -3929,6 +3935,7 @@ function createMychatProviderLifecycle(params) {
3929
3935
  return {
3930
3936
  async waitForReady() {
3931
3937
  const start = Date.now();
3938
+ console.log(`[mychat:lifecycle] starting timeoutMs=${readyTimeoutMs}`);
3932
3939
  logger?.info(`${prefix} starting connection lifecycle timeoutMs=${readyTimeoutMs}`);
3933
3940
  wsClient.connect();
3934
3941
  let wsConnectedAt = null;
@@ -3937,24 +3944,29 @@ function createMychatProviderLifecycle(params) {
3937
3944
  if (wsClient.isConnected()) {
3938
3945
  if (!wsConnectedAt) {
3939
3946
  wsConnectedAt = Date.now();
3947
+ console.log(`[mychat:lifecycle] ws connected, fetching bot identity elapsedMs=${wsConnectedAt - start}`);
3940
3948
  logger?.info(`${prefix} ws connected, fetching bot identity elapsedMs=${wsConnectedAt - start}`);
3941
3949
  }
3942
3950
  getSelfAttempts++;
3943
3951
  const botSelf = await httpClient.getSelf();
3944
3952
  if (botSelf) {
3953
+ console.log(`[mychat:lifecycle] bot connected botId=${botSelf.botId} wsConnectMs=${wsConnectedAt - start} getSelfAttempts=${getSelfAttempts}`);
3945
3954
  logger?.info(`${prefix} bot connected botId=${botSelf.botId} wsConnectMs=${wsConnectedAt - start} getSelfAttempts=${getSelfAttempts}`);
3946
3955
  return botSelf;
3947
3956
  }
3957
+ console.warn(`[mychat:lifecycle] getSelf() failed attempt=${getSelfAttempts} elapsedMs=${Date.now() - start}`);
3948
3958
  logger?.warn(`${prefix} getSelf() failed attempt=${getSelfAttempts} elapsedMs=${Date.now() - start}`);
3949
3959
  }
3950
3960
  await new Promise((r) => setTimeout(r, 500));
3951
3961
  }
3952
3962
  const wsConnected = wsClient.isConnected();
3953
3963
  const elapsed = Date.now() - start;
3964
+ console.warn(`[mychat:lifecycle] ready timeout wsConnected=${wsConnected} wsConnectedAt=${wsConnectedAt ? wsConnectedAt - start : "never"} getSelfAttempts=${getSelfAttempts} elapsedMs=${elapsed} timeoutMs=${readyTimeoutMs}`);
3954
3965
  logger?.warn(`${prefix} ready timeout wsConnected=${wsConnected} wsConnectedAt=${wsConnectedAt ? wsConnectedAt - start : "never"} getSelfAttempts=${getSelfAttempts} elapsedMs=${elapsed} timeoutMs=${readyTimeoutMs}`);
3955
3966
  return null;
3956
3967
  },
3957
3968
  shutdown() {
3969
+ console.log(`[mychat:lifecycle] shutdown`);
3958
3970
  wsClient.disconnect();
3959
3971
  logger?.info(`${prefix} shutdown`);
3960
3972
  }
@@ -4114,6 +4126,7 @@ async function monitorMychatProvider(ctx) {
4114
4126
  const { account, setStatus } = ctx;
4115
4127
  const logger = getMychatLogger();
4116
4128
  const prefix = mychatLogPrefix("provider");
4129
+ console.log(`[mychat:provider] starting accountId=${account.accountId}`);
4117
4130
  if (logger) logger.info(`${prefix} starting accountId=${account.accountId}`);
4118
4131
  setStatus({
4119
4132
  connected: false,
@@ -4123,10 +4136,12 @@ async function monitorMychatProvider(ctx) {
4123
4136
  baseUrl: account.baseUrl,
4124
4137
  token: account.token
4125
4138
  });
4139
+ console.log(`[mychat:provider] fetching bot identity baseUrl=${account.baseUrl}`);
4126
4140
  if (logger) logger.info(`${prefix} fetching bot identity baseUrl=${account.baseUrl}`);
4127
4141
  const botSelf = await httpClient.getSelf();
4128
4142
  if (!botSelf) {
4129
4143
  const error = `MyChat provider failed to get bot identity (baseUrl=${account.baseUrl}, token=${account.token ? account.token.slice(0, 8) + "..." : "empty"})`;
4144
+ console.error(`[mychat:provider] ${error}`);
4130
4145
  if (logger) logger.error(`${prefix} ${error}`);
4131
4146
  setStatus({
4132
4147
  connected: false,
@@ -4134,11 +4149,16 @@ async function monitorMychatProvider(ctx) {
4134
4149
  });
4135
4150
  throw new Error(error);
4136
4151
  }
4152
+ console.log(`[mychat:provider] got bot identity botId=${botSelf.botId} name=${botSelf.name ?? "unknown"}`);
4137
4153
  if (logger) logger.info(`${prefix} got bot identity botId=${botSelf.botId} name=${botSelf.name ?? "unknown"}`);
4138
4154
  const health = await httpClient.healthCheck();
4139
4155
  if (!health.ok) {
4156
+ console.warn(`[mychat:provider] health check failed latencyMs=${health.latencyMs} baseUrl=${account.baseUrl}`);
4140
4157
  if (logger) logger.warn(`${prefix} health check failed latencyMs=${health.latencyMs} baseUrl=${account.baseUrl}`);
4141
- } else if (logger) logger.info(`${prefix} health check ok latencyMs=${health.latencyMs}`);
4158
+ } else {
4159
+ console.log(`[mychat:provider] health check ok latencyMs=${health.latencyMs}`);
4160
+ if (logger) logger.info(`${prefix} health check ok latencyMs=${health.latencyMs}`);
4161
+ }
4142
4162
  const { wsClient } = createMychatProviderClients(account, botSelf.botId);
4143
4163
  const rt = ctx.runtime;
4144
4164
  rt.mychat = {
@@ -4160,6 +4180,7 @@ async function monitorMychatProvider(ctx) {
4160
4180
  }),
4161
4181
  wsClient
4162
4182
  });
4183
+ console.log(`[mychat:provider] starting connection lifecycle`);
4163
4184
  const lifecycle = createMychatProviderLifecycle({
4164
4185
  httpClient,
4165
4186
  wsClient
@@ -4167,6 +4188,7 @@ async function monitorMychatProvider(ctx) {
4167
4188
  const readyBotSelf = await lifecycle.waitForReady();
4168
4189
  if (!readyBotSelf) {
4169
4190
  const error = "MyChat provider failed to connect";
4191
+ console.error(`[mychat:provider] ${error}`);
4170
4192
  if (logger) logger.error(`${prefix} ${error}`);
4171
4193
  setStatus({
4172
4194
  connected: false,
@@ -4182,13 +4204,16 @@ async function monitorMychatProvider(ctx) {
4182
4204
  mode: "websocket",
4183
4205
  lastError: null
4184
4206
  });
4207
+ console.log(`[mychat:provider] bot connected botId=${readyBotSelf.botId}`);
4185
4208
  if (logger) logger.info(`${prefix} bot connected botId=${readyBotSelf.botId}`);
4186
4209
  ctx.abortSignal?.addEventListener("abort", () => {
4210
+ console.log(`[mychat:provider] abort signal received, shutting down`);
4187
4211
  if (logger) logger.info(`${prefix} abort signal received, shutting down`);
4188
4212
  lifecycle.shutdown();
4189
4213
  setStatus({ connected: false });
4190
4214
  });
4191
4215
  return { unsubscribe() {
4216
+ console.log(`[mychat:provider] unsubscribe called, shutting down`);
4192
4217
  lifecycle.shutdown();
4193
4218
  setStatus({ connected: false });
4194
4219
  } };
@@ -1,2 +1,2 @@
1
- import { t as mychatPlugin } from "./channel-MvJfw3N_.js";
1
+ import { t as mychatPlugin } from "./channel-Notyh4R-.js";
2
2
  export { mychatPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aka_openclaw_plugin/mychat",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "OpenClaw MyChat channel plugin",
5
5
  "repository": {
6
6
  "type": "git",
package/setup-entry.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as mychatPlugin } from "./channel-MvJfw3N_.js";
1
+ import { t as mychatPlugin } from "./channel-Notyh4R-.js";
2
2
  export { mychatPlugin };