@receptron/graphai_cli 2.0.2 → 2.0.4
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/lib/graphai_cli.js +21 -1
- package/lib/test.d.ts +4 -0
- package/lib/test.js +14 -0
- package/package.json +3 -2
package/lib/graphai_cli.js
CHANGED
|
@@ -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
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.
|
|
3
|
+
"version": "2.0.4",
|
|
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": "
|
|
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": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@graphai/stream_agent_filter": "^2.0.1",
|
|
39
39
|
"@graphai/token_bound_string_agent": "^1.0.1",
|
|
40
40
|
"@graphai/vanilla_node_agents": "^2.0.0",
|
|
41
|
+
"@receptron/graphai_cli": "./receptron-graphai_cli-2.0.3-alpha.tgz",
|
|
41
42
|
"@receptron/test_utils": "^2.0.0",
|
|
42
43
|
"dotenv": "^16.5.0",
|
|
43
44
|
"graphai": "^2.0.5",
|