crewaid-connect 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/bin.mjs +202 -79
  2. package/package.json +2 -2
package/dist/bin.mjs CHANGED
@@ -41,9 +41,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
41
41
  mod
42
42
  ));
43
43
 
44
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js
44
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js
45
45
  var require_constants = __commonJS({
46
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js"(exports, module) {
46
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js"(exports, module) {
47
47
  "use strict";
48
48
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
49
49
  var hasBlob = typeof Blob !== "undefined";
@@ -64,10 +64,11 @@ var require_constants = __commonJS({
64
64
  }
65
65
  });
66
66
 
67
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/buffer-util.js
67
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js
68
68
  var require_buffer_util = __commonJS({
69
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/buffer-util.js"(exports, module) {
69
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js"(exports, module) {
70
70
  "use strict";
71
+ var { websocketMask, websocketUnmask } = __require("http");
71
72
  var { EMPTY_BUFFER } = require_constants();
72
73
  var FastBuffer = Buffer[Symbol.species];
73
74
  function concat(list, totalLength) {
@@ -122,7 +123,16 @@ var require_buffer_util = __commonJS({
122
123
  toBuffer,
123
124
  unmask: _unmask
124
125
  };
125
- if (!process.env.WS_NO_BUFFER_UTIL) {
126
+ if (websocketMask) {
127
+ module.exports.mask = function(source, mask, output2, offset, length) {
128
+ if (length < 24) _mask(source, mask, output2, offset, length);
129
+ else websocketMask(source, mask, output2, offset, length);
130
+ };
131
+ module.exports.unmask = function(buffer, mask) {
132
+ if (buffer.length < 24) _unmask(buffer, mask);
133
+ else websocketUnmask(buffer, mask);
134
+ };
135
+ } else if (!process.env.WS_NO_BUFFER_UTIL) {
126
136
  try {
127
137
  const bufferUtil = __require("bufferutil");
128
138
  module.exports.mask = function(source, mask, output2, offset, length) {
@@ -139,9 +149,9 @@ var require_buffer_util = __commonJS({
139
149
  }
140
150
  });
141
151
 
142
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/limiter.js
152
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/limiter.js
143
153
  var require_limiter = __commonJS({
144
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/limiter.js"(exports, module) {
154
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/limiter.js"(exports, module) {
145
155
  "use strict";
146
156
  var kDone = /* @__PURE__ */ Symbol("kDone");
147
157
  var kRun = /* @__PURE__ */ Symbol("kRun");
@@ -189,9 +199,9 @@ var require_limiter = __commonJS({
189
199
  }
190
200
  });
191
201
 
192
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/permessage-deflate.js
202
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js
193
203
  var require_permessage_deflate = __commonJS({
194
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
204
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
195
205
  "use strict";
196
206
  var zlib = __require("zlib");
197
207
  var bufferUtil = require_buffer_util();
@@ -572,9 +582,9 @@ var require_permessage_deflate = __commonJS({
572
582
  }
573
583
  });
574
584
 
575
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/validation.js
585
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js
576
586
  var require_validation = __commonJS({
577
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/validation.js"(exports, module) {
587
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js"(exports, module) {
578
588
  "use strict";
579
589
  var { isUtf8 } = __require("buffer");
580
590
  var { hasBlob } = require_constants();
@@ -773,9 +783,9 @@ var require_validation = __commonJS({
773
783
  }
774
784
  });
775
785
 
776
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/receiver.js
786
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js
777
787
  var require_receiver = __commonJS({
778
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/receiver.js"(exports, module) {
788
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js"(exports, module) {
779
789
  "use strict";
780
790
  var { Writable } = __require("stream");
781
791
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -1185,6 +1195,7 @@ var require_receiver = __commonJS({
1185
1195
  unmask(data, this._mask);
1186
1196
  }
1187
1197
  }
1198
+ this._mask = void 0;
1188
1199
  if (this._opcode > 7) {
1189
1200
  this.controlMessage(data, cb);
1190
1201
  return;
@@ -1396,9 +1407,9 @@ var require_receiver = __commonJS({
1396
1407
  }
1397
1408
  });
1398
1409
 
1399
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/sender.js
1410
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js
1400
1411
  var require_sender = __commonJS({
1401
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/sender.js"(exports, module) {
1412
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js"(exports, module) {
1402
1413
  "use strict";
1403
1414
  var { Duplex } = __require("stream");
1404
1415
  var { randomFillSync } = __require("crypto");
@@ -1517,12 +1528,15 @@ var require_sender = __commonJS({
1517
1528
  target[2] = target[3] = 0;
1518
1529
  target.writeUIntBE(dataLength, 4, 6);
1519
1530
  }
1520
- if (!options.mask) return [target, data];
1531
+ if (!options.mask) {
1532
+ return dataLength ? [target, data] : [target];
1533
+ }
1521
1534
  target[1] |= 128;
1522
1535
  target[offset - 4] = mask[0];
1523
1536
  target[offset - 3] = mask[1];
1524
1537
  target[offset - 2] = mask[2];
1525
1538
  target[offset - 1] = mask[3];
1539
+ if (!dataLength) return [target];
1526
1540
  if (skipMasking) return [target, data];
1527
1541
  if (merge2) {
1528
1542
  applyMask(data, mask, target, offset, dataLength);
@@ -1889,9 +1903,9 @@ var require_sender = __commonJS({
1889
1903
  }
1890
1904
  });
1891
1905
 
1892
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/event-target.js
1906
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js
1893
1907
  var require_event_target = __commonJS({
1894
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/event-target.js"(exports, module) {
1908
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js"(exports, module) {
1895
1909
  "use strict";
1896
1910
  var { kForOnEventAttribute, kListener } = require_constants();
1897
1911
  var kCode = /* @__PURE__ */ Symbol("kCode");
@@ -2118,9 +2132,9 @@ var require_event_target = __commonJS({
2118
2132
  }
2119
2133
  });
2120
2134
 
2121
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/extension.js
2135
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js
2122
2136
  var require_extension = __commonJS({
2123
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/extension.js"(exports, module) {
2137
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js"(exports, module) {
2124
2138
  "use strict";
2125
2139
  var { tokenChars } = require_validation();
2126
2140
  function push(dest, name, elem) {
@@ -2271,14 +2285,15 @@ var require_extension = __commonJS({
2271
2285
  }
2272
2286
  });
2273
2287
 
2274
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket.js
2288
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js
2275
2289
  var require_websocket = __commonJS({
2276
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket.js"(exports, module) {
2290
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js"(exports, module) {
2277
2291
  "use strict";
2278
2292
  var EventEmitter = __require("events");
2279
2293
  var https = __require("https");
2280
2294
  var http = __require("http");
2281
2295
  var net = __require("net");
2296
+ var querystring = __require("querystring");
2282
2297
  var tls = __require("tls");
2283
2298
  var { randomBytes, createHash: createHash2 } = __require("crypto");
2284
2299
  var { Duplex, Readable } = __require("stream");
@@ -2336,21 +2351,38 @@ var require_websocket = __commonJS({
2336
2351
  this._isServer = false;
2337
2352
  this._redirects = 0;
2338
2353
  if (protocols === void 0) {
2339
- protocols = [];
2354
+ if (!options || options.protocols === void 0) {
2355
+ protocols = [];
2356
+ } else if (Array.isArray(options.protocols)) {
2357
+ protocols = options.protocols;
2358
+ } else {
2359
+ protocols = [options.protocols];
2360
+ }
2340
2361
  } else if (!Array.isArray(protocols)) {
2341
2362
  if (typeof protocols === "object" && protocols !== null) {
2342
2363
  options = protocols;
2343
- protocols = [];
2364
+ if (options.protocols === void 0) {
2365
+ protocols = [];
2366
+ } else if (Array.isArray(options.protocols)) {
2367
+ protocols = options.protocols;
2368
+ } else {
2369
+ protocols = [options.protocols];
2370
+ }
2344
2371
  } else {
2345
2372
  protocols = [protocols];
2346
2373
  }
2347
2374
  }
2348
- initAsClient(this, address, protocols, options);
2375
+ options = initAsClient(this, address, protocols, options);
2349
2376
  } else {
2350
- this._autoPong = options.autoPong;
2351
- this._closeTimeout = options.closeTimeout;
2352
2377
  this._isServer = true;
2353
2378
  }
2379
+ if (options.autoPong) {
2380
+ this._autoPong = true;
2381
+ this._autoPongComplete = () => autoPongComplete(this);
2382
+ this._pendingAutoPongs = 0;
2383
+ this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
2384
+ }
2385
+ this._closeTimeout = options.closeTimeout;
2354
2386
  }
2355
2387
  /**
2356
2388
  * For historical reasons, the custom "nodebuffer" type is used by the default
@@ -2537,7 +2569,6 @@ var require_websocket = __commonJS({
2537
2569
  }
2538
2570
  return;
2539
2571
  }
2540
- this._readyState = _WebSocket.CLOSING;
2541
2572
  this._sender.close(code, data, !this._isServer, (err) => {
2542
2573
  if (err) return;
2543
2574
  this._closeFrameSent = true;
@@ -2545,6 +2576,7 @@ var require_websocket = __commonJS({
2545
2576
  this._socket.end();
2546
2577
  }
2547
2578
  });
2579
+ this._readyState = _WebSocket.CLOSING;
2548
2580
  setCloseTimer(this);
2549
2581
  }
2550
2582
  /**
@@ -2761,6 +2793,7 @@ var require_websocket = __commonJS({
2761
2793
  maxBufferedChunks: 256 * 1024,
2762
2794
  maxFragments: 16 * 1024,
2763
2795
  maxPayload: 100 * 1024 * 1024,
2796
+ maxPendingAutoPongs: 60,
2764
2797
  skipUTF8Validation: false,
2765
2798
  perMessageDeflate: true,
2766
2799
  followRedirects: false,
@@ -2769,14 +2802,13 @@ var require_websocket = __commonJS({
2769
2802
  socketPath: void 0,
2770
2803
  hostname: void 0,
2771
2804
  protocol: void 0,
2805
+ protocols: void 0,
2772
2806
  timeout: void 0,
2773
2807
  method: "GET",
2774
2808
  host: void 0,
2775
2809
  path: void 0,
2776
2810
  port: void 0
2777
2811
  };
2778
- websocket._autoPong = opts.autoPong;
2779
- websocket._closeTimeout = opts.closeTimeout;
2780
2812
  if (!protocolVersions.includes(opts.protocolVersion)) {
2781
2813
  throw new RangeError(
2782
2814
  `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
@@ -2792,10 +2824,9 @@ var require_websocket = __commonJS({
2792
2824
  throw new SyntaxError(`Invalid URL: ${address}`);
2793
2825
  }
2794
2826
  }
2795
- if (parsedUrl.protocol === "http:") {
2796
- parsedUrl.protocol = "ws:";
2797
- } else if (parsedUrl.protocol === "https:") {
2798
- parsedUrl.protocol = "wss:";
2827
+ if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
2828
+ parsedUrl = new URL2(parsedUrl);
2829
+ parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
2799
2830
  }
2800
2831
  websocket._url = parsedUrl.href;
2801
2832
  const isSecure = parsedUrl.protocol === "wss:";
@@ -2864,12 +2895,19 @@ var require_websocket = __commonJS({
2864
2895
  }
2865
2896
  }
2866
2897
  if (parsedUrl.username || parsedUrl.password) {
2867
- opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
2898
+ const username = querystring.unescape(parsedUrl.username);
2899
+ const password = querystring.unescape(parsedUrl.password);
2900
+ opts.auth = `${username}:${password}`;
2868
2901
  }
2869
2902
  if (isIpcUrl) {
2870
- const parts = opts.path.split(":");
2871
- opts.socketPath = parts[0];
2872
- opts.path = parts[1];
2903
+ const i = opts.path.indexOf(":");
2904
+ if (i === -1) {
2905
+ opts.socketPath = opts.path;
2906
+ opts.path = "";
2907
+ } else {
2908
+ opts.socketPath = opts.path.slice(0, i);
2909
+ opts.path = opts.path.slice(i + 1);
2910
+ }
2873
2911
  }
2874
2912
  let req;
2875
2913
  if (opts.followRedirects) {
@@ -3013,6 +3051,7 @@ var require_websocket = __commonJS({
3013
3051
  } else {
3014
3052
  req.end();
3015
3053
  }
3054
+ return opts;
3016
3055
  }
3017
3056
  function emitErrorAndClose(websocket, err) {
3018
3057
  websocket._readyState = WebSocket2.CLOSING;
@@ -3064,8 +3103,13 @@ var require_websocket = __commonJS({
3064
3103
  function receiverOnConclude(code, reason) {
3065
3104
  const websocket = this[kWebSocket];
3066
3105
  websocket._closeFrameReceived = true;
3067
- websocket._closeMessage = reason;
3068
3106
  websocket._closeCode = code;
3107
+ if (reason.length === 0) {
3108
+ websocket._closeMessage = EMPTY_BUFFER;
3109
+ } else {
3110
+ websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
3111
+ websocket._closeMessage.set(reason);
3112
+ }
3069
3113
  if (websocket._socket[kWebSocket] === void 0) return;
3070
3114
  websocket._socket.removeListener("data", socketOnData);
3071
3115
  process.nextTick(resume, websocket._socket);
@@ -3096,9 +3140,19 @@ var require_websocket = __commonJS({
3096
3140
  }
3097
3141
  function receiverOnPing(data) {
3098
3142
  const websocket = this[kWebSocket];
3099
- if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
3143
+ if (websocket._autoPong && websocket.readyState === WebSocket2.OPEN) {
3144
+ if (websocket._maxPendingAutoPongs > 0 && websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs) {
3145
+ websocket.terminate();
3146
+ } else {
3147
+ websocket._pendingAutoPongs++;
3148
+ websocket.pong(data, !this._isServer, websocket._autoPongComplete);
3149
+ }
3150
+ }
3100
3151
  websocket.emit("ping", data);
3101
3152
  }
3153
+ function autoPongComplete(websocket) {
3154
+ websocket._pendingAutoPongs--;
3155
+ }
3102
3156
  function receiverOnPong(data) {
3103
3157
  this[kWebSocket].emit("pong", data);
3104
3158
  }
@@ -3167,9 +3221,9 @@ var require_websocket = __commonJS({
3167
3221
  }
3168
3222
  });
3169
3223
 
3170
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/stream.js
3224
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js
3171
3225
  var require_stream = __commonJS({
3172
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/stream.js"(exports, module) {
3226
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js"(exports, module) {
3173
3227
  "use strict";
3174
3228
  var WebSocket2 = require_websocket();
3175
3229
  var { Duplex } = __require("stream");
@@ -3265,9 +3319,9 @@ var require_stream = __commonJS({
3265
3319
  }
3266
3320
  });
3267
3321
 
3268
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/subprotocol.js
3322
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js
3269
3323
  var require_subprotocol = __commonJS({
3270
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/subprotocol.js"(exports, module) {
3324
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
3271
3325
  "use strict";
3272
3326
  var { tokenChars } = require_validation();
3273
3327
  function parse3(header) {
@@ -3310,9 +3364,9 @@ var require_subprotocol = __commonJS({
3310
3364
  }
3311
3365
  });
3312
3366
 
3313
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket-server.js
3367
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js
3314
3368
  var require_websocket_server = __commonJS({
3315
- "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket-server.js"(exports, module) {
3369
+ "../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
3316
3370
  "use strict";
3317
3371
  var EventEmitter = __require("events");
3318
3372
  var http = __require("http");
@@ -3352,6 +3406,8 @@ var require_websocket_server = __commonJS({
3352
3406
  * fragments
3353
3407
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3354
3408
  * size
3409
+ * @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
3410
+ * pending automatic pongs
3355
3411
  * @param {Boolean} [options.noServer=false] Enable no server mode
3356
3412
  * @param {String} [options.path] Accept only connections matching this path
3357
3413
  * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
@@ -3374,6 +3430,7 @@ var require_websocket_server = __commonJS({
3374
3430
  maxBufferedChunks: 256 * 1024,
3375
3431
  maxFragments: 16 * 1024,
3376
3432
  maxPayload: 100 * 1024 * 1024,
3433
+ maxPendingAutoPongs: 60,
3377
3434
  skipUTF8Validation: false,
3378
3435
  perMessageDeflate: false,
3379
3436
  handleProtocols: null,
@@ -28070,7 +28127,9 @@ var ProviderKindSchema = external_exports.enum([
28070
28127
  "custom",
28071
28128
  "crewaid",
28072
28129
  /** A speech key. It holds no models and never serves a turn. */
28073
- "elevenlabs"
28130
+ "elevenlabs",
28131
+ /** A Fish Audio speech key. It holds no models and never serves a turn. */
28132
+ "fish"
28074
28133
  ]);
28075
28134
  var CreatableProviderKindSchema = ProviderKindSchema.exclude(["crewaid"]);
28076
28135
  var ConnectionAuthKindSchema = external_exports.enum(["api_key"]);
@@ -28218,7 +28277,7 @@ var BotSchema = external_exports.object({
28218
28277
  * reading an older orchestrator sees the behaviour that orchestrator has.
28219
28278
  */
28220
28279
  approvalMode: ApprovalModeSchema.default("AUTO"),
28221
- /** The ElevenLabs voice this bot speaks in; null is the house voice. */
28280
+ /** This bot's voice on the server's current speech provider; null is that provider's house voice. */
28222
28281
  voiceId: external_exports.string().min(1).max(64).nullable().default(null),
28223
28282
  /**
28224
28283
  * The computer this bot works on. Null means detached — a bot that
@@ -29368,7 +29427,11 @@ var VoiceListResponseSchema = external_exports.object({
29368
29427
  voices: external_exports.array(VoiceOptionSchema),
29369
29428
  defaultVoiceId: external_exports.string().min(1).max(64)
29370
29429
  });
29371
- var VoiceStatusResponseSchema = external_exports.object({ configured: external_exports.boolean() });
29430
+ var VoiceProviderSchema = external_exports.enum(["elevenlabs", "fish"]);
29431
+ var VoiceStatusResponseSchema = external_exports.object({
29432
+ configured: external_exports.boolean(),
29433
+ provider: VoiceProviderSchema.default("elevenlabs")
29434
+ });
29372
29435
  var CallOverridesSchema = external_exports.object({
29373
29436
  prompt: external_exports.string().min(1).max(4e3),
29374
29437
  firstMessage: external_exports.string().min(1).max(200),
@@ -29376,11 +29439,37 @@ var CallOverridesSchema = external_exports.object({
29376
29439
  maxDurationSeconds: external_exports.number().int().positive(),
29377
29440
  language: external_exports.string().regex(/^[a-z]{2}(?:-[a-z]{2})?$/).optional()
29378
29441
  });
29442
+ var ElevenLabsCallLineSchema = external_exports.object({
29443
+ provider: external_exports.literal("elevenlabs"),
29444
+ signedUrl: external_exports.url({ protocol: /^wss$/ }),
29445
+ overrides: CallOverridesSchema
29446
+ });
29447
+ var FishCallSessionSchema = external_exports.object({
29448
+ session_id: external_exports.string().min(1).max(128),
29449
+ livekit_url: external_exports.url({ protocol: /^wss$/ }),
29450
+ token: external_exports.string().min(1).max(8192),
29451
+ expires_at: external_exports.string().min(1).max(64),
29452
+ max_duration_seconds: external_exports.number().int().positive(),
29453
+ transport: external_exports.literal("livekit")
29454
+ });
29455
+ var FishCallLineSchema = external_exports.object({
29456
+ provider: external_exports.literal("fish"),
29457
+ session: FishCallSessionSchema
29458
+ });
29459
+ var CallLineSchema = external_exports.discriminatedUnion("provider", [
29460
+ ElevenLabsCallLineSchema,
29461
+ FishCallLineSchema
29462
+ ]);
29379
29463
  var StartCallResponseSchema = external_exports.object({
29380
29464
  callId: CuidSchema,
29381
- signedUrl: external_exports.url({ protocol: /^wss$/ }),
29382
29465
  remainingSeconds: external_exports.number().int().nonnegative().nullable(),
29383
- overrides: CallOverridesSchema
29466
+ maxDurationSeconds: external_exports.number().int().positive().optional(),
29467
+ line: CallLineSchema.optional(),
29468
+ /** Legacy (one release, D-243): present on ElevenLabs lines for desktops that predate `line`. */
29469
+ signedUrl: external_exports.url({ protocol: /^wss$/ }).optional(),
29470
+ overrides: CallOverridesSchema.optional()
29471
+ }).refine((r) => r.line !== void 0 || r.signedUrl !== void 0 && r.overrides !== void 0, {
29472
+ message: "No call line"
29384
29473
  });
29385
29474
  var UpdateCallBodySchema = external_exports.object({
29386
29475
  conversationId: external_exports.string().min(1).max(128).optional(),
@@ -32282,7 +32371,7 @@ var WELCOME_COPIES = {
32282
32371
  import { execFile, spawn } from "node:child_process";
32283
32372
  import os from "node:os";
32284
32373
 
32285
- // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/wrapper.mjs
32374
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/wrapper.mjs
32286
32375
  var import_stream2 = __toESM(require_stream(), 1);
32287
32376
  var import_extension = __toESM(require_extension(), 1);
32288
32377
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -32460,11 +32549,15 @@ var ConnectorClient = class {
32460
32549
  activeTask = null;
32461
32550
  resolveDone;
32462
32551
  done;
32552
+ emitState(next) {
32553
+ this.options.onStateChange?.(next);
32554
+ }
32463
32555
  start() {
32464
32556
  if (this.stopped) return;
32557
+ this.emitState({ state: "connecting" });
32465
32558
  this.connect();
32466
32559
  }
32467
- stop(exitCode2 = 0) {
32560
+ stop(exitCode = 0) {
32468
32561
  if (this.stopped) return;
32469
32562
  this.stopped = true;
32470
32563
  clearTimeout(this.reconnectTimer);
@@ -32480,7 +32573,10 @@ var ConnectorClient = class {
32480
32573
  } catch {
32481
32574
  }
32482
32575
  }
32483
- this.resolveDone?.(exitCode2);
32576
+ if (exitCode === 0) {
32577
+ this.emitState({ state: "stopped" });
32578
+ }
32579
+ this.resolveDone?.(exitCode);
32484
32580
  }
32485
32581
  connect() {
32486
32582
  if (this.stopped) return;
@@ -32516,9 +32612,9 @@ var ConnectorClient = class {
32516
32612
  if (this.socket !== ws) return;
32517
32613
  const status = res.statusCode ?? 0;
32518
32614
  if (status === 401 || status === 403) {
32519
- this.log(
32520
- `Authentication failed (HTTP ${String(status)}). Check your connector token or rotate it in Crewaid Settings \u2192 Local harnesses.`
32521
- );
32615
+ const msg = `Authentication failed (HTTP ${String(status)}). Check your connector token or rotate it in Crewaid Settings \u2192 Local harnesses.`;
32616
+ this.log(msg);
32617
+ this.emitState({ state: "error", error: msg, permanent: true });
32522
32618
  this.stop(1);
32523
32619
  } else {
32524
32620
  this.log(`Server rejected WebSocket upgrade (HTTP ${String(status)}); retrying\u2026`);
@@ -32536,13 +32632,14 @@ var ConnectorClient = class {
32536
32632
  const reason = reasonBuf.toString("utf8");
32537
32633
  if (PERMANENT_CLOSE_CODES.has(code)) {
32538
32634
  const guidance = code === 4003 ? "Please update crewaid-connect to the latest version (npx crewaid-connect@latest)." : "Token was rotated or connector was revoked in Crewaid Settings.";
32539
- this.log(
32540
- `Disconnected permanently (${String(code)}${reason ? `: ${reason}` : ""}). ${guidance}`
32541
- );
32635
+ const msg = `Disconnected permanently (${String(code)}${reason ? `: ${reason}` : ""}). ${guidance}`;
32636
+ this.log(msg);
32637
+ this.emitState({ state: "error", error: msg, permanent: true });
32542
32638
  this.stop(1);
32543
32639
  return;
32544
32640
  }
32545
32641
  this.log(`Disconnected (${String(code)}${reason ? `: ${reason}` : ""}). Reconnecting\u2026`);
32642
+ this.emitState({ state: "reconnecting" });
32546
32643
  this.armDisconnectGraceIfBusy();
32547
32644
  this.scheduleReconnect();
32548
32645
  });
@@ -32623,11 +32720,13 @@ var ConnectorClient = class {
32623
32720
  task.abortController.abort();
32624
32721
  }
32625
32722
  }
32723
+ this.emitState({ state: this.activeTask !== null ? "busy" : "online" });
32626
32724
  return;
32627
32725
  }
32628
32726
  case "connector.error": {
32629
32727
  this.log(`Server error (${frame.code}): ${frame.message}`);
32630
32728
  if (frame.code === "CLI_OUTDATED" || frame.code === "UNAUTHORIZED") {
32729
+ this.emitState({ state: "error", error: frame.message, permanent: true });
32631
32730
  this.stop(1);
32632
32731
  }
32633
32732
  return;
@@ -32705,6 +32804,7 @@ var ConnectorClient = class {
32705
32804
  pendingResult: void 0
32706
32805
  };
32707
32806
  this.activeTask = task;
32807
+ this.emitState({ state: "busy" });
32708
32808
  try {
32709
32809
  if (this.lastConnectorId !== void 0) {
32710
32810
  const computed = computeLocalTaskPayloadHash({
@@ -32792,7 +32892,7 @@ var ConnectorClient = class {
32792
32892
  }
32793
32893
  const child = spawn(resolvedCmd.command, [...resolvedCmd.args], {
32794
32894
  cwd: confined.absoluteCwd,
32795
- env: harnessEnvironment(process.env),
32895
+ env: harnessEnvironment(this.options.baseEnv ?? process.env),
32796
32896
  stdio: ["pipe", "pipe", "pipe"],
32797
32897
  shell: false
32798
32898
  });
@@ -32874,6 +32974,9 @@ Verification command to run before finishing: ${frame.verifyCommand}`;
32874
32974
  clearTimeout(task.graceTimer);
32875
32975
  this.activeTask = null;
32876
32976
  }
32977
+ if (!this.stopped && this.activeTask === null && this.socket?.readyState === WS_OPEN) {
32978
+ this.emitState({ state: "online" });
32979
+ }
32877
32980
  }
32878
32981
  }
32879
32982
  lastConnectorId;
@@ -33208,14 +33311,17 @@ function promptHiddenToken(options = {}) {
33208
33311
 
33209
33312
  // src/cli.ts
33210
33313
  function cliVersion() {
33211
- return true ? "0.1.6" : "0.0.0-dev";
33314
+ return true ? "0.1.7" : "0.0.0-dev";
33212
33315
  }
33213
33316
  var HELP_TEXT = `crewaid-connect \u2014 Connect a local repository and ACP coding harness to Crewaid
33214
33317
 
33215
33318
  Usage:
33216
- crewaid-connect <dir> --url <server-url> [options]
33319
+ crewaid-connect [dir] --url <server-url> [options]
33217
33320
  crewaid-connect harnesses
33218
33321
 
33322
+ Arguments:
33323
+ dir Repository directory to share (default: current directory ".")
33324
+
33219
33325
  Options:
33220
33326
  --url <url> Crewaid server URL (required)
33221
33327
  --save Save bearer token to ~/.config/crewaid/connectors.json (0600)
@@ -33335,15 +33441,12 @@ function parseCliArgs(argv) {
33335
33441
  break;
33336
33442
  }
33337
33443
  }
33338
- if (dir === void 0) {
33339
- throw new Error("Missing target directory. Usage: crewaid-connect <dir> --url <server-url>");
33340
- }
33341
33444
  if (url2 === void 0) {
33342
33445
  throw new Error("Missing --url <server-url>.");
33343
33446
  }
33344
33447
  return {
33345
33448
  kind: "connect",
33346
- dir,
33449
+ dir: dir ?? ".",
33347
33450
  url: normalizeServerUrl(url2),
33348
33451
  save,
33349
33452
  tokenStdin,
@@ -33356,12 +33459,18 @@ function parseCliArgs(argv) {
33356
33459
  verbose
33357
33460
  };
33358
33461
  }
33359
- var HARNESS_INSTALL_HINTS = {
33360
- "claude-code": "npm install -g @agentclientprotocol/claude-agent-acp (requires Node >= 22)",
33361
- codex: "Install codex-acp on PATH (requires Node >= 22)",
33362
- opencode: "Install OpenCode (provides `opencode acp`)",
33363
- antigravity: "Install Google Antigravity CLI (provides `agy acp`)"
33364
- };
33462
+ function harnessInstallHint(id2, platform = process.platform) {
33463
+ switch (id2) {
33464
+ case "claude-code":
33465
+ return "npm install -g @agentclientprotocol/claude-agent-acp (requires Node >= 22)";
33466
+ case "codex":
33467
+ return "npm install -g @agentclientprotocol/codex-acp (requires Node >= 22)";
33468
+ case "opencode":
33469
+ return platform === "win32" ? "npm install -g opencode-ai" : "curl -fsSL https://opencode.ai/install | bash";
33470
+ case "antigravity":
33471
+ return platform === "win32" ? "irm https://antigravity.google/cli/install.ps1 | iex" : "curl -fsSL https://antigravity.google/cli/install.sh | bash";
33472
+ }
33473
+ }
33365
33474
  function formatHarnessesTable() {
33366
33475
  const detected = new Map(detectInstalledHarnesses().map((entry) => [entry.id, entry]));
33367
33476
  const lines = ["Detected local ACP coding harnesses:", ""];
@@ -33371,7 +33480,7 @@ function formatHarnessesTable() {
33371
33480
  const status = hit !== void 0 ? `installed (${hit.resolvedPath})` : "not found";
33372
33481
  lines.push(` - ${id2.padEnd(12)} ${preset.label.padEnd(14)} ${status}`);
33373
33482
  if (hit === void 0) {
33374
- lines.push(` Install: ${HARNESS_INSTALL_HINTS[id2]}`);
33483
+ lines.push(` Install: ${harnessInstallHint(id2)}`);
33375
33484
  }
33376
33485
  }
33377
33486
  lines.push("", 'Custom harnesses are also supported via --cmd "<binary> [args...]".');
@@ -33401,7 +33510,14 @@ async function runCli(argv) {
33401
33510
  `);
33402
33511
  return 0;
33403
33512
  }
33404
- const workspace = resolveWorkspaceRoot(command.dir);
33513
+ let workspace;
33514
+ try {
33515
+ workspace = resolveWorkspaceRoot(command.dir);
33516
+ } catch (error62) {
33517
+ process.stderr.write(`Error: ${error62 instanceof Error ? error62.message : String(error62)}
33518
+ `);
33519
+ return 1;
33520
+ }
33405
33521
  const detected = detectInstalledHarnesses();
33406
33522
  const availableBuiltins = detected.map((h) => h.id);
33407
33523
  const allDetected = [
@@ -33477,12 +33593,19 @@ async function runCli(argv) {
33477
33593
  `
33478
33594
  );
33479
33595
  client2.start();
33480
- const exitCode2 = await client2.done;
33596
+ const exitCode = await client2.done;
33481
33597
  process.off("SIGINT", onSignal);
33482
33598
  process.off("SIGTERM", onSignal);
33483
- return exitCode2;
33599
+ return exitCode;
33484
33600
  }
33485
33601
 
33486
33602
  // src/bin.ts
33487
- var exitCode = await runCli(process.argv.slice(2));
33488
- process.exit(exitCode);
33603
+ try {
33604
+ const exitCode = await runCli(process.argv.slice(2));
33605
+ process.exit(exitCode);
33606
+ } catch (error62) {
33607
+ const message = error62 instanceof Error ? error62.message : String(error62);
33608
+ process.stderr.write(`Error: ${message}
33609
+ `);
33610
+ process.exit(1);
33611
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crewaid-connect",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Connect a local repository and ACP coding harness (Claude Code, Codex, OpenCode, Antigravity) to Crewaid.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "esbuild": "0.28.2",
35
35
  "typescript": "5.9.3",
36
36
  "vitest": "4.1.11",
37
- "ws": "8.21.3",
37
+ "ws": "8.23.0",
38
38
  "zod": "4.6.6"
39
39
  }
40
40
  }