@flowcore/sdk 1.24.4 → 1.26.0
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/CHANGELOG.md +32 -0
- package/README.md +238 -0
- package/esm/commands/ai-agent-coordinator/artifact-get.command.d.ts +22 -0
- package/esm/commands/ai-agent-coordinator/artifact-get.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/artifact-get.command.js +52 -0
- package/esm/commands/ai-agent-coordinator/context-add-item.command.d.ts +28 -0
- package/esm/commands/ai-agent-coordinator/context-add-item.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/context-add-item.command.js +34 -0
- package/esm/commands/ai-agent-coordinator/context-remove-item.command.d.ts +28 -0
- package/esm/commands/ai-agent-coordinator/context-remove-item.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/context-remove-item.command.js +32 -0
- package/esm/commands/ai-agent-coordinator/conversation-delete.command.d.ts +25 -0
- package/esm/commands/ai-agent-coordinator/conversation-delete.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/conversation-delete.command.js +30 -0
- package/esm/commands/ai-agent-coordinator/conversation-get.command.d.ts +27 -0
- package/esm/commands/ai-agent-coordinator/conversation-get.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/conversation-get.command.js +36 -0
- package/esm/commands/ai-agent-coordinator/conversation-list.command.d.ts +23 -0
- package/esm/commands/ai-agent-coordinator/conversation-list.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/conversation-list.command.js +29 -0
- package/esm/commands/ai-agent-coordinator/conversation-stream.command.d.ts +30 -0
- package/esm/commands/ai-agent-coordinator/conversation-stream.command.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/conversation-stream.command.js +36 -0
- package/esm/commands/ai-agent-coordinator/mod.d.ts +8 -0
- package/esm/commands/ai-agent-coordinator/mod.d.ts.map +1 -0
- package/esm/commands/ai-agent-coordinator/mod.js +7 -0
- package/esm/common/command.d.ts.map +1 -1
- package/esm/common/command.js +3 -2
- package/esm/common/websocket-client.d.ts +109 -0
- package/esm/common/websocket-client.d.ts.map +1 -0
- package/esm/common/websocket-client.js +391 -0
- package/esm/common/websocket-command.d.ts +54 -0
- package/esm/common/websocket-command.d.ts.map +1 -0
- package/esm/common/websocket-command.js +1 -0
- package/esm/contracts/ai-agent-coordinator-stream.d.ts +85 -0
- package/esm/contracts/ai-agent-coordinator-stream.d.ts.map +1 -0
- package/esm/contracts/ai-agent-coordinator-stream.js +1 -0
- package/esm/contracts/ai-agent-coordinator.d.ts +41 -0
- package/esm/contracts/ai-agent-coordinator.d.ts.map +1 -0
- package/esm/contracts/ai-agent-coordinator.js +1 -0
- package/esm/mod.d.ts +8 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +8 -2
- package/package.json +1 -1
- package/script/commands/ai-agent-coordinator/artifact-get.command.d.ts +22 -0
- package/script/commands/ai-agent-coordinator/artifact-get.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/artifact-get.command.js +56 -0
- package/script/commands/ai-agent-coordinator/context-add-item.command.d.ts +28 -0
- package/script/commands/ai-agent-coordinator/context-add-item.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/context-add-item.command.js +38 -0
- package/script/commands/ai-agent-coordinator/context-remove-item.command.d.ts +28 -0
- package/script/commands/ai-agent-coordinator/context-remove-item.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/context-remove-item.command.js +36 -0
- package/script/commands/ai-agent-coordinator/conversation-delete.command.d.ts +25 -0
- package/script/commands/ai-agent-coordinator/conversation-delete.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/conversation-delete.command.js +34 -0
- package/script/commands/ai-agent-coordinator/conversation-get.command.d.ts +27 -0
- package/script/commands/ai-agent-coordinator/conversation-get.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/conversation-get.command.js +40 -0
- package/script/commands/ai-agent-coordinator/conversation-list.command.d.ts +23 -0
- package/script/commands/ai-agent-coordinator/conversation-list.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/conversation-list.command.js +33 -0
- package/script/commands/ai-agent-coordinator/conversation-stream.command.d.ts +30 -0
- package/script/commands/ai-agent-coordinator/conversation-stream.command.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/conversation-stream.command.js +40 -0
- package/script/commands/ai-agent-coordinator/mod.d.ts +8 -0
- package/script/commands/ai-agent-coordinator/mod.d.ts.map +1 -0
- package/script/commands/ai-agent-coordinator/mod.js +23 -0
- package/script/common/command.d.ts.map +1 -1
- package/script/common/command.js +27 -3
- package/script/common/websocket-client.d.ts +109 -0
- package/script/common/websocket-client.d.ts.map +1 -0
- package/script/common/websocket-client.js +418 -0
- package/script/common/websocket-command.d.ts +54 -0
- package/script/common/websocket-command.d.ts.map +1 -0
- package/script/common/websocket-command.js +2 -0
- package/script/contracts/ai-agent-coordinator-stream.d.ts +85 -0
- package/script/contracts/ai-agent-coordinator-stream.d.ts.map +1 -0
- package/script/contracts/ai-agent-coordinator-stream.js +2 -0
- package/script/contracts/ai-agent-coordinator.d.ts +41 -0
- package/script/contracts/ai-agent-coordinator.d.ts.map +1 -0
- package/script/contracts/ai-agent-coordinator.js +2 -0
- package/script/mod.d.ts +8 -2
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +11 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-list.command.d.ts","sourceRoot":"","sources":["../../../src/commands/ai-agent-coordinator/conversation-list.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAA4B,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAK7G;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,oBAAoB,EAAE,CAAA;AAElE;;GAEG;AACH,qBAAa,uBACX,SAAQ,gBAAgB,CAAC,4BAA4B,EAAE,6BAA6B,CACpF,YAAW,OAAO,CAAC,4BAA4B,EAAE,6BAA6B,CAAC;;cAK5D,UAAU,IAAI,MAAM;cAIpB,SAAS,IAAI,MAAM;cAInB,OAAO,IAAI,MAAM;cAIjB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,6BAA6B;CAQnF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationListCommand = void 0;
|
|
4
|
+
const command_js_1 = require("../../common/command.js");
|
|
5
|
+
const service = "ai-coordinator";
|
|
6
|
+
const baseUrl = `https://${service}.api.flowcore.io`;
|
|
7
|
+
/**
|
|
8
|
+
* Command to list all conversations accessible by the user.
|
|
9
|
+
*/
|
|
10
|
+
class ConversationListCommand extends command_js_1.Command {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({});
|
|
13
|
+
}
|
|
14
|
+
getBaseUrl() {
|
|
15
|
+
return baseUrl;
|
|
16
|
+
}
|
|
17
|
+
getMethod() {
|
|
18
|
+
return "GET";
|
|
19
|
+
}
|
|
20
|
+
getPath() {
|
|
21
|
+
return `/api/v1/conversations`;
|
|
22
|
+
}
|
|
23
|
+
parseResponse(response) {
|
|
24
|
+
const data = response;
|
|
25
|
+
if (data && Array.isArray(data.conversations)) {
|
|
26
|
+
return data.conversations;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error("Invalid response format for ConversationListCommand");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ConversationListCommand = ConversationListCommand;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WebSocketCommand } from "../../common/websocket-command.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the Conversation Stream.
|
|
4
|
+
* Only requires the conversationId.
|
|
5
|
+
*/
|
|
6
|
+
export interface ConversationStreamConfig {
|
|
7
|
+
conversationId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Payload type for messages sent *to* the Conversation Stream.
|
|
11
|
+
*/
|
|
12
|
+
export interface ConversationStreamSendPayload {
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Command to stream conversation events for a specific agent.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ConversationStreamCommand implements WebSocketCommand<ConversationStreamConfig, ConversationStreamSendPayload> {
|
|
19
|
+
private config;
|
|
20
|
+
constructor(config: ConversationStreamConfig);
|
|
21
|
+
/** Get the configuration object for the command. */
|
|
22
|
+
getConfig(): ConversationStreamConfig;
|
|
23
|
+
/** Get the base WebSocket URL. */
|
|
24
|
+
getWebSocketBaseUrl(): string;
|
|
25
|
+
/** Get the WebSocket path segment. */
|
|
26
|
+
getWebSocketPathSegment(config: ConversationStreamConfig): string;
|
|
27
|
+
/** Serializer function for outgoing payloads. */
|
|
28
|
+
serializeSendPayload(payload: ConversationStreamSendPayload): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=conversation-stream.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-stream.command.d.ts","sourceRoot":"","sources":["../../../src/commands/ai-agent-coordinator/conversation-stream.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEzE;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,qBAAa,yBACX,YAAW,gBAAgB,CAAC,wBAAwB,EAAE,6BAA6B,CAAC;IACpF,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,EAAE,wBAAwB;IAO5C,oDAAoD;IACpD,SAAS,IAAI,wBAAwB;IAIrC,kCAAkC;IAClC,mBAAmB,IAAI,MAAM;IAK7B,sCAAsC;IACtC,uBAAuB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM;IAKjE,iDAAiD;IACjD,oBAAoB,CAAC,OAAO,EAAE,6BAA6B,GAAG,MAAM;CAIrE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationStreamCommand = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Command to stream conversation events for a specific agent.
|
|
6
|
+
*/
|
|
7
|
+
class ConversationStreamCommand {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
Object.defineProperty(this, "config", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: void 0
|
|
14
|
+
});
|
|
15
|
+
if (!config.conversationId) {
|
|
16
|
+
throw new Error("conversationId is required in the config for ConversationStreamCommand");
|
|
17
|
+
}
|
|
18
|
+
this.config = config;
|
|
19
|
+
}
|
|
20
|
+
/** Get the configuration object for the command. */
|
|
21
|
+
getConfig() {
|
|
22
|
+
return this.config;
|
|
23
|
+
}
|
|
24
|
+
/** Get the base WebSocket URL. */
|
|
25
|
+
getWebSocketBaseUrl() {
|
|
26
|
+
// Specific base URL for AI Coordinator streams
|
|
27
|
+
return "wss://ai-coordinator.api.flowcore.io";
|
|
28
|
+
}
|
|
29
|
+
/** Get the WebSocket path segment. */
|
|
30
|
+
getWebSocketPathSegment(config) {
|
|
31
|
+
// Updated path segment based on likely API structure
|
|
32
|
+
return `/api/v1/stream/conversations/${config.conversationId}`;
|
|
33
|
+
}
|
|
34
|
+
/** Serializer function for outgoing payloads. */
|
|
35
|
+
serializeSendPayload(payload) {
|
|
36
|
+
// Default JSON serialization
|
|
37
|
+
return JSON.stringify(payload);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ConversationStreamCommand = ConversationStreamCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./artifact-get.command.js";
|
|
2
|
+
export * from "./context-add-item.command.js";
|
|
3
|
+
export * from "./context-remove-item.command.js";
|
|
4
|
+
export * from "./conversation-delete.command.js";
|
|
5
|
+
export * from "./conversation-get.command.js";
|
|
6
|
+
export * from "./conversation-list.command.js";
|
|
7
|
+
export * from "./conversation-stream.command.js";
|
|
8
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/commands/ai-agent-coordinator/mod.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./artifact-get.command.js"), exports);
|
|
18
|
+
__exportStar(require("./context-add-item.command.js"), exports);
|
|
19
|
+
__exportStar(require("./context-remove-item.command.js"), exports);
|
|
20
|
+
__exportStar(require("./conversation-delete.command.js"), exports);
|
|
21
|
+
__exportStar(require("./conversation-get.command.js"), exports);
|
|
22
|
+
__exportStar(require("./conversation-list.command.js"), exports);
|
|
23
|
+
__exportStar(require("./conversation-stream.command.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/common/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1D;;GAEG;AACH,8BAAsB,OAAO,CAAC,KAAK,EAAE,MAAM;IACzC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAO;IAEjD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE9C;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAuB;IAE/E;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;gBAEnB,KAAK,EAAE,KAAK;IAOxB;;OAEG;cACa,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/common/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE3D,OAAO,KAAK,EAAE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,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;QACnE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC/B,OAAO,EAAE,MAAM,CAAA;QACf,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,aAAa,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;QAC9D,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;QAC9E,iBAAiB,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;QAC/C,cAAc,EAAE,OAAO,CAAA;QACvB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAC7D,CAAC;IAeF;;OAEG;cAEa,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F"}
|
package/script/common/command.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.Command = void 0;
|
|
4
|
-
const tenant_fetch_js_1 = require("../commands/tenant/tenant.fetch.js");
|
|
5
27
|
const client_error_js_1 = require("../exceptions/client-error.js");
|
|
6
28
|
const command_error_js_1 = require("../exceptions/command-error.js");
|
|
7
29
|
const tenant_cache_js_1 = require("./tenant.cache.js");
|
|
@@ -65,13 +87,15 @@ class Command {
|
|
|
65
87
|
}
|
|
66
88
|
let tenant = tenant_cache_js_1.tenantCache.get(inputTenant);
|
|
67
89
|
if (!tenant) {
|
|
68
|
-
|
|
90
|
+
// Dynamically import TenantFetchCommand only when needed
|
|
91
|
+
const { TenantFetchCommand } = await Promise.resolve().then(() => __importStar(require("../commands/tenant/tenant.fetch.js")));
|
|
92
|
+
tenant = await client.execute(new TenantFetchCommand({ tenant: inputTenant }))
|
|
69
93
|
.catch((error) => {
|
|
70
94
|
if (error instanceof client_error_js_1.ClientError && error.status === 403) {
|
|
71
95
|
return {
|
|
72
96
|
isDedicated: false,
|
|
73
97
|
dedicated: null,
|
|
74
|
-
};
|
|
98
|
+
}; // Cast needed as we are not returning the full Tenant shape
|
|
75
99
|
}
|
|
76
100
|
throw error;
|
|
77
101
|
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { type Logger } from "../utils/logger.js";
|
|
3
|
+
import type { ClientOptions } from "./flowcore-client.js";
|
|
4
|
+
import type { ActiveStreamInterface, WebSocketCommand } from "./websocket-command.js";
|
|
5
|
+
/**
|
|
6
|
+
* Interface for OIDC authentication client (reused from NotificationClient context)
|
|
7
|
+
*/
|
|
8
|
+
export type OidcClient = {
|
|
9
|
+
getToken: () => Promise<{
|
|
10
|
+
accessToken: string;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for the WebSocketClient
|
|
15
|
+
*/
|
|
16
|
+
export type WebSocketClientOptions = {
|
|
17
|
+
/** Interval between reconnect attempts (ms). Defaults to 1000. */
|
|
18
|
+
reconnectInterval?: number;
|
|
19
|
+
/** Maximum number of reconnect attempts. Defaults to undefined (infinite). */
|
|
20
|
+
maxReconnects?: number;
|
|
21
|
+
/** Optional logger instance. */
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
};
|
|
24
|
+
interface MinimalWebSocket {
|
|
25
|
+
readyState: number;
|
|
26
|
+
onopen: (() => void) | null;
|
|
27
|
+
onmessage: ((event: {
|
|
28
|
+
data: string | ArrayBuffer | Buffer;
|
|
29
|
+
}) => void) | null;
|
|
30
|
+
onclose: ((event: {
|
|
31
|
+
code: number;
|
|
32
|
+
reason: string;
|
|
33
|
+
wasClean: boolean;
|
|
34
|
+
}) => void) | null;
|
|
35
|
+
onerror: ((event: Event) => void) | null;
|
|
36
|
+
send(data: string): void;
|
|
37
|
+
close(code?: number, reason?: string): void;
|
|
38
|
+
}
|
|
39
|
+
type WebSocketFactory = (url: string) => MinimalWebSocket;
|
|
40
|
+
/**
|
|
41
|
+
* Generic client for managing a single, persistent WebSocket connection based on a command.
|
|
42
|
+
* Handles connection lifecycle, authentication, reconnection, and message sending/receiving.
|
|
43
|
+
*/
|
|
44
|
+
export declare class WebSocketClient {
|
|
45
|
+
private readonly authOptions;
|
|
46
|
+
private overrideBaseUrl;
|
|
47
|
+
private webSocket;
|
|
48
|
+
private options;
|
|
49
|
+
private logger;
|
|
50
|
+
private reconnectInterval;
|
|
51
|
+
private reconnectAttempts;
|
|
52
|
+
private _isOpen;
|
|
53
|
+
private _isConnecting;
|
|
54
|
+
private webSocketFactory;
|
|
55
|
+
private internalSubject;
|
|
56
|
+
private currentCommand;
|
|
57
|
+
private currentConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new WebSocketClient instance.
|
|
60
|
+
* @param authOptions - Authentication options (Bearer token via OIDC client or API Key).
|
|
61
|
+
* @param options - Configuration options for the client.
|
|
62
|
+
* @param webSocketFactory - Optional WebSocket factory for testing.
|
|
63
|
+
*/
|
|
64
|
+
constructor(authOptions: ClientOptions, options?: WebSocketClientOptions, webSocketFactory?: WebSocketFactory);
|
|
65
|
+
/**
|
|
66
|
+
* Override the base URL provided by commands.
|
|
67
|
+
* @param baseUrl - The new base URL to use (e.g., "wss://staging-server.api.flowcore.io").
|
|
68
|
+
*/
|
|
69
|
+
setBaseUrl(baseUrl: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the WebSocket connection is currently open.
|
|
72
|
+
*/
|
|
73
|
+
get isOpen(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if the client is currently attempting to establish a WebSocket connection.
|
|
76
|
+
*/
|
|
77
|
+
get isConnecting(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Establishes WebSocket connection based on the provided command.
|
|
80
|
+
* Disconnects any existing connection before starting the new one.
|
|
81
|
+
* @param command - The command defining the stream connection details.
|
|
82
|
+
* @returns An interface to interact with the active stream.
|
|
83
|
+
*/
|
|
84
|
+
connect<Config, SendPayload>(command: WebSocketCommand<Config, SendPayload>): Promise<ActiveStreamInterface<SendPayload>>;
|
|
85
|
+
/**
|
|
86
|
+
* Sets up the WebSocket event handlers (onopen, onmessage, onclose, onerror).
|
|
87
|
+
*/
|
|
88
|
+
private setupEventHandlers;
|
|
89
|
+
/**
|
|
90
|
+
* Attempts to reconnect to the WebSocket server using exponential backoff.
|
|
91
|
+
* Requires `currentConfig` to be set.
|
|
92
|
+
*/
|
|
93
|
+
private attemptReconnect;
|
|
94
|
+
/**
|
|
95
|
+
* Sends a message to the currently connected WebSocket.
|
|
96
|
+
* @param message - The message object to send (e.g., { content: "user input" }).
|
|
97
|
+
*/
|
|
98
|
+
private sendMessage;
|
|
99
|
+
/**
|
|
100
|
+
* Closes the WebSocket connection gracefully.
|
|
101
|
+
*/
|
|
102
|
+
disconnect(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Implements the Disposable interface for clean resource management.
|
|
105
|
+
*/
|
|
106
|
+
[Symbol.dispose](): void;
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=websocket-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-client.d.ts","sourceRoot":"","sources":["../../src/common/websocket-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAIrF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjD,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAMD,UAAU,gBAAgB;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM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