@receptron/graphai_cli 2.0.2 → 2.0.5

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.
@@ -88,13 +88,33 @@ const main = async () => {
88
88
  console.log(yaml_1.default.stringify(graph_data, null, 2));
89
89
  return;
90
90
  }
91
+ const fds = {};
92
+ let fdsIndex = 3;
93
+ const getFd = (nodeId) => {
94
+ if (fds[nodeId]) {
95
+ return fds[nodeId];
96
+ }
97
+ fds[nodeId] = fs_1.default.createWriteStream(null, { fd: fdsIndex });
98
+ fds[nodeId].on("error", () => {
99
+ // nothing
100
+ });
101
+ fdsIndex = fdsIndex + 1;
102
+ return fds[nodeId];
103
+ };
91
104
  const consoleStreamAgentFilter = (0, stream_agent_filter_1.streamAgentFilterGenerator)((context, data) => {
105
+ const fd = getFd(context.debugInfo.nodeId);
106
+ try {
107
+ fd.write(data);
108
+ }
109
+ catch (e) {
110
+ // nothinfg
111
+ }
92
112
  process.stdout.write(data);
93
113
  });
94
114
  const agentFilters = [
95
115
  {
96
116
  name: "consoleStreamAgentFilter",
97
- agent: consoleStreamAgentFilter
117
+ agent: consoleStreamAgentFilter,
98
118
  },
99
119
  ];
100
120
  const graph = new graphai_1.GraphAI(graph_data, agents, { agentFilters });
package/lib/test.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare const fs: any;
2
+ declare const fd3: any;
3
+ declare let count: number;
4
+ declare const interval: NodeJS.Timeout;
package/lib/test.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ const fs = require("fs");
3
+ const fd3 = fs.createWriteStream(null, { fd: 3 });
4
+ console.log(fd3.writable);
5
+ let count = 0;
6
+ const interval = setInterval(() => {
7
+ process.stdout.write(`stdout: ${count}\n`);
8
+ fd3.write(`fd3: ${count}\n`);
9
+ count++;
10
+ if (count >= 5) {
11
+ clearInterval(interval);
12
+ fd3.end();
13
+ }
14
+ }, 100);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@receptron/graphai_cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "GraphAI command line tools.",
5
5
  "main": "lib/graphai_cli.js",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "test": "yarn run test_sh",
18
18
  "test_sh": "./scripts/test.sh",
19
19
  "test_node": "node --test -r tsconfig-paths/register --require ts-node/register ./test_yaml/test_*.ts",
20
- "cli": "npx ts-node -r tsconfig-paths/register ./src/graphai_cli.ts",
20
+ "cli": "node --require ts-node/register -r tsconfig-paths/register ./src/graphai_cli.ts",
21
21
  "b": "yarn run format && yarn run eslint && yarn run build"
22
22
  },
23
23
  "repository": {