@things-factory/integration-openai 6.0.43

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 (47) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +0 -0
  3. package/dist-server/engine/connector/graph-connector.js +75 -0
  4. package/dist-server/engine/connector/graph-connector.js.map +1 -0
  5. package/dist-server/engine/connector/index.js +4 -0
  6. package/dist-server/engine/connector/index.js.map +1 -0
  7. package/dist-server/engine/connector/modbus-tcp-server.js +41 -0
  8. package/dist-server/engine/connector/modbus-tcp-server.js.map +1 -0
  9. package/dist-server/engine/connector/modbus-tcp.js +145 -0
  10. package/dist-server/engine/connector/modbus-tcp.js.map +1 -0
  11. package/dist-server/engine/connector/msgraph-connector.js +75 -0
  12. package/dist-server/engine/connector/msgraph-connector.js.map +1 -0
  13. package/dist-server/engine/connector/openai-connector.js +58 -0
  14. package/dist-server/engine/connector/openai-connector.js.map +1 -0
  15. package/dist-server/engine/index.js +5 -0
  16. package/dist-server/engine/index.js.map +1 -0
  17. package/dist-server/engine/task/get-users.js +47 -0
  18. package/dist-server/engine/task/get-users.js.map +1 -0
  19. package/dist-server/engine/task/index.js +4 -0
  20. package/dist-server/engine/task/index.js.map +1 -0
  21. package/dist-server/engine/task/modbus-read.js +55 -0
  22. package/dist-server/engine/task/modbus-read.js.map +1 -0
  23. package/dist-server/engine/task/modbus-write-single.js +51 -0
  24. package/dist-server/engine/task/modbus-write-single.js.map +1 -0
  25. package/dist-server/engine/task/msgraph-get-users.js +41 -0
  26. package/dist-server/engine/task/msgraph-get-users.js.map +1 -0
  27. package/dist-server/engine/task/openai-completion.js +29 -0
  28. package/dist-server/engine/task/openai-completion.js.map +1 -0
  29. package/dist-server/index.js +4 -0
  30. package/dist-server/index.js.map +1 -0
  31. package/dist-server/tsconfig.tsbuildinfo +1 -0
  32. package/helps/integration/connector/openai-connector.ko.md +21 -0
  33. package/helps/integration/connector/openai-connector.md +21 -0
  34. package/helps/integration/task/openai-completion.ko.md +13 -0
  35. package/helps/integration/task/openai-completion.md +14 -0
  36. package/package.json +29 -0
  37. package/server/engine/connector/index.ts +1 -0
  38. package/server/engine/connector/openai-connector.ts +71 -0
  39. package/server/engine/index.ts +2 -0
  40. package/server/engine/task/index.ts +1 -0
  41. package/server/engine/task/openai-completion.ts +32 -0
  42. package/server/index.ts +1 -0
  43. package/things-factory.config.js +1 -0
  44. package/translations/en.json +1 -0
  45. package/translations/ko.json +1 -0
  46. package/translations/ms.json +1 -0
  47. package/translations/zh.json +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
