@graphai/shell_utilty_agent 0.0.1
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/README.md +53 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/run_shell_agent.d.ts +12 -0
- package/lib/run_shell_agent.js +103 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
# shell_util_agent for GraphAI
|
|
3
|
+
|
|
4
|
+
shell utility agent
|
|
5
|
+
|
|
6
|
+
### Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
yarn add shell_util_agent
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { GraphAI } from "graphai";
|
|
17
|
+
import { runShellAgent } from "shell_util_agent";
|
|
18
|
+
|
|
19
|
+
const agents = { runShellAgent };
|
|
20
|
+
|
|
21
|
+
const graph = new GraphAI(graph_data, agents);
|
|
22
|
+
const result = await graph.run();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Agents description
|
|
26
|
+
- runShellAgent - shell utility agent
|
|
27
|
+
|
|
28
|
+
### Input/Output/Params Schema & samples
|
|
29
|
+
- [runShellAgent](https://github.com/receptron/graphai/blob/main/docs/agentDocs/system/runShellAgent.md)
|
|
30
|
+
|
|
31
|
+
### Input/Params example
|
|
32
|
+
- runShellAgent
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
{
|
|
36
|
+
"inputs": {
|
|
37
|
+
"command": "echo 1"
|
|
38
|
+
},
|
|
39
|
+
"params": {
|
|
40
|
+
"baseDir": "./"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runShellAgent = void 0;
|
|
7
|
+
const run_shell_agent_1 = __importDefault(require("./run_shell_agent"));
|
|
8
|
+
exports.runShellAgent = run_shell_agent_1.default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AgentFunction, AgentFunctionInfo } from "graphai";
|
|
2
|
+
export declare const runShellCommand: (command: string, path?: string) => Promise<unknown>;
|
|
3
|
+
export declare const runShellAgent: AgentFunction<null, {
|
|
4
|
+
text?: string | unknown;
|
|
5
|
+
error?: unknown;
|
|
6
|
+
}, {
|
|
7
|
+
command: string;
|
|
8
|
+
baseDir?: string;
|
|
9
|
+
dirs?: string[];
|
|
10
|
+
}>;
|
|
11
|
+
declare const runShellAgentInfo: AgentFunctionInfo;
|
|
12
|
+
export default runShellAgentInfo;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runShellAgent = exports.runShellCommand = void 0;
|
|
37
|
+
const child_process_1 = require("child_process");
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const runShellCommand = (command, path) => {
|
|
40
|
+
// console.log(command, path);
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
// const exec = require("child_process").exec;
|
|
43
|
+
(0, child_process_1.exec)(command, { cwd: path ?? process.cwd() }, function (error, stdout, stderr) {
|
|
44
|
+
if (error) {
|
|
45
|
+
reject([error, stdout].join("\n"));
|
|
46
|
+
}
|
|
47
|
+
else if (stderr) {
|
|
48
|
+
reject([stderr, stdout].join("\n"));
|
|
49
|
+
}
|
|
50
|
+
else if (stdout) {
|
|
51
|
+
resolve(stdout);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
exports.runShellCommand = runShellCommand;
|
|
57
|
+
const runShellAgent = async ({ namedInputs }) => {
|
|
58
|
+
const { baseDir, dirs, command } = namedInputs;
|
|
59
|
+
const dir = (() => {
|
|
60
|
+
if (dirs) {
|
|
61
|
+
return path.resolve(...dirs);
|
|
62
|
+
}
|
|
63
|
+
if (baseDir) {
|
|
64
|
+
return baseDir;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
try {
|
|
68
|
+
const result = await (0, exports.runShellCommand)(command, dir);
|
|
69
|
+
return {
|
|
70
|
+
text: result
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error instanceof Error) {
|
|
75
|
+
return {
|
|
76
|
+
error: error.message
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
error,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
;
|
|
84
|
+
};
|
|
85
|
+
exports.runShellAgent = runShellAgent;
|
|
86
|
+
const runShellAgentInfo = {
|
|
87
|
+
name: "runShellAgent",
|
|
88
|
+
agent: exports.runShellAgent,
|
|
89
|
+
mock: exports.runShellAgent,
|
|
90
|
+
samples: [{
|
|
91
|
+
params: { baseDir: "./" },
|
|
92
|
+
inputs: { command: "echo 1" },
|
|
93
|
+
result: {
|
|
94
|
+
text: "1\n"
|
|
95
|
+
},
|
|
96
|
+
}],
|
|
97
|
+
description: "shell utility agent",
|
|
98
|
+
category: ["system"],
|
|
99
|
+
author: "isamu arimoto",
|
|
100
|
+
repository: "https://github.com/isamu/graphai-agents",
|
|
101
|
+
license: "MIT",
|
|
102
|
+
};
|
|
103
|
+
exports.default = runShellAgentInfo;
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphai/shell_utilty_agent",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "shell utilty agent",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"./lib"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"eslint": "eslint src --fix",
|
|
12
|
+
"format": "prettier --write '{src,tests}/**/*.ts'",
|
|
13
|
+
"doc": "npx agentdoc",
|
|
14
|
+
"test_run": "node --test --require ts-node/register ./tests/run_*.ts",
|
|
15
|
+
"test": "node --test --require ts-node/register ./tests/test_*.ts",
|
|
16
|
+
"ci": "yarn run format && yarn run eslint && yarn run test && yarn run build"
|
|
17
|
+
},
|
|
18
|
+
"author": "isamu arimoto",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@graphai/vanilla": "^0.2.2",
|
|
22
|
+
"@receptron/agentdoc": "^0.0.6",
|
|
23
|
+
"@receptron/test_utils": "^0.2.2",
|
|
24
|
+
"@types/node": "^22.10.1",
|
|
25
|
+
"eslint": "^9.16.0",
|
|
26
|
+
"graphai": "^0.6.2",
|
|
27
|
+
"prettier": "^3.4.2",
|
|
28
|
+
"ts-node": "^10.9.2",
|
|
29
|
+
"tsconfig-paths": "^4.2.0",
|
|
30
|
+
"typescript": "^5.7.2",
|
|
31
|
+
"typescript-eslint": "^8.17.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {}
|
|
34
|
+
}
|