@botschat/botschat 0.1.22 → 0.1.23

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) {
@@ -1151,15 +1152,18 @@ var chatCmd = new Command9("chat").description("Chat with an AI agent").argument
1151
1152
  const wsProtocol = cfg.url.startsWith("https") ? "wss" : "ws";
1152
1153
  const wsHost = cfg.url.replace(/^https?:\/\//, "");
1153
1154
  const wsUrl = `${wsProtocol}://${wsHost}/api/ws/${cfg.userId}/${encodeURIComponent(sessionId)}`;
1155
+ const timeoutMs = parseFloat(opts.timeout) * 1e3;
1154
1156
  if (interactive) {
1155
1157
  await runInteractive(wsUrl, sessionId, opts.agent, cfg.userId);
1158
+ } else if (opts.async) {
1159
+ await runAsync(wsUrl, sessionId, message, opts.agent);
1156
1160
  } else {
1157
1161
  await runSingleShot(
1158
1162
  wsUrl,
1159
1163
  sessionId,
1160
1164
  message,
1161
1165
  opts.agent,
1162
- parseInt(opts.timeout),
1166
+ timeoutMs,
1163
1167
  opts.stream !== false
1164
1168
  );
1165
1169
  }
@@ -1168,7 +1172,7 @@ var chatCmd = new Command9("chat").description("Chat with an AI agent").argument
1168
1172
  process.exit(1);
1169
1173
  }
1170
1174
  });
1171
- async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 12e4, stream = true) {
1175
+ async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 3e5, stream = true) {
1172
1176
  return new Promise((resolve, reject) => {
1173
1177
  let fullText = "";
1174
1178
  let streaming = false;
@@ -1239,6 +1243,44 @@ async function runSingleShot(wsUrl, sessionKey, message, agentId, timeout = 12e4
1239
1243
  ws.connect();
1240
1244
  });
1241
1245
  }
1246
+ async function runAsync(wsUrl, sessionKey, message, agentId) {
1247
+ return new Promise((resolve, reject) => {
1248
+ const messageId = randomUUID3();
1249
+ const ws = new BotsChatWSClient({
1250
+ url: wsUrl,
1251
+ getToken,
1252
+ noReconnect: true,
1253
+ onStatusChange: async (connected) => {
1254
+ if (connected) {
1255
+ const msg = {
1256
+ type: "user.message",
1257
+ sessionKey,
1258
+ text: message,
1259
+ messageId
1260
+ };
1261
+ if (agentId) msg.targetAgentId = agentId;
1262
+ await ws.send(msg);
1263
+ if (isJsonMode()) {
1264
+ printJson({ sent: true, messageId, sessionKey });
1265
+ } else {
1266
+ console.log(`Message sent (id: ${messageId})`);
1267
+ }
1268
+ setTimeout(() => {
1269
+ ws.disconnect();
1270
+ resolve();
1271
+ }, 500);
1272
+ }
1273
+ },
1274
+ onMessage: () => {
1275
+ }
1276
+ });
1277
+ ws.connect();
1278
+ setTimeout(() => {
1279
+ ws.disconnect();
1280
+ reject(new Error("Timeout connecting to server"));
1281
+ }, 15e3);
1282
+ });
1283
+ }
1242
1284
  async function runInteractive(wsUrl, sessionKey, agentId, userId) {
1243
1285
  return new Promise((resolve) => {
1244
1286
  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.23",
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",