@botschat/botschat 0.1.22 → 0.1.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.
package/SKILL.md CHANGED
@@ -11,7 +11,7 @@ Interact with [BotsChat](https://botschat.app) directly from OpenClaw. Send mess
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- npx skills add @botschat/botschat
14
+ npx skills add botschat-app/botsChat
15
15
  ```
16
16
 
17
17
  Or use directly with npx (no install):
@@ -597,6 +597,7 @@ async function browserLogin(autoOpen = true) {
597
597
  Logged in as ${email} (${userId})`);
598
598
  }
599
599
  setTimeout(() => {
600
+ server.closeAllConnections();
600
601
  server.close();
601
602
  resolve();
602
603
  }, 2e3);
@@ -1110,7 +1111,7 @@ var BotsChatWSClient = class {
1110
1111
  };
1111
1112
 
1112
1113
  // src/commands/chat.ts
1113
- var chatCmd = new Command9("chat").description("Chat with an AI agent").argument("[message]", "Message to send (omit for interactive mode)").option("-i, --interactive", "Interactive REPL mode").option("-s, --session <sessionId>", "Session ID").option("-c, --channel <channelId>", "Channel ID").option("-a, --agent <agentId>", "Agent ID").option("--no-stream", "Wait for full response instead of streaming").option("--pipe", "Read message from stdin").option("--timeout <ms>", "Timeout in ms for single-shot mode", "120000").action(async (message, opts) => {
1114
+ var chatCmd = new Command9("chat").description("Chat with an AI agent").argument("[message]", "Message to send (omit for interactive mode)").option("-i, --interactive", "Interactive REPL mode").option("-s, --session <sessionId>", "Session ID").option("-c, --channel <channelId>", "Channel ID").option("-a, --agent <agentId>", "Agent ID").option("--no-stream", "Wait for full response instead of streaming").option("--async", "Send message and exit immediately without waiting for response").option("--pipe", "Read message from stdin").option("--timeout <seconds>", "Timeout in seconds for single-shot mode", "300").action(async (message, opts) => {
1114
1115
  try {
1115
1116
  const cfg = loadConfig();
1116
1117
  if (!cfg.userId || !cfg.token) {
@@ -1148,18 +1149,22 @@ var chatCmd = new Command9("chat").description("Chat with an AI agent").argument
1148
1149
  updateConfig({ defaultSession: sessionId });
1149
1150
  }
1150
1151
  }
1152
+ const wsSessionId = randomUUID3();
1151
1153
  const wsProtocol = cfg.url.startsWith("https") ? "wss" : "ws";
1152
1154
  const wsHost = cfg.url.replace(/^https?:\/\//, "");
1153
- const wsUrl = `${wsProtocol}://${wsHost}/api/ws/${cfg.userId}/${encodeURIComponent(sessionId)}`;
1155
+ const wsUrl = `${wsProtocol}://${wsHost}/api/ws/${cfg.userId}/${wsSessionId}`;
1156
+ const timeoutMs = parseFloat(opts.timeout) * 1e3;
1154
1157
  if (interactive) {
1155
1158
  await runInteractive(wsUrl, sessionId, opts.agent, cfg.userId);
1159
+ } else if (opts.async) {
1160
+ await runAsync(wsUrl, sessionId, message, opts.agent);
1156
1161
  } else {
1157
1162
  await runSingleShot(
1158
1163
  wsUrl,
1159
1164
  sessionId,
1160
1165
  message,
1161
1166
  opts.agent,
1162
- parseInt(opts.timeout),
1167
+ timeoutMs,
1163
1168
  opts.stream !== false
1164
1169
  );
1165
1170
  }
@@ -1168,7 +1173,7 @@ var chatCmd = new Command9("chat").description("Chat with an AI agent").argument
1168
1173
  process.exit(1);
1169
1174
  }
1170
1175
  });
1171
- async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 12e4, stream = true) {
1176
+ async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 3e5, stream = true) {
1172
1177
  return new Promise((resolve, reject) => {
1173
1178
  let fullText = "";
1174
1179
  let streaming = false;
@@ -1239,6 +1244,44 @@ async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 12e4
1239
1244
  ws.connect();
1240
1245
  });
1241
1246
  }
1247
+ async function runAsync(wsUrl, sessionKey, message, agentId) {
1248
+ return new Promise((resolve, reject) => {
1249
+ const messageId = randomUUID3();
1250
+ const ws = new BotsChatWSClient({
1251
+ url: wsUrl,
1252
+ getToken,
1253
+ noReconnect: true,
1254
+ onStatusChange: async (connected) => {
1255
+ if (connected) {
1256
+ const msg = {
1257
+ type: "user.message",
1258
+ sessionKey,
1259
+ text: message,
1260
+ messageId
1261
+ };
1262
+ if (agentId) msg.targetAgentId = agentId;
1263
+ await ws.send(msg);
1264
+ if (isJsonMode()) {
1265
+ printJson({ sent: true, messageId, sessionKey });
1266
+ } else {
1267
+ console.log(`Message sent (id: ${messageId})`);
1268
+ }
1269
+ setTimeout(() => {
1270
+ ws.disconnect();
1271
+ resolve();
1272
+ }, 500);
1273
+ }
1274
+ },
1275
+ onMessage: () => {
1276
+ }
1277
+ });
1278
+ ws.connect();
1279
+ setTimeout(() => {
1280
+ ws.disconnect();
1281
+ reject(new Error("Timeout connecting to server"));
1282
+ }, 15e3);
1283
+ });
1284
+ }
1242
1285
  async function runInteractive(wsUrl, sessionKey, agentId, userId) {
1243
1286
  return new Promise((resolve) => {
1244
1287
  let streaming = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botschat/botschat",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "BotsChat channel plugin for OpenClaw — connects your OpenClaw agent to the BotsChat cloud platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",