@blade-hq/agent-client 2612.0.0-beta.2 → 2612.0.0-beta.21

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 (92) hide show
  1. package/README.md +203 -19
  2. package/dist/blade-client.d.ts +13 -1
  3. package/dist/{chunk-PWJJJATA.js → chunk-J3XXTHHK.js} +1723 -701
  4. package/dist/chunk-J3XXTHHK.js.map +1 -0
  5. package/dist/index.d.ts +12 -3
  6. package/dist/index.js +9 -1
  7. package/dist/internal.d.ts +9 -3
  8. package/dist/internal.js +13 -1
  9. package/dist/internal.js.map +1 -1
  10. package/dist/resources/auth.d.ts +3 -1
  11. package/dist/resources/chat-groups.d.ts +92 -0
  12. package/dist/resources/headless.d.ts +5 -0
  13. package/dist/resources/models.d.ts +6 -1
  14. package/dist/resources/plugins.d.ts +1 -0
  15. package/dist/resources/sessions.d.ts +96 -11
  16. package/dist/schemas/context-attachments.d.ts +16 -0
  17. package/dist/schemas/event.d.ts +2 -0
  18. package/dist/schemas/message-utils.d.ts +3 -9
  19. package/dist/schemas/message.d.ts +18 -1
  20. package/dist/schemas/plugin-refs.d.ts +15 -0
  21. package/dist/schemas/projection.d.ts +31 -0
  22. package/dist/schemas/session.d.ts +2 -42
  23. package/dist/schemas/topic-assets.d.ts +7 -0
  24. package/dist/server-clock.d.ts +2 -0
  25. package/dist/session/agent-session.d.ts +51 -7
  26. package/dist/session/background.d.ts +14 -0
  27. package/dist/session/events.d.ts +0 -1
  28. package/dist/session/hub.d.ts +3 -0
  29. package/dist/session/log-cursor.d.ts +14 -0
  30. package/dist/session/state.d.ts +2 -1
  31. package/dist/session/workflow.d.ts +10 -3
  32. package/dist/shared/projection/builder.d.ts +5 -0
  33. package/dist/shared/projection/helpers.d.ts +2 -0
  34. package/dist/shared/projection/index.d.ts +1 -0
  35. package/dist/shared/projection/workflow.d.ts +24 -0
  36. package/dist/tool-provider.d.ts +51 -0
  37. package/dist/types/socket-events.d.ts +179 -6
  38. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +2 -3
  39. package/node_modules/engine.io-client/build/cjs/index.d.ts +3 -3
  40. package/node_modules/engine.io-client/build/cjs/index.js +1 -4
  41. package/node_modules/engine.io-client/build/cjs/socket.d.ts +39 -82
  42. package/node_modules/engine.io-client/build/cjs/socket.js +151 -218
  43. package/node_modules/engine.io-client/build/cjs/transport.d.ts +1 -1
  44. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +4 -4
  45. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +2 -2
  46. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +17 -7
  47. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +17 -7
  48. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +2 -3
  49. package/node_modules/engine.io-client/build/esm/index.d.ts +3 -3
  50. package/node_modules/engine.io-client/build/esm/index.js +1 -2
  51. package/node_modules/engine.io-client/build/esm/socket.d.ts +39 -82
  52. package/node_modules/engine.io-client/build/esm/socket.js +141 -206
  53. package/node_modules/engine.io-client/build/esm/transport.d.ts +1 -1
  54. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +4 -4
  55. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +2 -2
  56. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +2 -3
  57. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +3 -3
  58. package/node_modules/engine.io-client/build/esm-debug/index.js +1 -2
  59. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +39 -82
  60. package/node_modules/engine.io-client/build/esm-debug/socket.js +150 -215
  61. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +1 -1
  62. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +4 -4
  63. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +2 -2
  64. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +3 -3
  65. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -1
  66. package/node_modules/engine.io-client/dist/engine.io.js +164 -239
  67. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -1
  68. package/node_modules/engine.io-client/dist/engine.io.min.js +3 -3
  69. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -1
  70. package/node_modules/engine.io-client/package.json +2 -2
  71. package/node_modules/socket.io-parser/build/cjs/binary.js +4 -1
  72. package/node_modules/socket.io-parser/build/cjs/index.d.ts +14 -4
  73. package/node_modules/socket.io-parser/build/cjs/index.js +18 -11
  74. package/node_modules/socket.io-parser/build/esm/binary.js +4 -1
  75. package/node_modules/socket.io-parser/build/esm/index.d.ts +14 -4
  76. package/node_modules/socket.io-parser/build/esm/index.js +14 -10
  77. package/node_modules/socket.io-parser/build/esm-debug/binary.js +4 -1
  78. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +14 -4
  79. package/node_modules/socket.io-parser/build/esm-debug/index.js +14 -10
  80. package/node_modules/socket.io-parser/package.json +1 -1
  81. package/node_modules/ws/index.js +15 -6
  82. package/node_modules/ws/lib/constants.js +1 -0
  83. package/node_modules/ws/lib/permessage-deflate.js +9 -7
  84. package/node_modules/ws/lib/receiver.js +37 -0
  85. package/node_modules/ws/lib/sender.js +6 -1
  86. package/node_modules/ws/lib/websocket-server.js +18 -6
  87. package/node_modules/ws/lib/websocket.js +50 -17
  88. package/node_modules/ws/package.json +8 -3
  89. package/node_modules/ws/wrapper.mjs +14 -1
  90. package/package.json +4 -4
  91. package/public-api.md +335 -28
  92. package/dist/chunk-PWJJJATA.js.map +0 -1
