@awarevue/agent-sdk 2.0.78 → 2.0.79

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.
@@ -13,6 +13,11 @@ export type Inbound<D extends Direction> = D extends 'server' ? FromAgent : From
13
13
  export type Outbound<D extends Direction> = D extends 'server' ? FromServer : FromAgent;
14
14
  export type InMsg<D extends Direction> = Message<Inbound<D>>;
15
15
  export type OutMsg<D extends Direction> = Message<Outbound<D>>;
16
+ export interface GetReplyOptions {
17
+ /** Timeout for awaiting replies to sent messages (default 10s) */
18
+ timeoutMs?: number;
19
+ onProgress?: (progress: Message<PayloadByKind['progress']>) => void;
20
+ }
16
21
  export interface AgentProtocolOptions {
17
22
  /** Timeout for awaiting replies to sent messages (default 10s) */
18
23
  replyTimeout?: number;
@@ -27,6 +32,6 @@ export declare class AgentProtocol<D extends Direction> {
27
32
  constructor(transport: DuplexTransport<Message<Inbound<D>>, Message<Outbound<D>>>, options: AgentProtocolOptions);
28
33
  getReply$: <K extends RequestKind>(payload: Extract<Outbound<D>, {
29
34
  kind: K;
30
- }>, timeoutMs?: number) => Observable<Message<PayloadByKind[ResponseKind<K>]>>;
35
+ }>, { timeoutMs, onProgress }?: GetReplyOptions) => Observable<Message<PayloadByKind[ResponseKind<K>]>>;
31
36
  send: (payload: Outbound<D>) => void;
32
37
  }
@@ -15,7 +15,7 @@ class AgentProtocol {
15
15
  version: constants_1.AGENT_PROTOCOL_VERSION,
16
16
  on: Date.now(),
17
17
  });
18
- this.getReply$ = (payload, timeoutMs) => {
18
+ this.getReply$ = (payload, { timeoutMs, onProgress } = {}) => {
19
19
  const responseKind = api_types_1.ReplyKindByRequestKind[payload.kind];
20
20
  const reply$ = (id) => this.transport.messages$.pipe(
21
21
  // pass through only messages with matching requestId (it could be response, error or progress update)
@@ -29,6 +29,12 @@ class AgentProtocol {
29
29
  }),
30
30
  // enforce timeout (progress updates will reset the timer, but if no messages arrive for `timeoutMs` duration, the request is considered failed)
31
31
  (0, rxjs_1.timeout)(timeoutMs || this.options.replyTimeout || 10000),
32
+ // if an onProgress callback was provided, tap into the stream to route progress updates to the callback
33
+ (0, rxjs_1.tap)((message) => {
34
+ if (message.kind === 'progress' && onProgress) {
35
+ onProgress(message);
36
+ }
37
+ }),
32
38
  // pass through only the final response message (filter out progress updates)
33
39
  (0, rxjs_1.filter)((message) => message.kind === responseKind),
34
40
  // we only expect one response message, so complete the stream after the response arrives
package/dist/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/Linc-Security-Systems/aware-essentials.git"
6
6
  },
7
- "version": "2.0.78",
7
+ "version": "2.0.79",
8
8
  "description": "SDK for building Agent implementations that speak the agent protocol.",
9
9
  "author": "Yaser Awajan",
10
10
  "license": "MIT",
@@ -31,12 +31,12 @@
31
31
  "lint:fix": "yarn lint --fix"
32
32
  },
33
33
  "peerDependencies": {
34
- "@awarevue/api-types": "2.0.78",
34
+ "@awarevue/api-types": "2.0.79",
35
35
  "rxjs": "^7.8.2",
36
36
  "ws": "^8"
37
37
  },
38
38
  "devDependencies": {
39
- "@awarevue/api-types": "2.0.78",
39
+ "@awarevue/api-types": "2.0.79",
40
40
  "@types/node": "^20.12.7",
41
41
  "@types/ws": "^8.18.1",
42
42
  "@typescript-eslint/eslint-plugin": "^8.31.1",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/Linc-Security-Systems/aware-essentials.git"
6
6
  },
7
- "version": "2.0.78",
7
+ "version": "2.0.79",
8
8
  "description": "SDK for building Agent implementations that speak the agent protocol.",
9
9
  "author": "Yaser Awajan",
10
10
  "license": "MIT",
@@ -31,12 +31,12 @@
31
31
  "lint:fix": "yarn lint --fix"
32
32
  },
33
33
  "peerDependencies": {
34
- "@awarevue/api-types": "2.0.78",
34
+ "@awarevue/api-types": "2.0.79",
35
35
  "rxjs": "^7.8.2",
36
36
  "ws": "^8"
37
37
  },
38
38
  "devDependencies": {
39
- "@awarevue/api-types": "2.0.78",
39
+ "@awarevue/api-types": "2.0.79",
40
40
  "@types/node": "^20.12.7",
41
41
  "@types/ws": "^8.18.1",
42
42
  "@typescript-eslint/eslint-plugin": "^8.31.1",