+
8
+ <!-- ## [Unreleased] -->
package/README.md ADDED
File without changes
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsGraphConnector = void 0;
4
+ /* fetch polyfil */
5
+ require("cross-fetch/polyfill");
6
+ const integration_base_1 = require("@things-factory/integration-base");
7
+ const azure = require('@azure/identity');
8
+ const graph = require('@microsoft/microsoft-graph-client');
9
+ const authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials');
10
+ class MsGraphConnector {
11
+ async ready(connectionConfigs) {
12
+ await Promise.all(connectionConfigs.map(this.connect.bind(this)));
13
+ integration_base_1.ConnectionManager.logger.info('msgraph-connector connections are ready');
14
+ }
15
+ async connect(connection) {
16
+ var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId, authTenantId, graphUserScopes } } = connection;
17
+ if (!clientId || !clientSecret || !tenantId || !authTenantId) {
18
+ throw new Error('Connection parameters should not be undefined');
19
+ }
20
+ const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret);
21
+ const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {
22
+ scopes: ['https://graph.microsoft.com/.default']
23
+ });
24
+ const client = graph.Client.initWithMiddleware({
25
+ authProvider: authProvider
26
+ });
27
+ integration_base_1.ConnectionManager.addConnectionInstance(connection, client);
28
+ integration_base_1.ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`);
29
+ }
30
+ async disconnect(connection) {
31
+ const client = integration_base_1.ConnectionManager.getConnectionInstance(connection);
32
+ // TODO implement how to stop connection
33
+ integration_base_1.ConnectionManager.removeConnectionInstance(connection);
34
+ integration_base_1.ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`);
35
+ }
36
+ get parameterSpec() {
37
+ /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */
38
+ return [
39
+ {
40
+ type: 'string',
41
+ name: 'clientId',
42
+ label: 'client-id'
43
+ },
44
+ {
45
+ type: 'string',
46
+ name: 'clientSecret',
47
+ label: 'client-secret'
48
+ },
49
+ {
50
+ type: 'string',
51
+ name: 'tenantId',
52
+ label: 'tenant-id'
53
+ },
54
+ {
55
+ type: 'string',
56
+ name: 'authTenantId',
57
+ label: 'auth-tenant-id'
58
+ },
59
+ {
60
+ type: 'string',
61
+ name: 'graphUserScopes',
62
+ label: 'graph-user-scopes'
63
+ }
64
+ ];
65
+ }
66
+ get taskPrefixes() {
67
+ return ['msgraph'];
68
+ }
69
+ get description() {
70
+ return 'Graph API Connector';
71
+ }
72
+ }
73
+ exports.MsGraphConnector = MsGraphConnector;
74
+ integration_base_1.ConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector());
75
+ //# sourceMappingURL=graph-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/graph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACxC,MA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A;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,MAAM,MAAM,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClE,wCAAwC;QACxC,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,2FAA2F;QAC3F,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,eAAe;aACvB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,gBAAgB;aACxB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,mBAAmB;aAC3B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;CACF;AA/ED,4CA+EC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nconst azure = require('@azure/identity')\nconst graph = require('@microsoft/microsoft-graph-client')\nconst authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials')\n\nexport class MsGraphConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('msgraph-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri = 'https://graph.microsoft.com/v1.0',\n params: { clientId, clientSecret, tenantId, authTenantId, graphUserScopes }\n } = connection\n\n if (!clientId || !clientSecret || !tenantId || !authTenantId) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret)\n const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {\n scopes: ['https://graph.microsoft.com/.default']\n })\n\n const client = graph.Client.initWithMiddleware({\n authProvider: authProvider\n })\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */\n return [\n {\n type: 'string',\n name: 'clientId',\n label: 'client-id'\n },\n {\n type: 'string',\n name: 'clientSecret',\n label: 'client-secret'\n },\n {\n type: 'string',\n name: 'tenantId',\n label: 'tenant-id'\n },\n {\n type: 'string',\n name: 'authTenantId',\n label: 'auth-tenant-id'\n },\n {\n type: 'string',\n name: 'graphUserScopes',\n label: 'graph-user-scopes'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['msgraph']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n}\n\nConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector())\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./openai-connector");
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/connector/index.ts"],"names":[],"mappings":";;AAAA,8BAA2B","sourcesContent":["import './openai-connector'\n"]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModbusTCPServer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const integration_base_1 = require("@things-factory/integration-base");
6
+ const net_1 = tslib_1.__importDefault(require("net"));
7
+ const modbus = tslib_1.__importStar(require("jsmodbus"));
8
+ class ModbusTCPServer {
9
+ async ready(connectionConfigs) {
10
+ await Promise.all(connectionConfigs.map(this.connect));
11
+ integration_base_1.ConnectionManager.logger.info('modbus-tcp-servers are ready');
12
+ }
13
+ async connect(config) {
14
+ var [host = '0.0.0.0', port = 502] = config.endpoint.split(':');
15
+ const netServer = new net_1.default.Server();
16
+ const server = new modbus.server.TCP(netServer);
17
+ netServer.on('error', console.error);
18
+ netServer.listen(port, host);
19
+ /* default client connection */
20
+ const clientSocket = new net_1.default.Socket();
21
+ const client = new modbus.client.TCP(clientSocket);
22
+ clientSocket.on('error', console.error);
23
+ clientSocket.connect({ host: 'localhost', port });
24
+ client['__server__'] = server;
25
+ integration_base_1.ConnectionManager.addConnectionInstance(config, client);
26
+ integration_base_1.ConnectionManager.logger.info(`modbus-tcp-server connection(${config.name}:${config.endpoint}) is connected`);
27
+ }
28
+ async disconnect(connection) {
29
+ var client = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
30
+ var server = client['__server__'];
31
+ client.socket.end();
32
+ server && server._server.close();
33
+ integration_base_1.ConnectionManager.logger.info(`modbus-tcp-server connection(${connection.name}) is disconnected`);
34
+ }
35
+ get parameterSpec() {
36
+ return [];
37
+ }
38
+ }
39
+ exports.ModbusTCPServer = ModbusTCPServer;
40
+ integration_base_1.ConnectionManager.registerConnector('modbus-tcp-server', new ModbusTCPServer());
41
+ //# sourceMappingURL=modbus-tcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modbus-tcp-server.js","sour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CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,gBAAgB,CAAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAsB;QACrC,IAAI,MAAM,GAAG,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACnE,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QAEjC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QACnB,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAEhC,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AA3CD,0CA2CC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA","sourcesContent":["import { ConnectionManager, Connector, Connection } from '@things-factory/integration-base'\nimport net from 'net'\nimport * as modbus from 'jsmodbus'\n\nexport class ModbusTCPServer implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('modbus-tcp-servers are ready')\n }\n\n async connect(config) {\n var [host = '0.0.0.0', port = 502] = config.endpoint.split(':')\n\n const netServer = new net.Server()\n\n const server = new modbus.server.TCP(netServer)\n\n netServer.on('error', console.error)\n netServer.listen(port, host)\n\n /* default client connection */\n const clientSocket = new net.Socket()\n const client = new modbus.client.TCP(clientSocket)\n clientSocket.on('error', console.error)\n clientSocket.connect({ host: 'localhost', port })\n\n client['__server__'] = server\n\n ConnectionManager.addConnectionInstance(config, client)\n\n ConnectionManager.logger.info(`modbus-tcp-server connection(${config.name}:${config.endpoint}) is connected`)\n }\n\n async disconnect(connection: Connection) {\n var client = ConnectionManager.removeConnectionInstance(connection)\n var server = client['__server__']\n\n client.socket.end()\n server && server._server.close()\n\n ConnectionManager.logger.info(`modbus-tcp-server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n}\n\nConnectionManager.registerConnector('modbus-tcp-server', new ModbusTCPServer())\n"]}
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModbusTCPConnector = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const modbus = tslib_1.__importStar(require("jsmodbus"));
6
+ const net_1 = require("net");
7
+ const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
8
+ const promise_socket_1 = tslib_1.__importDefault(require("promise-socket"));
9
+ const integration_base_1 = require("@things-factory/integration-base");
10
+ const utils_1 = require("@things-factory/utils");
11
+ class ModbusTCPConnector {
12
+ async ready(connectionConfigs) {
13
+ await Promise.all(connectionConfigs.map(this.connect));
14
+ integration_base_1.ConnectionManager.logger.info('modbus-tcp connections are ready');
15
+ }
16
+ async connect(config) {
17
+ var [host, port = 502] = config.endpoint.split(':');
18
+ var { params } = config;
19
+ var clientSocket = new net_1.Socket();
20
+ var promiseSocket = new promise_socket_1.default(clientSocket);
21
+ var client = new modbus.client.TCP(clientSocket);
22
+ try {
23
+ clientSocket.on('error', console.error);
24
+ await promiseSocket.connect(port, host);
25
+ var queue = new p_queue_1.default({ concurrency: 1 });
26
+ var keepalive = params.keepalive;
27
+ integration_base_1.ConnectionManager.addConnectionInstance(config, {
28
+ readModBus: async function (objectType, address, quantity, { logger }) {
29
+ return await queue.add(async () => {
30
+ while (true) {
31
+ try {
32
+ var response;
33
+ switch (objectType) {
34
+ case 'descrete input':
35
+ response = await client.readDiscreteInputs(address, quantity);
36
+ break;
37
+ case 'input register':
38
+ response = await client.readInputRegisters(address, quantity);
39
+ break;
40
+ case 'holding register':
41
+ response = await client.readHoldingRegisters(address, quantity);
42
+ break;
43
+ default:
44
+ response = await client.readCoils(address, quantity);
45
+ }
46
+ var data = response && response.response._body.valuesAsArray.slice(0, quantity);
47
+ logger.info(`${JSON.stringify(data)}`);
48
+ return {
49
+ data
50
+ };
51
+ }
52
+ catch (e) {
53
+ logger.error('readModBus command failed.');
54
+ logger.error(e);
55
+ if (keepalive) {
56
+ promiseSocket && promiseSocket.destroy();
57
+ clientSocket = new net_1.Socket();
58
+ promiseSocket = new promise_socket_1.default(clientSocket);
59
+ client = new modbus.client.TCP(clientSocket);
60
+ clientSocket.on('error', console.error);
61
+ promiseSocket.connect(port, host);
62
+ await (0, utils_1.sleep)(1000);
63
+ }
64
+ else {
65
+ throw e;
66
+ }
67
+ }
68
+ }
69
+ });
70
+ },
71
+ writeSingleModBus: async function (objectType, address, value, { logger }) {
72
+ return await queue.add(async () => {
73
+ while (true) {
74
+ try {
75
+ var response;
76
+ switch (objectType) {
77
+ case 'holding register':
78
+ await client.writeSingleRegister(address, parseInt(value));
79
+ response = await client.readHoldingRegisters(address, 1);
80
+ break;
81
+ default:
82
+ await client.writeSingleCoil(address, !!Number(value));
83
+ response = await client.readCoils(address, 1);
84
+ }
85
+ var data = response && response.response._body.valuesAsArray[0];
86
+ logger.info(data);
87
+ return {
88
+ data
89
+ };
90
+ }
91
+ catch (e) {
92
+ logger.error('writeSingleModBus command failed.');
93
+ logger.error(e);
94
+ if (keepalive) {
95
+ promiseSocket && promiseSocket.destroy();
96
+ clientSocket = new net_1.Socket();
97
+ promiseSocket = new promise_socket_1.default(clientSocket);
98
+ client = new modbus.client.TCP(clientSocket);
99
+ clientSocket.on('error', console.error);
100
+ promiseSocket.connect(port, host);
101
+ await (0, utils_1.sleep)(1000);
102
+ }
103
+ else {
104
+ throw e;
105
+ }
106
+ }
107
+ }
108
+ });
109
+ },
110
+ close: function () {
111
+ queue.clear();
112
+ keepalive = false;
113
+ promiseSocket.destroy();
114
+ }
115
+ });
116
+ integration_base_1.ConnectionManager.logger.info(`modbus-tcp connection(${config.name}:${config.endpoint}) is connected`);
117
+ }
118
+ catch (error) {
119
+ integration_base_1.ConnectionManager.logger.info(`modbus-tcp connection(${config.name}:${config.endpoint}) failed to connect`);
120
+ }
121
+ }
122
+ async disconnect(connection) {
123
+ var { close } = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
124
+ close();
125
+ integration_base_1.ConnectionManager.logger.info(`modbus-tcp connection(${connection.name}) is disconnected`);
126
+ }
127
+ get parameterSpec() {
128
+ return [
129
+ {
130
+ type: 'checkbox',
131
+ name: 'keepalive',
132
+ label: 'keepalive'
133
+ }
134
+ ];
135
+ }
136
+ get taskPrefixes() {
137
+ return ['modbus'];
138
+ }
139
+ get help() {
140
+ return 'integration/connector/modbus-tcp';
141
+ }
142
+ }
143
+ exports.ModbusTCPConnector = ModbusTCPConnector;
144
+ integration_base_1.ConnectionManager.registerConnector('modbus-tcp', new ModbusTCPConnector());
145
+ //# sourceMappingURL=modbus-tcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modbus-tcp.js","sourceRoot":"","sources":["../../../server/engine/connector/modbus-tcp.ts"],"names":[],"mappings":";;;;AAAA,yDAAkC;AAClC,6BAA4B;AAC5B,8DAA4B;AAC5B,4EAA0C;AAE1C,uEAA2F;AAC3F,iDAA6C;AAE7C,MAAa,kBAAkB;IAC7B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IACnE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAM;QAClB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnD,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;QAEvB,IAAI,YAAY,GAAG,IAAI,YAAM,EAAE,CAAA;QAC/B,IA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AAO,EAAE,CAAA;gBACzB,CAAC;aACF,CAAC,CAAA;YAEF,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,gBAAgB,CAAC,CAAA;SACvG;QAAC,OAAO,KAAK,EAAE;YACd,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,qBAAqB,CAAC,CAAA;SAC5G;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAsB;QACrC,IAAI,EAAE,KAAK,EAAE,GAAG,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACtE,KAAK,EAAE,CAAA;QAEP,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,WAAW;aACnB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,kCAAkC,CAAA;IAC3C,CAAC;CACF;AAtJD,gDAsJC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,IAAI,kBAAkB,EAAE,CAAC,CAAA","sourcesContent":["import * as modbus from 'jsmodbus'\nimport { Socket } from 'net'\nimport PQueue from 'p-queue'\nimport PromiseSocket from 'promise-socket'\n\nimport { Connection, ConnectionManager, Connector } from '@things-factory/integration-base'\nimport { sleep } from '@things-factory/utils'\n\nexport class ModbusTCPConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('modbus-tcp connections are ready')\n }\n\n async connect(config) {\n var [host, port = 502] = config.endpoint.split(':')\n var { params } = config\n\n var clientSocket = new Socket()\n var promiseSocket = new PromiseSocket(clientSocket)\n\n var client = new modbus.client.TCP(clientSocket)\n\n try {\n clientSocket.on('error', console.error)\n\n await promiseSocket.connect(port, host)\n\n var queue = new PQueue({ concurrency: 1 })\n var keepalive = params.keepalive\n\n ConnectionManager.addConnectionInstance(config, {\n readModBus: async function (objectType, address, quantity, { logger }) {\n return await queue.add(async () => {\n while (true) {\n try {\n var response\n\n switch (objectType) {\n case 'descrete input':\n response = await client.readDiscreteInputs(address, quantity)\n break\n case 'input register':\n response = await client.readInputRegisters(address, quantity)\n break\n case 'holding register':\n response = await client.readHoldingRegisters(address, quantity)\n break\n default:\n response = await client.readCoils(address, quantity)\n }\n\n var data = response && response.response._body.valuesAsArray.slice(0, quantity)\n logger.info(`${JSON.stringify(data)}`)\n return {\n data\n }\n } catch (e) {\n logger.error('readModBus command failed.')\n logger.error(e)\n\n if (keepalive) {\n promiseSocket && promiseSocket.destroy()\n\n clientSocket = new Socket()\n promiseSocket = new PromiseSocket(clientSocket)\n client = new modbus.client.TCP(clientSocket)\n clientSocket.on('error', console.error)\n promiseSocket.connect(port, host)\n\n await sleep(1000)\n } else {\n throw e\n }\n }\n }\n })\n },\n writeSingleModBus: async function (objectType, address, value, { logger }) {\n return await queue.add(async () => {\n while (true) {\n try {\n var response\n\n switch (objectType) {\n case 'holding register':\n await client.writeSingleRegister(address, parseInt(value))\n response = await client.readHoldingRegisters(address, 1)\n break\n default:\n await client.writeSingleCoil(address, !!Number(value))\n response = await client.readCoils(address, 1)\n }\n\n var data = response && response.response._body.valuesAsArray[0]\n logger.info(data)\n return {\n data\n }\n } catch (e) {\n logger.error('writeSingleModBus command failed.')\n logger.error(e)\n\n if (keepalive) {\n promiseSocket && promiseSocket.destroy()\n\n clientSocket = new Socket()\n promiseSocket = new PromiseSocket(clientSocket)\n client = new modbus.client.TCP(clientSocket)\n clientSocket.on('error', console.error)\n promiseSocket.connect(port, host)\n\n await sleep(1000)\n } else {\n throw e\n }\n }\n }\n })\n },\n close: function () {\n queue.clear()\n keepalive = false\n promiseSocket.destroy()\n }\n })\n\n ConnectionManager.logger.info(`modbus-tcp connection(${config.name}:${config.endpoint}) is connected`)\n } catch (error) {\n ConnectionManager.logger.info(`modbus-tcp connection(${config.name}:${config.endpoint}) failed to connect`)\n }\n }\n\n async disconnect(connection: Connection) {\n var { close } = ConnectionManager.removeConnectionInstance(connection)\n close()\n\n ConnectionManager.logger.info(`modbus-tcp connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'checkbox',\n name: 'keepalive',\n label: 'keepalive'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['modbus']\n }\n\n get help() {\n return 'integration/connector/modbus-tcp'\n }\n}\n\nConnectionManager.registerConnector('modbus-tcp', new ModbusTCPConnector())\n"]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsGraphConnector = void 0;
4
+ /* fetch polyfil */
5
+ require("cross-fetch/polyfill");
6
+ const integration_base_1 = require("@things-factory/integration-base");
7
+ const azure = require('@azure/identity');
8
+ const graph = require('@microsoft/microsoft-graph-client');
9
+ const authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials');
10
+ class MsGraphConnector {
11
+ async ready(connectionConfigs) {
12
+ await Promise.all(connectionConfigs.map(this.connect.bind(this)));
13
+ integration_base_1.ConnectionManager.logger.info('msgraph-connector connections are ready');
14
+ }
15
+ async connect(connection) {
16
+ var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId, authTenantId, graphUserScopes } } = connection;
17
+ if (!clientId || !clientSecret || !tenantId || !authTenantId) {
18
+ throw new Error('Connection parameters should not be undefined');
19
+ }
20
+ const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret);
21
+ const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {
22
+ scopes: ['https://graph.microsoft.com/.default']
23
+ });
24
+ const client = graph.Client.initWithMiddleware({
25
+ authProvider: authProvider
26
+ });
27
+ integration_base_1.ConnectionManager.addConnectionInstance(connection, client);
28
+ integration_base_1.ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`);
29
+ }
30
+ async disconnect(connection) {
31
+ const client = integration_base_1.ConnectionManager.getConnectionInstance(connection);
32
+ // TODO implement how to stop connection
33
+ integration_base_1.ConnectionManager.removeConnectionInstance(connection);
34
+ integration_base_1.ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`);
35
+ }
36
+ get parameterSpec() {
37
+ /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */
38
+ return [
39
+ {
40
+ type: 'string',
41
+ name: 'clientId',
42
+ label: 'client-id'
43
+ },
44
+ {
45
+ type: 'string',
46
+ name: 'clientSecret',
47
+ label: 'client-secret'
48
+ },
49
+ {
50
+ type: 'string',
51
+ name: 'tenantId',
52
+ label: 'tenant-id'
53
+ },
54
+ {
55
+ type: 'string',
56
+ name: 'authTenantId',
57
+ label: 'auth-tenant-id'
58
+ },
59
+ {
60
+ type: 'string',
61
+ name: 'graphUserScopes',
62
+ label: 'graph-user-scopes'
63
+ }
64
+ ];
65
+ }
66
+ get taskPrefixes() {
67
+ return ['msgraph'];
68
+ }
69
+ get description() {
70
+ return 'Graph API Connector';
71
+ }
72
+ }
73
+ exports.MsGraphConnector = MsGraphConnector;
74
+ integration_base_1.ConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector());
75
+ //# sourceMappingURL=msgraph-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgraph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/msgraph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACxC,MAAM,KAAK,GAAG,OAAO,CAAC,mCAAmC,CA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AC,UAAU;QACzB,MAAM,MAAM,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClE,wCAAwC;QACxC,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,2FAA2F;QAC3F,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,eAAe;aACvB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,gBAAgB;aACxB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,mBAAmB;aAC3B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;CACF;AA/ED,4CA+EC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nconst azure = require('@azure/identity')\nconst graph = require('@microsoft/microsoft-graph-client')\nconst authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials')\n\nexport class MsGraphConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('msgraph-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri = 'https://graph.microsoft.com/v1.0',\n params: { clientId, clientSecret, tenantId, authTenantId, graphUserScopes }\n } = connection\n\n if (!clientId || !clientSecret || !tenantId || !authTenantId) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret)\n const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {\n scopes: ['https://graph.microsoft.com/.default']\n })\n\n const client = graph.Client.initWithMiddleware({\n authProvider: authProvider\n })\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */\n return [\n {\n type: 'string',\n name: 'clientId',\n label: 'client-id'\n },\n {\n type: 'string',\n name: 'clientSecret',\n label: 'client-secret'\n },\n {\n type: 'string',\n name: 'tenantId',\n label: 'tenant-id'\n },\n {\n type: 'string',\n name: 'authTenantId',\n label: 'auth-tenant-id'\n },\n {\n type: 'string',\n name: 'graphUserScopes',\n label: 'graph-user-scopes'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['msgraph']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n}\n\nConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector())\n"]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenAIConnector = void 0;
4
+ /* fetch polyfil */
5
+ require("cross-fetch/polyfill");
6
+ const integration_base_1 = require("@things-factory/integration-base");
7
+ const openai_1 = require("openai");
8
+ class OpenAIConnector {
9
+ async ready(connectionConfigs) {
10
+ await Promise.all(connectionConfigs.map(this.connect.bind(this)));
11
+ integration_base_1.ConnectionManager.logger.info('openai-connector connections are ready');
12
+ }
13
+ async connect(connection) {
14
+ var { endpoint: uri, params: { organization, apiKey } } = connection;
15
+ if (!organization || !apiKey) {
16
+ throw new Error('Connection parameters should not be undefined');
17
+ }
18
+ const configuration = new openai_1.Configuration({
19
+ organization,
20
+ apiKey
21
+ });
22
+ const client = new openai_1.OpenAIApi(configuration);
23
+ integration_base_1.ConnectionManager.addConnectionInstance(connection, client);
24
+ integration_base_1.ConnectionManager.logger.info(`openai-connector connection(${connection.name}:${connection.endpoint}) is connected`);
25
+ }
26
+ async disconnect(connection) {
27
+ const client = integration_base_1.ConnectionManager.getConnectionInstance(connection);
28
+ // TODO implement how to stop connection
29
+ integration_base_1.ConnectionManager.removeConnectionInstance(connection);
30
+ integration_base_1.ConnectionManager.logger.info(`openai-connector connection(${connection.name}) is disconnected`);
31
+ }
32
+ get parameterSpec() {
33
+ return [
34
+ {
35
+ type: 'string',
36
+ name: 'organization',
37
+ label: 'organization'
38
+ },
39
+ {
40
+ type: 'string',
41
+ name: 'apiKey',
42
+ label: 'api-key'
43
+ }
44
+ ];
45
+ }
46
+ get taskPrefixes() {
47
+ return ['openai'];
48
+ }
49
+ get description() {
50
+ return 'Graph API Connector';
51
+ }
52
+ get help() {
53
+ return 'integration/connector/openai-connector';
54
+ }
55
+ }
56
+ exports.OpenAIConnector = OpenAIConnector;
57
+ integration_base_1.ConnectionManager.registerConnector('openai-connector', new OpenAIConnector());
58
+ //# sourceMappingURL=openai-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/openai-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAC/E,mCAAiD;AAEjD,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAiB;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E,QAAQ;gBACd,KAAK,EAAE,SAAS;aACjB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,wCAAwC,CAAA;IACjD,CAAC;CACF;AA9DD,0CA8DC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\nimport { Configuration, OpenAIApi } from 'openai'\n\nexport class OpenAIConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('openai-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri,\n params: { organization, apiKey }\n } = connection\n\n if (!organization || !apiKey) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const configuration = new Configuration({\n organization,\n apiKey\n })\n const client = new OpenAIApi(configuration)\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(`openai-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`openai-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'organization',\n label: 'organization'\n },\n {\n type: 'string',\n name: 'apiKey',\n label: 'api-key'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['openai']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n\n get help() {\n return 'integration/connector/openai-connector'\n }\n}\n\nConnectionManager.registerConnector('openai-connector', new OpenAIConnector())\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./connector");
4
+ require("./task");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,uBAAoB;AACpB,kBAAe","sourcesContent":["import './connector'\nimport './task'\n"]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ const integration_base_2 = require("@things-factory/integration-base");
5
+ async function GetUsers(step, context) {
6
+ var { connection: connectionName, params: stepOptions } = step;
7
+ var { select, page = 0, limit = 30, orderby } = stepOptions || {};
8
+ var { domain, data, variables } = context;
9
+ var client = integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
10
+ select || (select = 'displayName,id,mail');
11
+ orderby || (orderby = 'displayName');
12
+ try {
13
+ const result = await (client === null || client === void 0 ? void 0 : client.api('/users').select(select.split(',')).top(limit).orderby(orderby).get());
14
+ return {
15
+ data: result
16
+ };
17
+ }
18
+ catch (err) {
19
+ console.error(err);
20
+ throw err;
21
+ }
22
+ }
23
+ GetUsers.parameterSpec = [
24
+ {
25
+ type: 'string',
26
+ name: 'select',
27
+ label: 'select'
28
+ },
29
+ {
30
+ type: 'number',
31
+ name: 'page',
32
+ label: 'page'
33
+ },
34
+ {
35
+ type: 'number',
36
+ name: 'limit',
37
+ label: 'limit'
38
+ },
39
+ {
40
+ type: 'string',
41
+ name: 'orderby',
42
+ label: 'orderby'
43
+ }
44
+ ];
45
+ GetUsers.help = 'integration/msgraph/task/get-users';
46
+ integration_base_1.TaskRegistry.registerTaskHandler('msgraph-get-users', GetUsers);
47
+ //# sourceMappingURL=get-users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-users.js","sourceRoot":"","sources":["../../../server/engine/task/get-users.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uE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QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AACD,QAAQ,CAAC,IAAI,GAAG,oCAAoC,CAAA;AAEpD,+BAAY,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nasync function GetUsers(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var { select, page = 0, limit = 30, orderby } = stepOptions || {}\n var { domain, data, variables } = context\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n select ||= 'displayName,id,mail'\n orderby ||= 'displayName'\n\n try {\n const result = await client?.api('/users').select(select.split(',')).top(limit).orderby(orderby).get()\n\n return {\n data: result\n }\n } catch (err) {\n console.error(err)\n throw err\n }\n}\n\nGetUsers.parameterSpec = [\n {\n type: 'string',\n name: 'select',\n label: 'select'\n },\n {\n type: 'number',\n name: 'page',\n label: 'page'\n },\n {\n type: 'number',\n name: 'limit',\n label: 'limit'\n },\n {\n type: 'string',\n name: 'orderby',\n label: 'orderby'\n }\n]\nGetUsers.help = 'integration/msgraph/task/get-users'\n\nTaskRegistry.registerTaskHandler('msgraph-get-users', GetUsers)\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./openai-completion");
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,+BAA4B","sourcesContent":["import './openai-completion'\n"]}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ async function modbusRead(step, { logger, domain }) {
5
+ var { connection, params: { objectType = 'coil', address, quantity = 1 } } = step;
6
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
+ if (!client) {
8
+ throw new Error(`no connection : ${connection}`);
9
+ }
10
+ // NOTICE: Keep the previous codes to track the changes before applying keepalive
11
+ // var response
12
+ // switch (objectType) {
13
+ // case 'descrete input':
14
+ // response = await client.readCoils(address, quantity)
15
+ // break
16
+ // case 'input register':
17
+ // response = await client.readDiscreteInputs(address, quantity)
18
+ // break
19
+ // case 'holding register':
20
+ // response = await client.readHoldingRegisters(address, quantity)
21
+ // break
22
+ // default:
23
+ // response = await client.readCoils(address, quantity)
24
+ // }
25
+ // var data = response && response.response._body.valuesAsArray.slice(0, quantity)
26
+ // logger.info(`${JSON.stringify(data)}`)
27
+ // return {
28
+ // data
29
+ // }
30
+ var { readModBus } = client;
31
+ var content = await readModBus(objectType, address, quantity, { logger });
32
+ return content;
33
+ }
34
+ modbusRead.parameterSpec = [
35
+ {
36
+ type: 'select',
37
+ name: 'objectType',
38
+ label: 'object-type',
39
+ property: {
40
+ options: ['', 'coil', 'descrete input', 'input register', 'holding register']
41
+ }
42
+ },
43
+ {
44
+ type: 'number',
45
+ name: 'address',
46
+ label: 'address'
47
+ },
48
+ {
49
+ type: 'number',
50
+ name: 'quantity',
51
+ label: 'quantity'
52
+ }
53
+ ];
54
+ integration_base_1.TaskRegistry.registerTaskHandler('modbus-read', modbusRead);
55
+ //# sourceMappingURL=modbus-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modbus-read.js","sourceRoot":"","sources":["../../../server/engine/task/modbus-read.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAChD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE,EACvD,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,iFAAiF;IACjF,iBAAiB;IAEjB,0BAA0B;IAC1B,6BAA6B;IAC7B,6DAA6D;IAC7D,cAAc;IACd,6BAA6B;IAC7B,sEAAsE;IACtE,cAAc;IACd,+BAA+B;IAC/B,wEAAwE;IACxE,cAAc;IACd,eAAe;IACf,6DAA6D;IAC7D,MAAM;IAEN,oFAAoF;IACpF,2CAA2C;IAE3C,aAAa;IACb,WAAW;IACX,MAAM;IAEN,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;IAC3B,IAAI,OAAO,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IACzE,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,UAAU,CAAC,aAAa,GAAG;IACzB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;SAC9E;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\n\nasync function modbusRead(step, { logger, domain }) {\n var {\n connection,\n params: { objectType = 'coil', address, quantity = 1 }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n // NOTICE: Keep the previous codes to track the changes before applying keepalive\n // var response\n\n // switch (objectType) {\n // case 'descrete input':\n // response = await client.readCoils(address, quantity)\n // break\n // case 'input register':\n // response = await client.readDiscreteInputs(address, quantity)\n // break\n // case 'holding register':\n // response = await client.readHoldingRegisters(address, quantity)\n // break\n // default:\n // response = await client.readCoils(address, quantity)\n // }\n\n // var data = response && response.response._body.valuesAsArray.slice(0, quantity)\n // logger.info(`${JSON.stringify(data)}`)\n\n // return {\n // data\n // }\n\n var { readModBus } = client\n var content = await readModBus(objectType, address, quantity, { logger })\n return content\n}\n\nmodbusRead.parameterSpec = [\n {\n type: 'select',\n name: 'objectType',\n label: 'object-type',\n property: {\n options: ['', 'coil', 'descrete input', 'input register', 'holding register']\n }\n },\n {\n type: 'number',\n name: 'address',\n label: 'address'\n },\n {\n type: 'number',\n name: 'quantity',\n label: 'quantity'\n }\n]\n\nTaskRegistry.registerTaskHandler('modbus-read', modbusRead)\n"]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ async function modbusWriteSingle(step, { logger, domain }) {
5
+ var { connection, params: { objectType = 'coil', address, value } } = step;
6
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
+ if (!client) {
8
+ throw new Error(`no connection : ${connection}`);
9
+ }
10
+ // NOTICE: Keep the previous codes to track the changes before applying keepalive
11
+ // var response
12
+ // switch (objectType) {
13
+ // case 'holding register':
14
+ // await client.writeSingleRegister(address, parseInt(value))
15
+ // response = await client.readHoldingRegisters(address, 1)
16
+ // break
17
+ // default:
18
+ // await client.writeSingleCoil(address, !!value)
19
+ // response = await client.readCoils(address, 1)
20
+ // }
21
+ // var data = response && response.response._body.valuesAsArray[0]
22
+ // logger.info(data)
23
+ // return {
24
+ // data
25
+ // }
26
+ var { writeSingleModBus } = client;
27
+ var content = await writeSingleModBus(objectType, address, value, { logger });
28
+ return content;
29
+ }
30
+ modbusWriteSingle.parameterSpec = [
31
+ {
32
+ type: 'select',
33
+ name: 'objectType',
34
+ label: 'object-type',
35
+ property: {
36
+ options: ['', 'coil', 'holding register']
37
+ }
38
+ },
39
+ {
40
+ type: 'number',
41
+ name: 'address',
42
+ label: 'address'
43
+ },
44
+ {
45
+ type: 'number',
46
+ name: 'value',
47
+ label: 'value'
48
+ }
49
+ ];
50
+ integration_base_1.TaskRegistry.registerTaskHandler('modbus-write-single', modbusWriteSingle);
51
+ //# sourceMappingURL=modbus-write-single.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modbus-write-single.js","sourceRoot":"","sources":["../../../server/engine/task/modbus-write-single.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACvD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,UAAU,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAChD,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,iFAAiF;IACjF,iBAAiB;IAEjB,0BAA0B;IAC1B,+BAA+B;IAC/B,mEAAmE;IACnE,iEAAiE;IACjE,cAAc;IACd,eAAe;IACf,uDAAuD;IACvD,sDAAsD;IACtD,MAAM;IAEN,oEAAoE;IACpE,sBAAsB;IAEtB,aAAa;IACb,WAAW;IACX,MAAM;IAEN,IAAI,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAA;IAClC,IAAI,OAAO,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7E,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,iBAAiB,CAAC,aAAa,GAAG;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,kBAAkB,CAAC;SAC1C;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\n\nasync function modbusWriteSingle(step, { logger, domain }) {\n var {\n connection,\n params: { objectType = 'coil', address, value }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n // NOTICE: Keep the previous codes to track the changes before applying keepalive\n // var response\n\n // switch (objectType) {\n // case 'holding register':\n // await client.writeSingleRegister(address, parseInt(value))\n // response = await client.readHoldingRegisters(address, 1)\n // break\n // default:\n // await client.writeSingleCoil(address, !!value)\n // response = await client.readCoils(address, 1)\n // }\n\n // var data = response && response.response._body.valuesAsArray[0]\n // logger.info(data)\n\n // return {\n // data\n // }\n\n var { writeSingleModBus } = client\n var content = await writeSingleModBus(objectType, address, value, { logger })\n return content\n}\n\nmodbusWriteSingle.parameterSpec = [\n {\n type: 'select',\n name: 'objectType',\n label: 'object-type',\n property: {\n options: ['', 'coil', 'holding register']\n }\n },\n {\n type: 'number',\n name: 'address',\n label: 'address'\n },\n {\n type: 'number',\n name: 'value',\n label: 'value'\n }\n]\n\nTaskRegistry.registerTaskHandler('modbus-write-single', modbusWriteSingle)\n"]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ const integration_base_2 = require("@things-factory/integration-base");
5
+ async function MsGraphGetUsers(step, context) {
6
+ var { connection: connectionName, params: stepOptions } = step;
7
+ var { select, page = 0, limit = 30, orderby } = stepOptions || {};
8
+ var { domain, data, variables } = context;
9
+ var client = integration_base_2.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
10
+ select || (select = 'displayName,id,mail');
11
+ orderby || (orderby = 'displayName');
12
+ const result = await (client === null || client === void 0 ? void 0 : client.api('/users').select(select.split(',')).top(limit).orderby(orderby).get());
13
+ return {
14
+ data: result
15
+ };
16
+ }
17
+ MsGraphGetUsers.parameterSpec = [
18
+ {
19
+ type: 'string',
20
+ name: 'select',
21
+ label: 'select'
22
+ },
23
+ {
24
+ type: 'number',
25
+ name: 'page',
26
+ label: 'page'
27
+ },
28
+ {
29
+ type: 'number',
30
+ name: 'limit',
31
+ label: 'limit'
32
+ },
33
+ {
34
+ type: 'string',
35
+ name: 'orderby',
36
+ label: 'orderby'
37
+ }
38
+ ];
39
+ MsGraphGetUsers.help = 'integration/msgraph/task/get-users';
40
+ integration_base_1.TaskRegistry.registerTaskHandler('msgraph-get-users', MsGraphGetUsers);
41
+ //# sourceMappingURL=msgraph-get-users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgraph-get-users.js","sourceRoot":"","sources":["../../../server/engine/task/msgraph-get-users.ts"],"names":[],"mappings":";;AAAA,uEAA+D;AAC/D,uEAAoE;AAEpE,KAAK,UAAU,eAAe,CAAC,IAAI,EAAE,OAAO;IAC1C,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IACjE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAElF,MAAM,KAAN,MAAM,GAAK,qBAAqB,EAAA;IAChC,OAAO,KAAP,OAAO,GAAK,aAAa,EAAA;IAEzB,MAAM,MAAM,GAAG,MAAM,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAA,CAAA;IAEtG,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAA;AACH,CAAC;AAED,eAAe,CAAC,aAAa,GAAG;IAC9B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AACD,eAAe,CAAC,IAAI,GAAG,oCAAoC,CAAA;AAE3D,+BAAY,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '@things-factory/integration-base'\nimport { ConnectionManager } from '@things-factory/integration-base'\n\nasync function MsGraphGetUsers(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var { select, page = 0, limit = 30, orderby } = stepOptions || {}\n var { domain, data, variables } = context\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n select ||= 'displayName,id,mail'\n orderby ||= 'displayName'\n\n const result = await client?.api('/users').select(select.split(',')).top(limit).orderby(orderby).get()\n\n return {\n data: result\n }\n}\n\nMsGraphGetUsers.parameterSpec = [\n {\n type: 'string',\n name: 'select',\n label: 'select'\n },\n {\n type: 'number',\n name: 'page',\n label: 'page'\n },\n {\n type: 'number',\n name: 'limit',\n label: 'limit'\n },\n {\n type: 'string',\n name: 'orderby',\n label: 'orderby'\n }\n]\nMsGraphGetUsers.help = 'integration/msgraph/task/get-users'\n\nTaskRegistry.registerTaskHandler('msgraph-get-users', MsGraphGetUsers)\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ const utils_1 = require("@things-factory/utils");
5
+ async function OpenAICompletion(step, context) {
6
+ var { connection: connectionName, params: stepOptions } = step;
7
+ var { prompt } = stepOptions || {};
8
+ var { domain, data, variables } = context;
9
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
10
+ prompt = (0, utils_1.access)(prompt, data);
11
+ const completion = await client.createChatCompletion({
12
+ model: 'gpt-3.5-turbo',
13
+ messages: [{ role: 'user', content: prompt }]
14
+ });
15
+ return {
16
+ data: completion.data.choices[0].message.content
17
+ };
18
+ }
19
+ OpenAICompletion.parameterSpec = [
20
+ {
21
+ type: 'string',
22
+ name: 'prompt',
23
+ label: 'prompt',
24
+ placeholder: 'accessor for prompt'
25
+ }
26
+ ];
27
+ OpenAICompletion.help = 'integration/task/openai-completion';
28
+ integration_base_1.TaskRegistry.registerTaskHandler('openai-completion', OpenAICompletion);
29
+ //# sourceMappingURL=openai-completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-completion.js","sourceRoot":"","sources":["../../../server/engine/task/openai-completion.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,iDAA8C;AAE9C,KAAK,UAAU,gBAAgB,CAAC,IAAI,EAAE,OAAO;IAC3C,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAClC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAClF,MAAM,GAAG,IAAA,cAAM,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAE7B,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC;QACnD,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;KAC9C,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;KACjD,CAAA;AACH,CAAC;AAED,gBAAgB,CAAC,aAAa,GAAG;IAC/B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,qBAAqB;KACnC;CACF,CAAA;AACD,gBAAgB,CAAC,IAAI,GAAG,oCAAoC,CAAA;AAE5D,+BAAY,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAA","sourcesContent":["import { TaskRegistry, ConnectionManager } from '@things-factory/integration-base'\nimport { access } from '@things-factory/utils'\n\nasync function OpenAICompletion(step, context) {\n var { connection: connectionName, params: stepOptions } = step\n var { prompt } = stepOptions || {}\n var { domain, data, variables } = context\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n prompt = access(prompt, data)\n\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [{ role: 'user', content: prompt }]\n })\n\n return {\n data: completion.data.choices[0].message.content\n }\n}\n\nOpenAICompletion.parameterSpec = [\n {\n type: 'string',\n name: 'prompt',\n label: 'prompt',\n placeholder: 'accessor for prompt'\n }\n]\nOpenAICompletion.help = 'integration/task/openai-completion'\n\nTaskRegistry.registerTaskHandler('openai-completion', OpenAICompletion)\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./engine");
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;AAAA,oBAAiB","sourcesContent":["import './engine'\n"]}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/openai/dist/configuration.d.ts","../../../node_modules/openai/node_modules/axios/index.d.ts","../../../node_modules/openai/dist/base.d.ts","../../../node_modules/openai/dist/api.d.ts","../../../node_modules/openai/dist/index.d.ts","../server/engine/connector/openai-connector.ts","../server/engine/connector/index.ts","../server/engine/task/openai-completion.ts","../server/engine/task/index.ts","../server/engine/index.ts","../server/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/dom-events.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../node_modules/chalk/index.d.ts","../../../node_modules/@sinclair/typebox/typebox.d.ts","../../../node_modules/@jest/schemas/build/index.d.ts","../../../node_modules/pretty-format/build/index.d.ts","../../../node_modules/jest-diff/build/index.d.ts","../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../node_modules/expect/build/index.d.ts","../../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9",{"version":"3aafcb693fe5b5c3bd277bd4c3a617b53db474fe498fc5df067c5603b1eebde7","affectsGlobalScope":true},{"version":"f3d4da15233e593eacb3965cde7960f3fddf5878528d882bcedd5cbaba0193c7","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"2768ef564cfc0689a1b76106c421a2909bdff0acbe87da010785adab80efdd5c","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},"f1c9fe42b65437a61104e601eb298c5c859fb522b483f1bdb700eed67a16f980","830839b68ea9b3b3a89f3bd3f5b6953fb44b80127ee61bc153f0634bc35b8e43","2808645b990069e5f8b5ff14c9f1e6077eb642583c3f7854012d60757f23c70e","addd3910212f0470469b51c90dab834027a53a46c143b5235d97fb05a698f9c5","7e512e924bc5c45dda4984b0e2f3b3c8f77ef7cc50eacce7c7f2b4e71b7af96b","5efed25b13d02c3c027963b9e3572343ec041e50c4d61a95176ced9df4154063",{"version":"1614bdb588d48461e82577527afcbefed7e5f6239d1449b1b9125aac2fc33635","signature":"0eae79bc6c10119f9ef33c3a6fa304dbb75bc74e676cc26c962858dca5e07b8c"},{"version":"ff925f75cc5caf8559b0f9df3a793fec04b3ddbbbe8799f7db88e7bb5cfbfb66","signature":"80931c364f6d23ed335a4155507edb70cd1fcb184fb3993f2cb1f17fb02fc177"},{"version":"824564d3eb55205530654c01b8498efd944676a2af28b1f17c74a8a86d96a4c1","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"ac2422fc480b25ccfddb41b9af06116579ece8dbab67483c7862c4c6c9073e7c","signature":"51e6dabea461ba1d40868f5dfc64f878670a6dacf98b59ae9eed29bf048177b3"},"8547694bbf35e324d5bb64215ae218ab372807c759be08f9ce27a8adfc9af9fb","336b6d64b4cff6c2e09100b496e9870743d9c8005e718c18e6200bce7ec2975c","7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"57b6cb95756d1fe3bfeb20205de27b0c5406e4a86e130c6dfa6bd92af641e09d","affectsGlobalScope":true},"11e2d554398d2bd460e7d06b2fa5827a297c8acfbe00b4f894a224ac0862857f",{"version":"e193e634a99c9c1d71f1c6e4e1567a4a73584328d21ea02dd5cddbaad6693f61","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","e596c9bb2f29a2699fdd4ae89139612652245192f67f45617c5a4b20832aaae9","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","1cdcfc1f624d6c08aa12c73935f6e13f095919cd99edf95752951796eb225729","216717f17c095cde1dc19375e1ab3af0a4a485355860c077a4f9d6ea59fab5b5","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"80473bd0dd90ca1e166514c2dfead9d5803f9c51418864ca35abbeec6e6847e1","1c84b46267610a34028edfd0d035509341751262bac1062857f3c8df7aff7153","e6c86d83bd526c8bdb5d0bf935b8e72ce983763d600743f74d812fdf4abf4df6","a3d541d303ee505053f5dcbf9fafb65cac3d5631037501cd616195863a6c5740","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"bcebb922784739bdb34c18ee51095d25a92b560c78ccd2eaacd6bd00f7443d83","7ee6ed878c4528215c82b664fe0cfe80e8b4da6c0d4cc80869367868774db8b1","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"0715e4cd28ad471b2a93f3e552ff51a3ae423417a01a10aa1d3bc7c6b95059d6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","7d55d78cd47cf5280643b53434b16c2d9d11d144126932759fbdd51da525eec4","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","f69ff39996a61a0dd10f4bce73272b52e8024a4d58b13ab32bf4712909d0a2b7",{"version":"3c4ba1dd9b12ffa284b565063108f2f031d150ea15b8fafbdc17f5d2a07251f3","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c4577fb855ca259bdbf3ea663ca73988ce5f84251a92b4aef80a1f4122b6f98e","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"ff07a9a03c65732ccc59b3c65bc584173da093bd563a6565411c01f5703bd3cb","affectsGlobalScope":true},"6de4a219df57d2b27274d59b67708f13c2cbf7ed211abe57d8f9ab8b25cde776","0fe8985a28f82c450a04a6edf1279d7181c0893f37da7d2a27f8efd4fd5edb03","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"d8d555f3d607ecaa18d55de6995ea8f206342ecc93305919eac945c7c78c78c6","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","db25694be959314fd1e868d72e567746db1db9e2001fae545d12d2a8c1bba1b8","43883cf3635bb1846cbdc6c363787b76227677388c74f7313e3f0edb380840fa","2d47012580f859dae201d2eef898a416bdae719dffc087dfd06aefe3de2f9c8d","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","2cec1a31729b9b01e9294c33fc9425d336eff067282809761ad2e74425d6d2a5",{"version":"458e2fd1185e659cb800ef68d01ef77de70dcab8860bedf6d94eaebe736751f1","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":false,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":1,"noEmitOnError":true,"noImplicitAny":false,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":false,"target":4,"useDefineForClassFields":false},"fileIdsList":[[102],[102,112],[102,114,117],[56,102],[59,102],[60,65,93,102],[61,72,73,80,90,101,102],[61,62,72,80,102],[63,102],[64,65,73,81,102],[65,90,98,102],[66,68,72,80,102],[67,102],[68,69,102],[72,102],[70,72,102],[72,73,74,90,101,102],[72,73,74,87,90,93,102],[102,106],[68,75,80,90,101,102],[72,73,75,76,80,90,98,101,102],[75,77,90,98,101,102],[56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108],[72,78,102],[79,101,102],[68,72,80,90,102],[81,102],[82,102],[59,83,102],[84,100,102,106],[85,102],[86,102],[72,87,88,102],[87,89,102,104],[60,72,90,91,92,93,102],[60,90,92,102],[90,91,102],[93,102],[94,102],[72,96,97,102],[96,97,102],[65,80,90,98,102],[99,102],[80,100,102],[60,75,86,101,102],[65,102],[90,102,103],[102,104],[102,105],[60,65,72,74,83,90,101,102,104,106],[90,102,107],[102,110,116],[102,114],[102,111,115],[45,46,47,102],[45,46,102],[45,48,102],[102,113],[44,50,102],[44,49,102],[44,51,53,102],[44,52,102],[44,102],[44,54,102],[50],[52]],"referencedMap":[[110,1],[113,2],[112,1],[118,3],[56,4],[57,4],[59,5],[60,6],[61,7],[62,8],[63,9],[64,10],[65,11],[66,12],[67,13],[68,14],[69,14],[71,15],[70,16],[72,15],[73,17],[74,18],[58,19],[108,1],[75,20],[76,21],[77,22],[109,23],[78,24],[79,25],[80,26],[81,27],[82,28],[83,29],[84,30],[85,31],[86,32],[87,33],[88,33],[89,34],[90,35],[92,36],[91,37],[93,38],[94,39],[95,1],[96,40],[97,41],[98,42],[99,43],[100,44],[101,45],[102,46],[103,47],[104,48],[105,49],[106,50],[107,51],[111,1],[117,52],[115,53],[116,54],[48,55],[47,56],[45,1],[49,57],[46,1],[114,58],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[51,59],[50,60],[54,61],[53,62],[52,63],[55,64]],"exportedModulesMap":[[110,1],[113,2],[112,1],[118,3],[56,4],[57,4],[59,5],[60,6],[61,7],[62,8],[63,9],[64,10],[65,11],[66,12],[67,13],[68,14],[69,14],[71,15],[70,16],[72,15],[73,17],[74,18],[58,19],[108,1],[75,20],[76,21],[77,22],[109,23],[78,24],[79,25],[80,26],[81,27],[82,28],[83,29],[84,30],[85,31],[86,32],[87,33],[88,33],[89,34],[90,35],[92,36],[91,37],[93,38],[94,39],[95,1],[96,40],[97,41],[98,42],[99,43],[100,44],[101,45],[102,46],[103,47],[104,48],[105,49],[106,50],[107,51],[111,1],[117,52],[115,53],[116,54],[48,55],[47,56],[45,1],[49,57],[46,1],[114,58],[44,1],[8,1],[9,1],[11,1],[10,1],[2,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[3,1],[4,1],[23,1],[20,1],[21,1],[22,1],[24,1],[25,1],[26,1],[5,1],[27,1],[28,1],[29,1],[30,1],[6,1],[34,1],[31,1],[32,1],[33,1],[35,1],[7,1],[36,1],[41,1],[42,1],[37,1],[38,1],[39,1],[40,1],[1,1],[43,1],[51,65],[54,61],[53,66],[55,64]],"semanticDiagnosticsPerFile":[110,113,112,118,56,57,59,60,61,62,63,64,65,66,67,68,69,71,70,72,73,74,58,108,75,76,77,109,78,79,80,81,82,83,84,85,86,87,88,89,90,92,91,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,111,117,115,116,48,47,45,49,46,114,44,8,9,11,10,2,12,13,14,15,16,17,18,19,3,4,23,20,21,22,24,25,26,5,27,28,29,30,6,34,31,32,33,35,7,36,41,42,37,38,39,40,1,43,51,50,54,53,52,55]},"version":"4.9.5"}
@@ -0,0 +1,21 @@
1
+ # OpenAI Connector
2
+
3
+ OpenAI Connector는 OpenAI에서 제공하는 API를 사용하여 대화형 인공지능 모델인 ChatGPT를 연결해주는 도구입니다.
4
+
5
+ ## OpenAI Connector의 기능
6
+
7
+ OpenAI Connector를 사용하면 다음과 같은 기능을 수행할 수 있습니다.
8
+
9
+ - 대화형 인공지능 모델인 ChatGPT를 쉽게 사용할 수 있습니다.
10
+ - 간단한 API 요청을 통해 대화형 인공지능 모델을 활용할 수 있습니다.
11
+ - 다양한 언어로 대화를 할 수 있습니다.
12
+
13
+ ## OpenAI Connector를 사용하는 방법은 어떻게 되나요?
14
+
15
+ OpenAI Connector를 사용하기 위해서는 OpenAI에서 발급하는 API 키가 필요합니다. API 키를 발급받은 후, API 요청을 보내면 됩니다. API 요청을 보낼 때는 HTTP POST 요청을 사용하며, 요청 데이터는 JSON 형식으로 작성합니다.
16
+
17
+ ## 마무리
18
+
19
+ OpenAI Connector를 사용하면 대화형 인공지능 모델인 ChatGPT를 쉽게 사용할 수 있습니다. 간단한 API 요청만으로 다양한 언어로 대화를 할 수 있으며, 이를 활용하여 다양한 프로젝트를 구현할 수 있습니다.
20
+
21
+ (이 도움말은 ChatGPT가 작성하였습니다.)
@@ -0,0 +1,21 @@
1
+ # What is OpenAI Connector?
2
+
3
+ OpenAI Connector is a tool that connects the conversational AI model ChatGPT using the API provided by OpenAI.
4
+
5
+ ## What are the features of OpenAI Connector?
6
+
7
+ Using OpenAI Connector, you can perform the following functions:
8
+
9
+ - Easily use the conversational AI model, ChatGPT.
10
+ - Utilize the conversational AI model through simple API requests.
11
+ - Have conversations in various languages.
12
+
13
+ ## How do I use OpenAI Connector?
14
+
15
+ To use OpenAI Connector, you need an API key issued by OpenAI. Once you have obtained an API key, you can send API requests. API requests are sent using HTTP POST requests, and the request data is written in JSON format.
16
+
17
+ ## Conclusion
18
+
19
+ With OpenAI Connector, you can easily use the conversational AI model ChatGPT. You can have conversations in various languages by making simple API requests, and you can implement various projects using this tool.
20
+
21
+ (This help was created by ChatGPT.)
@@ -0,0 +1,13 @@
1
+ # OpenAI Completion
2
+
3
+ ## 사용된 AI 모델
4
+
5
+ ```
6
+ gpt-3.5-turbo
7
+ ```
8
+
9
+ ## paramters
10
+
11
+ - prompt
12
+ - prompt로 사용될 [데이타 접근자](../concept/data-accessor.md)
13
+ - ChatGPT의 prompt는 대화의 시작점으로 사용자가 제공한 입력을 나타냅니다. 사용자가 질문하거나 명령을 내릴 때 입력할 수 있는 모든 텍스트 또는 문장이 prompt가 될 수 있습니다. 예를 들어 "오늘 날씨가 어때요?" 또는 "최근에 본 좋은 영화를 추천해 주세요."와 같은 것들이 prompt로 사용될 수 있습니다. 이 prompt를 기반으로 ChatGPT는 적절한 응답을 생성하고 대화를 이어나갈 수 있습니다.
@@ -0,0 +1,14 @@
1
+ # OpenAI Completion
2
+
3
+ ## used AI model
4
+
5
+ ```
6
+ gpt-3.5-turbo
7
+ ```
8
+
9
+ ## parameters
10
+
11
+ - [prompt](../concept/data-accessor.md)
12
+ - data [accessor](../concept/data-accessor.md) to be used as a prompt
13
+ - The prompt in ChatGPT refers to the input provided by the user, which serves as the starting point for a conversation. The prompt can be any text or sentence that the user types when asking a question or making a statement. For example, "What's the weather like today?" or "Can you recommend a good movie you recently watched?" can be used as prompts. Based on this prompt, ChatGPT generates an appropriate response and helps continue the conversation.
14
+ - accessor
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@things-factory/integration-openai",
3
+ "version": "6.0.43",
4
+ "main": "dist-server/index.js",
5
+ "browser": "client/index.js",
6
+ "things-factory": true,
7
+ "author": "heartyoh <heartyoh@hatiolab.com>",
8
+ "description": "Module to provide OpenAI connection on integration engine",
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "@things-factory:registry": "https://registry.npmjs.org"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/hatiolab/things-factory.git",
16
+ "directory": "packages/integration-openai"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc --p tsconfig.json",
20
+ "build:server": "npm run clean:server && tsc",
21
+ "clean:server": "rm -rf dist-server",
22
+ "clean": "npm run clean:server"
23
+ },
24
+ "dependencies": {
25
+ "@things-factory/integration-base": "^6.0.43",
26
+ "openai": "^3.2.1"
27
+ },
28
+ "gitHead": "08a649f00a8f0f489142207cb34de4b28c2e5630"
29
+ }
@@ -0,0 +1 @@
1
+ import './openai-connector'
@@ -0,0 +1,71 @@
1
+ /* fetch polyfil */
2
+ import 'cross-fetch/polyfill'
3
+
4
+ import { ConnectionManager, Connector } from '@things-factory/integration-base'
5
+ import { Configuration, OpenAIApi } from 'openai'
6
+
7
+ export class OpenAIConnector implements Connector {
8
+ async ready(connectionConfigs) {
9
+ await Promise.all(connectionConfigs.map(this.connect.bind(this)))
10
+
11
+ ConnectionManager.logger.info('openai-connector connections are ready')
12
+ }
13
+
14
+ async connect(connection) {
15
+ var {
16
+ endpoint: uri,
17
+ params: { organization, apiKey }
18
+ } = connection
19
+
20
+ if (!organization || !apiKey) {
21
+ throw new Error('Connection parameters should not be undefined')
22
+ }
23
+
24
+ const configuration = new Configuration({
25
+ organization,
26
+ apiKey
27
+ })
28
+ const client = new OpenAIApi(configuration)
29
+
30
+ ConnectionManager.addConnectionInstance(connection, client)
31
+
32
+ ConnectionManager.logger.info(`openai-connector connection(${connection.name}:${connection.endpoint}) is connected`)
33
+ }
34
+
35
+ async disconnect(connection) {
36
+ const client = ConnectionManager.getConnectionInstance(connection)
37
+ // TODO implement how to stop connection
38
+ ConnectionManager.removeConnectionInstance(connection)
39
+
40
+ ConnectionManager.logger.info(`openai-connector connection(${connection.name}) is disconnected`)
41
+ }
42
+
43
+ get parameterSpec() {
44
+ return [
45
+ {
46
+ type: 'string',
47
+ name: 'organization',
48
+ label: 'organization'
49
+ },
50
+ {
51
+ type: 'string',
52
+ name: 'apiKey',
53
+ label: 'api-key'
54
+ }
55
+ ]
56
+ }
57
+
58
+ get taskPrefixes() {
59
+ return ['openai']
60
+ }
61
+
62
+ get description() {
63
+ return 'Graph API Connector'
64
+ }
65
+
66
+ get help() {
67
+ return 'integration/connector/openai-connector'
68
+ }
69
+ }
70
+
71
+ ConnectionManager.registerConnector('openai-connector', new OpenAIConnector())
@@ -0,0 +1,2 @@
1
+ import './connector'
2
+ import './task'
@@ -0,0 +1 @@
1
+ import './openai-completion'
@@ -0,0 +1,32 @@
1
+ import { TaskRegistry, ConnectionManager } from '@things-factory/integration-base'
2
+ import { access } from '@things-factory/utils'
3
+
4
+ async function OpenAICompletion(step, context) {
5
+ var { connection: connectionName, params: stepOptions } = step
6
+ var { prompt } = stepOptions || {}
7
+ var { domain, data, variables } = context
8
+
9
+ var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
10
+ prompt = access(prompt, data)
11
+
12
+ const completion = await client.createChatCompletion({
13
+ model: 'gpt-3.5-turbo',
14
+ messages: [{ role: 'user', content: prompt }]
15
+ })
16
+
17
+ return {
18
+ data: completion.data.choices[0].message.content
19
+ }
20
+ }
21
+
22
+ OpenAICompletion.parameterSpec = [
23
+ {
24
+ type: 'string',
25
+ name: 'prompt',
26
+ label: 'prompt',
27
+ placeholder: 'accessor for prompt'
28
+ }
29
+ ]
30
+ OpenAICompletion.help = 'integration/task/openai-completion'
31
+
32
+ TaskRegistry.registerTaskHandler('openai-completion', OpenAICompletion)
@@ -0,0 +1 @@
1
+ import './engine'
@@ -0,0 +1 @@
1
+ export default {}
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}