@@ -18,6 +18,7 @@ const { isBlob } = require('./validation');
18
18
 
19
19
  const {
20
20
  BINARY_TYPES,
21
+ CLOSE_TIMEOUT,
21
22
  EMPTY_BUFFER,
22
23
  GUID,
23
24
  kForOnEventAttribute,
@@ -32,7 +33,6 @@ const {
32
33
  const { format, parse } = require('./extension');
33
34
  const { toBuffer } = require('./buffer-util');
34
35
 
35
- const closeTimeout = 30 * 1000;
36
36
  const kAborted = Symbol('kAborted');
37
37
  const protocolVersions = [8, 13];
38
38
  const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
@@ -75,11 +75,24 @@ class WebSocket extends EventEmitter {
75
75
  this._redirects = 0;
76
76
 
77
77
  if (protocols === undefined) {
78
- protocols = [];
78
+ if (!options || options.protocols === undefined) {
79
+ protocols = [];
80
+ } else if (Array.isArray(options.protocols)) {
81
+ protocols = options.protocols;
82
+ } else {
83
+ protocols = [options.protocols];
84
+ }
79
85
  } else if (!Array.isArray(protocols)) {
80
86
  if (typeof protocols === 'object' && protocols !== null) {
81
87
  options = protocols;
82
- protocols = [];
88
+
89
+ if (options.protocols === undefined) {
90
+ protocols = [];
91
+ } else if (Array.isArray(options.protocols)) {
92
+ protocols = options.protocols;
93
+ } else {
94
+ protocols = [options.protocols];
95
+ }
83
96
  } else {
84
97
  protocols = [protocols];
85
98
  }
@@ -88,6 +101,7 @@ class WebSocket extends EventEmitter {
88
101
  initAsClient(this, address, protocols, options);
89
102
  } else {
90
103
  this._autoPong = options.autoPong;
104
+ this._closeTimeout = options.closeTimeout;
91
105
  this._isServer = true;
92
106
  }
93
107
  }
@@ -200,6 +214,10 @@ class WebSocket extends EventEmitter {
200
214
  * multiple times in the same tick
201
215
  * @param {Function} [options.generateMask] The function used to generate the
202
216
  * masking key
217
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
218
+ * buffered data chunks
219
+ * @param {Number} [options.maxFragments=0] The maximum number of message
220
+ * fragments
203
221
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
204
222
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
205
223
  * not to skip UTF-8 validation for text and close messages
@@ -211,6 +229,8 @@ class WebSocket extends EventEmitter {
211
229
  binaryType: this.binaryType,
212
230
  extensions: this._extensions,
213
231
  isServer: this._isServer,
232
+ maxBufferedChunks: options.maxBufferedChunks,
233
+ maxFragments: options.maxFragments,
214
234
  maxPayload: options.maxPayload,
215
235
  skipUTF8Validation: options.skipUTF8Validation
216
236
  });
@@ -311,7 +331,6 @@ class WebSocket extends EventEmitter {
311
331
  return;
312
332
  }
313
333
 
314
- this._readyState = WebSocket.CLOSING;
315
334
  this._sender.close(code, data, !this._isServer, (err) => {
316
335
  //
317
336
  // This error is handled by the `'error'` listener on the socket. We only
@@ -329,6 +348,7 @@ class WebSocket extends EventEmitter {
329
348
  }
330
349
  });
331
350
 
351
+ this._readyState = WebSocket.CLOSING;
332
352
  setCloseTimer(this);
333
353
  }
334
354
 
@@ -629,6 +649,8 @@ module.exports = WebSocket;
629
649
  * times in the same tick
630
650
  * @param {Boolean} [options.autoPong=true] Specifies whether or not to
631
651
  * automatically send a pong in response to a ping
652
+ * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait
653
+ * for the closing handshake to finish after `websocket.close()` is called
632
654
  * @param {Function} [options.finishRequest] A function which can be used to
633
655
  * customize the headers of each http request before it is sent
634
656
  * @param {Boolean} [options.followRedirects=false] Whether or not to follow
@@ -637,6 +659,10 @@ module.exports = WebSocket;
637
659
  * masking key
638
660
  * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
639
661
  * handshake request
662
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
663
+ * buffered data chunks
664
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
665
+ * fragments
640
666
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
641
667
  * size
642
668
  * @param {Number} [options.maxRedirects=10] The maximum number of redirects
@@ -655,7 +681,10 @@ function initAsClient(websocket, address, protocols, options) {
655
681
  const opts = {
656
682
  allowSynchronousEvents: true,
657
683
  autoPong: true,
684
+ closeTimeout: CLOSE_TIMEOUT,
658
685
  protocolVersion: protocolVersions[1],
686
+ maxBufferedChunks: 256 * 1024,
687
+ maxFragments: 16 * 1024,
659
688
  maxPayload: 100 * 1024 * 1024,
660
689
  skipUTF8Validation: false,
661
690
  perMessageDeflate: true,
@@ -665,6 +694,7 @@ function initAsClient(websocket, address, protocols, options) {
665
694
  socketPath: undefined,
666
695
  hostname: undefined,
667
696
  protocol: undefined,
697
+ protocols: undefined,
668
698
  timeout: undefined,
669
699
  method: 'GET',
670
700
  host: undefined,
@@ -673,6 +703,7 @@ function initAsClient(websocket, address, protocols, options) {
673
703
  };
674
704
 
675
705
  websocket._autoPong = opts.autoPong;
706
+ websocket._closeTimeout = opts.closeTimeout;
676
707
 
677
708
  if (!protocolVersions.includes(opts.protocolVersion)) {
678
709
  throw new RangeError(
@@ -688,7 +719,7 @@ function initAsClient(websocket, address, protocols, options) {
688
719
  } else {
689
720
  try {
690
721
  parsedUrl = new URL(address);
691
- } catch (e) {
722
+ } catch {
692
723
  throw new SyntaxError(`Invalid URL: ${address}`);
693
724
  }
694
725
  }
@@ -750,11 +781,11 @@ function initAsClient(websocket, address, protocols, options) {
750
781
  opts.timeout = opts.handshakeTimeout;
751
782
 
752
783
  if (opts.perMessageDeflate) {
753
- perMessageDeflate = new PerMessageDeflate(
754
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
755
- false,
756
- opts.maxPayload
757
- );
784
+ perMessageDeflate = new PerMessageDeflate({
785
+ ...opts.perMessageDeflate,
786
+ isServer: false,
787
+ maxPayload: opts.maxPayload
788
+ });
758
789
  opts.headers['Sec-WebSocket-Extensions'] = format({
759
790
  [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
760
791
  });
@@ -1012,6 +1043,8 @@ function initAsClient(websocket, address, protocols, options) {
1012
1043
  websocket.setSocket(socket, head, {
1013
1044
  allowSynchronousEvents: opts.allowSynchronousEvents,
1014
1045
  generateMask: opts.generateMask,
1046
+ maxBufferedChunks: opts.maxBufferedChunks,
1047
+ maxFragments: opts.maxFragments,
1015
1048
  maxPayload: opts.maxPayload,
1016
1049
  skipUTF8Validation: opts.skipUTF8Validation
1017
1050
  });
@@ -1290,7 +1323,7 @@ function senderOnError(err) {
1290
1323
  function setCloseTimer(websocket) {
1291
1324
  websocket._closeTimer = setTimeout(
1292
1325
  websocket._socket.destroy.bind(websocket._socket),
1293
- closeTimeout
1326
+ websocket._closeTimeout
1294
1327
  );
1295
1328
  }
1296
1329
 
@@ -1308,23 +1341,23 @@ function socketOnClose() {
1308
1341
 
1309
1342
  websocket._readyState = WebSocket.CLOSING;
1310
1343
 
1311
- let chunk;
1312
-
1313
1344
  //
1314
1345
  // The close frame might not have been received or the `'end'` event emitted,
1315
1346
  // for example, if the socket was destroyed due to an error. Ensure that the
1316
1347
  // `receiver` stream is closed after writing any remaining buffered data to
1317
1348
  // it. If the readable side of the socket is in flowing mode then there is no
1318
- // buffered data as everything has been already written and `readable.read()`
1319
- // will return `null`. If instead, the socket is paused, any possible buffered
1320
- // data will be read as a single chunk.
1349
+ // buffered data as everything has been already written. If instead, the
1350
+ // socket is paused, any possible buffered data will be read as a single
1351
+ // chunk.
1321
1352
  //
1322
1353
  if (
1323
1354
  !this._readableState.endEmitted &&
1324
1355
  !websocket._closeFrameReceived &&
1325
1356
  !websocket._receiver._writableState.errorEmitted &&
1326
- (chunk = websocket._socket.read()) !== null
1357
+ this._readableState.length !== 0
1327
1358
  ) {
1359
+ const chunk = this.read(this._readableState.length);
1360
+
1328
1361
  websocket._receiver.write(chunk);
1329
1362
  }
1330
1363
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws",
3
- "version": "8.18.3",
3
+ "version": "8.22.0",
4
4
  "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
5
  "keywords": [
6
6
  "HyBi",
@@ -55,15 +55,20 @@
55
55
  }
56
56
  },
57
57
  "devDependencies": {
58
+ "@eslint/js": "^10.0.1",
58
59
  "benchmark": "^2.1.4",
59
60
  "bufferutil": "^4.0.1",
60
- "eslint": "^9.0.0",
61
+ "eslint": "^10.0.1",
61
62
  "eslint-config-prettier": "^10.0.1",
62
63
  "eslint-plugin-prettier": "^5.0.0",
63
- "globals": "^16.0.0",
64
+ "globals": "^17.0.0",
64
65
  "mocha": "^8.4.0",
65
66
  "nyc": "^15.0.0",
66
67
  "prettier": "^3.0.0",
67
68
  "utf-8-validate": "^6.0.0"
69
+ },
70
+ "allowScripts": {
71
+ "bufferutil": true,
72
+ "utf-8-validate": true
68
73
  }
69
74
  }
@@ -1,8 +1,21 @@
1
1
  import createWebSocketStream from './lib/stream.js';
2
+ import extension from './lib/extension.js';
3
+ import PerMessageDeflate from './lib/permessage-deflate.js';
2
4
  import Receiver from './lib/receiver.js';
3
5
  import Sender from './lib/sender.js';
6
+ import subprotocol from './lib/subprotocol.js';
4
7
  import WebSocket from './lib/websocket.js';
5
8
  import WebSocketServer from './lib/websocket-server.js';
6
9
 
7
- export { createWebSocketStream, Receiver, Sender, WebSocket, WebSocketServer };
10
+ export {
11
+ createWebSocketStream,
12
+ extension,
13
+ PerMessageDeflate,
14
+ Receiver,
15
+ Sender,
16
+ subprotocol,
17
+ WebSocket,
18
+ WebSocketServer
19
+ };
20
+
8
21
  export default WebSocket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blade-hq/agent-client",
3
- "version": "2612.0.0-beta.2",
3
+ "version": "2612.0.0-beta.21",
4
4
  "description": "Blade Agent 框架无关客户端:会话实时状态机、REST 通道、弹窗登录、页面协作。浏览器与 Node.js 通用。",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,11 +41,11 @@
41
41
  "@socket.io/component-emitter": "3.1.2",
42
42
  "debug": "4.4.3",
43
43
  "ms": "2.1.3",
44
- "engine.io-client": "6.6.4",
44
+ "engine.io-client": "6.6.7",
45
45
  "engine.io-parser": "5.2.3",
46
- "ws": "8.18.3",
46
+ "ws": "8.22.0",
47
47
  "xmlhttprequest-ssl": "2.1.2",
48
- "socket.io-parser": "4.2.5"
48
+ "socket.io-parser": "4.2.7"
49
49
  },
50
50
  "bundledDependencies": [
51
51
  "@ark/schema",