@awarevue/agent-sdk 2.0.78 → 2.0.80
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/dist/agent-protocol.d.ts +6 -1
- package/dist/agent-protocol.js +7 -1
- package/dist/agent-server.d.ts +2 -1
- package/dist/agent-server.js +12 -2
- package/dist/package.json +3 -3
- package/package.json +3 -3
package/dist/agent-protocol.d.ts
CHANGED
|
@@ -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?:
|
|
35
|
+
}>, { timeoutMs, onProgress }?: GetReplyOptions) => Observable<Message<PayloadByKind[ResponseKind<K>]>>;
|
|
31
36
|
send: (payload: Outbound<D>) => void;
|
|
32
37
|
}
|
package/dist/agent-protocol.js
CHANGED
|
@@ -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/agent-server.d.ts
CHANGED
|
@@ -47,7 +47,8 @@ export declare class AgentServer<TPeer extends PeerId = string> {
|
|
|
47
47
|
private onPeerLeave;
|
|
48
48
|
private processMessage;
|
|
49
49
|
startAgent({ agentId, ...rest }: StartAgentArgs): void;
|
|
50
|
-
stopAgent(agentId: string, provider: string): void
|
|
50
|
+
stopAgent(agentId: string, provider: string): Promise<void>;
|
|
51
|
+
restartAgent({ agentId, ...rest }: StartAgentArgs): Promise<void>;
|
|
51
52
|
finalize(): void;
|
|
52
53
|
getAgentSender(agentId: string): AgentProtocol<'server'> | null;
|
|
53
54
|
private getPeerSender;
|
package/dist/agent-server.js
CHANGED
|
@@ -119,9 +119,19 @@ class AgentServer {
|
|
|
119
119
|
const protocol = this.getAgentSender(agentId);
|
|
120
120
|
protocol === null || protocol === void 0 ? void 0 : protocol.send({ kind: 'start', ...rest });
|
|
121
121
|
}
|
|
122
|
-
stopAgent(agentId, provider) {
|
|
122
|
+
async stopAgent(agentId, provider) {
|
|
123
123
|
const protocol = this.getAgentSender(agentId);
|
|
124
|
-
|
|
124
|
+
if (!protocol) {
|
|
125
|
+
this.notifications$.next(`Cannot stop agent ${agentId} - no connection found`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await (0, rxjs_1.lastValueFrom)(protocol.getReply$({ kind: 'stop', provider })).catch((err) => {
|
|
129
|
+
this.notifications$.next(`Failed to stop agent ${agentId}: ${err.message}`);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async restartAgent({ agentId, ...rest }) {
|
|
133
|
+
await this.stopAgent(agentId, rest.provider);
|
|
134
|
+
this.startAgent({ agentId, ...rest });
|
|
125
135
|
}
|
|
126
136
|
finalize() {
|
|
127
137
|
var _a;
|
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.
|
|
7
|
+
"version": "2.0.80",
|
|
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.
|
|
34
|
+
"@awarevue/api-types": "2.0.80",
|
|
35
35
|
"rxjs": "^7.8.2",
|
|
36
36
|
"ws": "^8"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@awarevue/api-types": "2.0.
|
|
39
|
+
"@awarevue/api-types": "2.0.80",
|
|
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.
|
|
7
|
+
"version": "2.0.80",
|
|
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.
|
|
34
|
+
"@awarevue/api-types": "2.0.80",
|
|
35
35
|
"rxjs": "^7.8.2",
|
|
36
36
|
"ws": "^8"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@awarevue/api-types": "2.0.
|
|
39
|
+
"@awarevue/api-types": "2.0.80",
|
|
40
40
|
"@types/node": "^20.12.7",
|
|
41
41
|
"@types/ws": "^8.18.1",
|
|
42
42
|
"@typescript-eslint/eslint-plugin": "^8.31.1",
|