@roll-agent/octopus-agent 0.0.7 → 0.0.8
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 +11 -7
- package/{octopus_sponge_skill → octopus_skill}/__init__.py +1 -1
- package/package.json +4 -7
- package/pyproject.toml +2 -2
- package/scripts/start-octopus-agent.js +112 -0
- package/src/{octopus_sponge_skill → octopus_skill}/_version.py +1 -1
- package/src/{octopus_sponge_skill → octopus_skill}/main.py +1 -1
- package/bin/check-python.js +0 -85
- package/bin/start-roll-server.js +0 -109
- /package/src/{octopus_sponge_skill → octopus_skill}/__init__.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/__main__.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/agent.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/audit_logger.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/config.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/context.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/device_info.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/llm_sql_generator.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/mcp_client.py +0 -0
- /package/src/{octopus_sponge_skill/roll_server.py → octopus_skill/octopus_run.py} +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/prompt_builder.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/query_sql_cache.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/result_renderer.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/schema_cache.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/schema_context_retriever.py +0 -0
- /package/src/{octopus_sponge_skill → octopus_skill}/sql_generator.py +0 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
## 本地运行
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
python -m
|
|
16
|
+
python -m octopus_skill "查询我能看到的品牌列表"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
运行参数由 Agent 内置;用户本地只需要配置 Sponge MCP Server 地址和 Token。
|
|
@@ -31,9 +31,15 @@ roll agent install @roll-agent/octopus-agent
|
|
|
31
31
|
roll run octopus-agent diagnostic_status --json
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
该 npm package(npm 包)直接包含 Python 源码;`roll agent install` 不会再从 PyPI 下载 `octopus-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
该 npm package(npm 包)直接包含 Python 源码;`roll agent install` 不会再从 PyPI 下载 `octopus-skill`。
|
|
35
|
+
安装机器上需要有 Python 3.11+。Agent 启动时会自动尝试 `python3`、`python`、`py -3.11`、`py -3`。
|
|
36
|
+
如果 Python 命令不在这些名称里,可以配置 `OCTOPUS_PYTHON_COMMAND`(Python 命令),例如:
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
roll config set agents.env.octopus-agent.OCTOPUS_PYTHON_COMMAND "py -3.11"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Windows 用户只要安装 Python 3.11+,通常不需要额外创建 `python3` 别名。
|
|
37
43
|
|
|
38
44
|
### 本地源码注册
|
|
39
45
|
|
|
@@ -85,14 +91,12 @@ roll run octopus-agent query_sponge --json \
|
|
|
85
91
|
"runtime": {"ownership": "on-demand", "transport": "stdio"},
|
|
86
92
|
"start": {
|
|
87
93
|
"command": "node",
|
|
88
|
-
"args": ["
|
|
94
|
+
"args": ["scripts/start-octopus-agent.js"]
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
```
|
|
93
99
|
|
|
94
|
-
`start-roll-server.js` 会按系统选择 Python 命令:Windows 优先 `python`,macOS/Linux 优先 `python3`;都不可用或版本低于 3.11 时会报错提示安装。
|
|
95
|
-
|
|
96
100
|
环境变量可放到 `roll.config.yaml`:
|
|
97
101
|
|
|
98
102
|
```yaml
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
_src_package = Path(__file__).resolve().parent.parent / "src" / "
|
|
5
|
+
_src_package = Path(__file__).resolve().parent.parent / "src" / "octopus_skill"
|
|
6
6
|
if _src_package.exists():
|
|
7
7
|
__path__.append(str(_src_package))
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roll-agent/octopus-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "丸子Agent(Octopus Agent)",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"keywords": [
|
|
@@ -11,13 +11,10 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"postinstall": "node bin/check-python.js"
|
|
16
|
-
},
|
|
17
14
|
"files": [
|
|
18
|
-
"
|
|
19
|
-
"octopus_sponge_skill",
|
|
15
|
+
"octopus_skill",
|
|
20
16
|
"src",
|
|
17
|
+
"scripts",
|
|
21
18
|
"references",
|
|
22
19
|
"SKILL.md",
|
|
23
20
|
"pyproject.toml",
|
|
@@ -33,7 +30,7 @@
|
|
|
33
30
|
"start": {
|
|
34
31
|
"command": "node",
|
|
35
32
|
"args": [
|
|
36
|
-
"
|
|
33
|
+
"scripts/start-octopus-agent.js"
|
|
37
34
|
]
|
|
38
35
|
}
|
|
39
36
|
}
|
package/pyproject.toml
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "octopus-skill"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.8"
|
|
4
4
|
description = "丸子Agent(Octopus Agent)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
dependencies = []
|
|
8
8
|
|
|
9
9
|
[project.scripts]
|
|
10
|
-
octopus-
|
|
10
|
+
octopus-agent = "octopus_skill.main:main"
|
|
11
11
|
|
|
12
12
|
[build-system]
|
|
13
13
|
requires = ["setuptools>=68"]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawn, spawnSync } = require("node:child_process");
|
|
5
|
+
|
|
6
|
+
const MIN_MAJOR = 3;
|
|
7
|
+
const MIN_MINOR = 11;
|
|
8
|
+
const VERSION_CHECK = [
|
|
9
|
+
"import sys",
|
|
10
|
+
`raise SystemExit(0 if sys.version_info >= (${MIN_MAJOR}, ${MIN_MINOR}) else 1)`,
|
|
11
|
+
].join("; ");
|
|
12
|
+
|
|
13
|
+
function splitCommand(value) {
|
|
14
|
+
const parts = [];
|
|
15
|
+
let current = "";
|
|
16
|
+
let quote = null;
|
|
17
|
+
|
|
18
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
19
|
+
const char = value[index];
|
|
20
|
+
if ((char === '"' || char === "'") && quote === null) {
|
|
21
|
+
quote = char;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (char === quote) {
|
|
25
|
+
quote = null;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (/\s/.test(char) && quote === null) {
|
|
29
|
+
if (current) {
|
|
30
|
+
parts.push(current);
|
|
31
|
+
current = "";
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
current += char;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (current) {
|
|
39
|
+
parts.push(current);
|
|
40
|
+
}
|
|
41
|
+
return parts;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function configuredCandidate() {
|
|
45
|
+
const value = process.env.OCTOPUS_PYTHON_COMMAND;
|
|
46
|
+
if (!value) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [command, ...args] = splitCommand(value);
|
|
51
|
+
if (!command) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return { command, args, source: "OCTOPUS_PYTHON_COMMAND" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function pythonCandidates() {
|
|
58
|
+
return [
|
|
59
|
+
configuredCandidate(),
|
|
60
|
+
{ command: "python3", args: [], source: "python3" },
|
|
61
|
+
{ command: "python", args: [], source: "python" },
|
|
62
|
+
{ command: "py", args: ["-3.11"], source: "py -3.11" },
|
|
63
|
+
{ command: "py", args: ["-3"], source: "py -3" },
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isUsablePython(candidate) {
|
|
68
|
+
const result = spawnSync(candidate.command, [...candidate.args, "-c", VERSION_CHECK], {
|
|
69
|
+
encoding: "utf8",
|
|
70
|
+
stdio: "ignore",
|
|
71
|
+
});
|
|
72
|
+
return result.status === 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function findPython() {
|
|
76
|
+
return pythonCandidates().find(isUsablePython);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const python = findPython();
|
|
80
|
+
if (!python) {
|
|
81
|
+
console.error(
|
|
82
|
+
[
|
|
83
|
+
`Octopus Agent requires Python ${MIN_MAJOR}.${MIN_MINOR}+.`,
|
|
84
|
+
"Install Python 3.11+ and make one of these commands available:",
|
|
85
|
+
"python3, python, py -3.11, py -3",
|
|
86
|
+
"Or set OCTOPUS_PYTHON_COMMAND to the Python command.",
|
|
87
|
+
].join("\n")
|
|
88
|
+
);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const child = spawn(
|
|
93
|
+
python.command,
|
|
94
|
+
[...python.args, "-m", "octopus_skill.octopus_run", ...process.argv.slice(2)],
|
|
95
|
+
{
|
|
96
|
+
stdio: "inherit",
|
|
97
|
+
windowsHide: true,
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
child.on("error", (error) => {
|
|
102
|
+
console.error(`Failed to start Python via ${python.source}: ${error.message}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
child.on("exit", (code, signal) => {
|
|
107
|
+
if (signal) {
|
|
108
|
+
process.kill(process.pid, signal);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
process.exit(code ?? 0);
|
|
112
|
+
});
|
|
@@ -7,7 +7,7 @@ from .config import load_config_from_env
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def main() -> None:
|
|
10
|
-
parser = argparse.ArgumentParser(prog="octopus-
|
|
10
|
+
parser = argparse.ArgumentParser(prog="octopus-agent")
|
|
11
11
|
parser.add_argument("question")
|
|
12
12
|
parser.add_argument("--session-id")
|
|
13
13
|
args = parser.parse_args()
|
package/bin/check-python.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawnSync } = require("child_process");
|
|
4
|
-
|
|
5
|
-
const MIN_VERSION = [3, 11, 0];
|
|
6
|
-
|
|
7
|
-
function pythonCandidates() {
|
|
8
|
-
return [["python"], ["python3"]];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function parseVersion(output) {
|
|
12
|
-
const match = String(output).match(/Python\s+(\d+)\.(\d+)\.(\d+)/);
|
|
13
|
-
if (!match) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return match.slice(1).map((part) => Number(part));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function versionLabel(version) {
|
|
20
|
-
return version.join(".");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function isSupported(version) {
|
|
24
|
-
for (let index = 0; index < MIN_VERSION.length; index += 1) {
|
|
25
|
-
if (version[index] > MIN_VERSION[index]) return true;
|
|
26
|
-
if (version[index] < MIN_VERSION[index]) return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function commandLabel(command) {
|
|
32
|
-
return command.join(" ");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function run(command, args, options = {}) {
|
|
36
|
-
return spawnSync(command[0], [...command.slice(1), ...args], {
|
|
37
|
-
encoding: "utf8",
|
|
38
|
-
stdio: options.stdio || ["ignore", "pipe", "pipe"],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function findPython() {
|
|
43
|
-
const checked = [];
|
|
44
|
-
for (const command of pythonCandidates()) {
|
|
45
|
-
const result = run(command, ["--version"]);
|
|
46
|
-
const output = `${result.stdout || ""}${result.stderr || ""}`;
|
|
47
|
-
const version = parseVersion(output);
|
|
48
|
-
if (result.status === 0 && version && isSupported(version)) {
|
|
49
|
-
return { command, version, checked };
|
|
50
|
-
}
|
|
51
|
-
checked.push({
|
|
52
|
-
command,
|
|
53
|
-
reason: version
|
|
54
|
-
? `当前版本 ${versionLabel(version)},需要 ${versionLabel(MIN_VERSION)}+`
|
|
55
|
-
: "未找到或无法读取版本",
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return { command: null, version: null, checked };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function printInstallHelp() {
|
|
62
|
-
console.error("未找到 Python 3.11+。请手动安装后重试。");
|
|
63
|
-
console.error("Windows/macOS/Linux: 安装后确认 `python --version` 或 `python3 --version` 可用。");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function main() {
|
|
67
|
-
let result = findPython();
|
|
68
|
-
if (result.command) {
|
|
69
|
-
console.log(
|
|
70
|
-
`Found Python ${versionLabel(result.version)}: ${commandLabel(
|
|
71
|
-
result.command
|
|
72
|
-
)}`
|
|
73
|
-
);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
for (const item of result.checked) {
|
|
78
|
-
console.error(`${commandLabel(item.command)}: ${item.reason}`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
printInstallHelp();
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main();
|
package/bin/start-roll-server.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn, spawnSync } = require("child_process");
|
|
4
|
-
|
|
5
|
-
const MIN_VERSION = [3, 11, 0];
|
|
6
|
-
|
|
7
|
-
function pythonCandidates() {
|
|
8
|
-
if (process.platform === "win32") {
|
|
9
|
-
return [["python"], ["python3"]];
|
|
10
|
-
}
|
|
11
|
-
return [["python3"], ["python"]];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function parseVersion(output) {
|
|
15
|
-
const match = String(output).match(/Python\s+(\d+)\.(\d+)\.(\d+)/);
|
|
16
|
-
if (!match) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return match.slice(1).map((part) => Number(part));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function versionLabel(version) {
|
|
23
|
-
return version.join(".");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isSupported(version) {
|
|
27
|
-
for (let index = 0; index < MIN_VERSION.length; index += 1) {
|
|
28
|
-
if (version[index] > MIN_VERSION[index]) return true;
|
|
29
|
-
if (version[index] < MIN_VERSION[index]) return false;
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function commandLabel(command) {
|
|
35
|
-
return command.join(" ");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function findPython() {
|
|
39
|
-
const checked = [];
|
|
40
|
-
for (const command of pythonCandidates()) {
|
|
41
|
-
const result = spawnSync(command[0], [...command.slice(1), "--version"], {
|
|
42
|
-
encoding: "utf8",
|
|
43
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
44
|
-
});
|
|
45
|
-
const output = `${result.stdout || ""}${result.stderr || ""}`;
|
|
46
|
-
const version = parseVersion(output);
|
|
47
|
-
if (result.status === 0 && version && isSupported(version)) {
|
|
48
|
-
return { command, version, checked };
|
|
49
|
-
}
|
|
50
|
-
checked.push({
|
|
51
|
-
command,
|
|
52
|
-
reason: version
|
|
53
|
-
? `当前版本 ${versionLabel(version)},需要 ${versionLabel(MIN_VERSION)}+`
|
|
54
|
-
: "未找到或无法读取版本",
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return { command: null, version: null, checked };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function printPythonError(checked) {
|
|
61
|
-
for (const item of checked) {
|
|
62
|
-
console.error(`${commandLabel(item.command)}: ${item.reason}`);
|
|
63
|
-
}
|
|
64
|
-
console.error("未找到 Python 3.11+,无法启动 octopus-agent。");
|
|
65
|
-
console.error("Windows: 请安装 Python 3.11+,并确认 `python --version` 可用。");
|
|
66
|
-
console.error(
|
|
67
|
-
"macOS/Linux: 请安装 Python 3.11+,并确认 `python3 --version` 可用。"
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function main() {
|
|
72
|
-
const passthroughArgs = process.argv.slice(2);
|
|
73
|
-
const checkOnly = passthroughArgs[0] === "--check";
|
|
74
|
-
const serverArgs = checkOnly ? [] : passthroughArgs;
|
|
75
|
-
const result = findPython();
|
|
76
|
-
|
|
77
|
-
if (!result.command) {
|
|
78
|
-
printPythonError(result.checked);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (checkOnly) {
|
|
83
|
-
console.log(
|
|
84
|
-
`${commandLabel(result.command)} ${versionLabel(result.version)}`
|
|
85
|
-
);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const child = spawn(
|
|
90
|
-
result.command[0],
|
|
91
|
-
[...result.command.slice(1), "-m", "octopus_sponge_skill.roll_server", ...serverArgs],
|
|
92
|
-
{ stdio: "inherit" }
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
child.on("exit", (code, signal) => {
|
|
96
|
-
if (signal) {
|
|
97
|
-
process.kill(process.pid, signal);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
process.exit(code || 0);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
child.on("error", (error) => {
|
|
104
|
-
console.error(`启动 Python 失败: ${error.message}`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
main();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|