@receptron/graphai_cli 2.0.1 → 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.
@@ -42,6 +42,7 @@ const graphai_1 = require("graphai");
42
42
  const packages = __importStar(require("@graphai/agents"));
43
43
  const token_bound_string_agent_1 = require("@graphai/token_bound_string_agent");
44
44
  const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
45
+ const stream_agent_filter_1 = require("@graphai/stream_agent_filter");
45
46
  const fs_1 = __importDefault(require("fs"));
46
47
  const path_1 = __importDefault(require("path"));
47
48
  const yaml_1 = __importDefault(require("yaml"));
@@ -87,7 +88,36 @@ const main = async () => {
87
88
  console.log(yaml_1.default.stringify(graph_data, null, 2));
88
89
  return;
89
90
  }
90
- const graph = new graphai_1.GraphAI(graph_data, agents);
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
+ };
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
+ }
112
+ process.stdout.write(data);
113
+ });
114
+ const agentFilters = [
115
+ {
116
+ name: "consoleStreamAgentFilter",
117
+ agent: consoleStreamAgentFilter,
118
+ },
119
+ ];
120
+ const graph = new graphai_1.GraphAI(graph_data, agents, { agentFilters });
91
121
  if (args_1.args.verbose) {
92
122
  graph.onLogCallback = test_utils_1.callbackLog;
93
123
  }
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.1",
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": "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": {
@@ -34,10 +34,11 @@
34
34
  "@types/yargs": "^17.0.33"
35
35
  },
36
36
  "dependencies": {
37
- "@graphai/agent_filters": "^2.0.0",
38
37
  "@graphai/agents": "^2.0.4",
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",