opc-agent 4.1.14 → 4.1.16

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/install.sh CHANGED
@@ -1,164 +1,138 @@
1
- #!/bin/bash
2
- # ============================================================================
3
- # OPC Agent 一键安装脚本 (macOS / Linux / WSL)
4
- # 用法: curl -fsSL https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.sh | bash
5
- # 高级: curl -fsSL ... | bash -s -- --yes --no-ollama
6
- # ============================================================================
7
-
8
- set -e
9
-
10
- # ── 颜色 & Emoji ──────────────────────────────────────────────
11
- RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; CYAN='\033[0;36m'; NC='\033[0m'
12
- info() { echo -e "${CYAN}ℹ️ $1${NC}"; }
13
- ok() { echo -e "${GREEN}✅ $1${NC}"; }
14
- warn() { echo -e "${YELLOW}⚠️ $1${NC}"; }
15
- err() { echo -e "${RED}❌ $1${NC}"; }
16
- step() { echo -e "\n${BLUE}━━━ $1 ━━━${NC}"; }
17
-
18
- # ── 参数解析 ──────────────────────────────────────────────────
19
- AUTO_YES=false
20
- SKIP_OLLAMA=false
21
- for arg in "$@"; do
22
- case "$arg" in
23
- --yes|-y) AUTO_YES=true ;;
24
- --no-ollama) SKIP_OLLAMA=true ;;
25
- esac
26
- done
27
-
28
- confirm() {
29
- if $AUTO_YES; then return 0; fi
30
- read -r -p "$(echo -e "${YELLOW}❓ $1 [Y/n]: ${NC}")" choice
31
- case "$choice" in n|N|no|NO) return 1 ;; *) return 0 ;; esac
32
- }
33
-
34
- # ── 检测操作系统 ──────────────────────────────────────────────
35
- step "🔍 检测操作系统 / Detecting OS"
36
- OS="unknown"
37
- if [[ "$OSTYPE" == "darwin"* ]]; then
38
- OS="macos"
39
- ok "macOS detected"
40
- elif grep -qi microsoft /proc/version 2>/dev/null; then
41
- OS="wsl"
42
- ok "WSL (Windows Subsystem for Linux) detected"
43
- elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
44
- OS="linux"
45
- ok "Linux detected"
46
- else
47
- err "不支持的操作系统 / Unsupported OS: $OSTYPE"
48
- exit 1
49
- fi
50
-
51
- # ── 检测 & 安装 Node.js ──────────────────────────────────────
52
- step "📦 检测 Node.js / Checking Node.js"
53
- NEED_NODE=false
54
-
55
- if command -v node &>/dev/null; then
56
- NODE_VER=$(node -v | sed 's/v//' | cut -d. -f1)
57
- if [ "$NODE_VER" -ge 18 ]; then
58
- ok "Node.js $(node -v) 已安装 / installed"
59
- else
60
- warn "Node.js $(node -v) 版本过低,需要 18+ / version too old, need 18+"
61
- NEED_NODE=true
62
- fi
63
- else
64
- warn "未检测到 Node.js / Node.js not found"
65
- NEED_NODE=true
66
- fi
67
-
68
- if $NEED_NODE; then
69
- info "将通过 nvm 安装 Node.js 22 LTS / Installing Node.js 22 via nvm"
70
- if confirm "安装 Node.js 22? / Install Node.js 22?"; then
71
- if command -v nvm &>/dev/null || [ -s "$HOME/.nvm/nvm.sh" ]; then
72
- [ -s "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh"
73
- info "nvm 已存在,安装 Node 22... / nvm found, installing Node 22..."
74
- else
75
- info "安装 nvm... / Installing nvm..."
76
- curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
77
- export NVM_DIR="$HOME/.nvm"
78
- [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
79
- fi
80
- nvm install 22
81
- nvm use 22
82
- ok "Node.js $(node -v) 安装成功 / installed successfully"
83
- else
84
- err "Node.js 是必需的 / Node.js is required"
85
- echo "手动安装 / Manual install: https://nodejs.org/"
86
- exit 1
87
- fi
88
- fi
89
-
90
- # ── 安装 OPC Agent ────────────────────────────────────────────
91
- step "🚀 安装 OPC Agent / Installing OPC Agent"
92
- info "npm install -g opc-agent ..."
93
- npm install -g opc-agent
94
- ok "OPC Agent $(opc --version 2>/dev/null || echo '') 安装成功 / installed"
95
-
96
- # ── Ollama(可选)─────────────────────────────────────────────
97
- if ! $SKIP_OLLAMA; then
98
- step "🦙 检测 Ollama / Checking Ollama"
99
-
100
- if command -v ollama &>/dev/null; then
101
- ok "Ollama 已安装 / installed ($(ollama --version 2>/dev/null || echo 'ok'))"
102
- else
103
- warn "未检测到 Ollama / Ollama not found"
104
- info "Ollama 可让你在本地运行 AI 模型(免费、数据不出门)"
105
- info "Ollama lets you run AI models locally (free, private)"
106
-
107
- if confirm "安装 Ollama? / Install Ollama?"; then
108
- if [ "$OS" = "macos" ]; then
109
- if command -v brew &>/dev/null; then
110
- brew install ollama
111
- else
112
- info "请从 https://ollama.com/download 下载安装"
113
- info "Download from https://ollama.com/download"
114
- open "https://ollama.com/download" 2>/dev/null || true
115
- fi
116
- else
117
- curl -fsSL https://ollama.com/install.sh | sh
118
- fi
119
- ok "Ollama 安装成功 / installed"
120
- else
121
- info "跳过 Ollama / Skipping Ollama"
122
- fi
123
- fi
124
-
125
- # 拉取推荐模型
126
- if command -v ollama &>/dev/null; then
127
- step "🧠 推荐模型 / Recommended Models"
128
- info "推荐拉取以下模型用于本地 Agent:"
129
- info " qwen2.5:7b 中英文对话(4.7GB)"
130
- info " • nomic-embed-text — 文本向量化(274MB)"
131
-
132
- if confirm "拉取推荐模型? / Pull recommended models?"; then
133
- info "拉取 qwen2.5:7b ... (可能需要几分钟)"
134
- ollama pull qwen2.5:7b && ok "qwen2.5:7b ✓" || warn "qwen2.5:7b 拉取失败,可稍后手动: ollama pull qwen2.5:7b"
135
-
136
- info "拉取 nomic-embed-text ..."
137
- ollama pull nomic-embed-text && ok "nomic-embed-text ✓" || warn "拉取失败,可稍后手动: ollama pull nomic-embed-text"
138
- fi
139
- fi
140
- fi
141
-
142
- # ── 启动 Studio ───────────────────────────────────────────────
143
- step "🎉 安装完成!/ Installation Complete!"
144
- echo ""
145
- echo -e "${GREEN}┌─────────────────────────────────────────────────┐${NC}"
146
- echo -e "${GREEN}│ OPC Agent 已安装成功! │${NC}"
147
- echo -e "${GREEN}│ OPC Agent installed successfully! │${NC}"
148
- echo -e "${GREEN}│ │${NC}"
149
- echo -e "${GREEN}│ 快速开始 / Quick Start: │${NC}"
150
- echo -e "${GREEN}│ opc init my-agent # 创建 Agent │${NC}"
151
- echo -e "${GREEN}│ cd my-agent && npm i │${NC}"
152
- echo -e "${GREEN}│ opc chat # 开始对话 │${NC}"
153
- echo -e "${GREEN}│ │${NC}"
154
- echo -e "${GREEN}│ 可视化面板 / Dashboard: │${NC}"
155
- echo -e "${GREEN}│ opc studio │${NC}"
156
- echo -e "${GREEN}│ │${NC}"
157
- echo -e "${GREEN}│ 帮助 / Help: │${NC}"
158
- echo -e "${GREEN}│ opc --help │${NC}"
159
- echo -e "${GREEN}└─────────────────────────────────────────────────┘${NC}"
160
- echo ""
161
-
162
- if confirm "现在打开 OPC Studio? / Open OPC Studio now?"; then
163
- opc studio
164
- fi
1
+ #!/bin/bash
2
+ # ============================================================================
3
+ # OPC Agent 一键安装脚本 (macOS / Linux / WSL)
4
+ # 用法: curl -fsSL https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.sh | bash
5
+ # 高级: curl -fsSL ... | bash -s -- --no-ollama
6
+ # ============================================================================
7
+
8
+ set -e
9
+
10
+ # ── 颜色 & Emoji ──────────────────────────────────────────────
11
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; CYAN='\033[0;36m'; BOLD='\033[1m'; NC='\033[0m'
12
+ info() { echo -e "${CYAN}ℹ️ $1${NC}"; }
13
+ ok() { echo -e "${GREEN}✅ $1${NC}"; }
14
+ warn() { echo -e "${YELLOW}⚠️ $1${NC}"; }
15
+ err() { echo -e "${RED}❌ $1${NC}"; }
16
+ step() { echo -e "\n${BLUE}${BOLD}━━━ $1 ━━━${NC}"; }
17
+
18
+ # ── 参数解析 ──────────────────────────────────────────────────
19
+ SKIP_OLLAMA=false
20
+ for arg in "$@"; do
21
+ case "$arg" in
22
+ --no-ollama) SKIP_OLLAMA=true ;;
23
+ esac
24
+ done
25
+
26
+ # ── Banner ────────────────────────────────────────────────────
27
+ echo -e "${BOLD}${CYAN}"
28
+ echo " ___ ____ ____ _ _ "
29
+ echo " / _ \| _ \/ ___| / \ __ _ ___ _ __ | |_ "
30
+ echo " | | | | |_) \___ \ / _ \ / _\` |/ _ \ '_ \| __|"
31
+ echo " | |_| | __/ ___) / ___ \ (_| | __/ | | | |_ "
32
+ echo " \___/|_| |____/_/ \_\__, |\___|_| |_|\__|"
33
+ echo " |___/ "
34
+ echo -e "${NC}"
35
+ info "一键安装 OPC Agent / One-line installer for OPC Agent"
36
+ echo ""
37
+
38
+ # ── 检测操作系统 ──────────────────────────────────────────────
39
+ step "🔍 检测操作系统 / Detecting OS"
40
+ OS="unknown"
41
+ if [[ "$OSTYPE" == "darwin"* ]]; then
42
+ OS="macos"; ok "macOS detected"
43
+ elif grep -qi microsoft /proc/version 2>/dev/null; then
44
+ OS="wsl"; ok "WSL (Windows Subsystem for Linux) detected"
45
+ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
46
+ OS="linux"; ok "Linux detected"
47
+ else
48
+ err "不支持的操作系统 / Unsupported OS: $OSTYPE"
49
+ err "修复建议 / Fix: 请使用 macOS、Linux 或 WSL"
50
+ exit 1
51
+ fi
52
+
53
+ # ── 检测 Node.js ─────────────────────────────────────────────
54
+ step "📦 检测 Node.js (>=18) / Checking Node.js"
55
+
56
+ if command -v node &>/dev/null; then
57
+ NODE_VER=$(node -v | sed 's/v//' | cut -d. -f1)
58
+ if [ "$NODE_VER" -ge 18 ]; then
59
+ ok "Node.js $(node -v) ✓"
60
+ else
61
+ err "Node.js $(node -v) 版本过低 / version too old (need >=18)"
62
+ err "修复建议 / Fix:"
63
+ echo " curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash"
64
+ echo " nvm install 22"
65
+ echo " # 或访问 / or visit: https://nodejs.org/"
66
+ exit 1
67
+ fi
68
+ else
69
+ err "未检测到 Node.js / Node.js not found"
70
+ err "修复建议 / Fix:"
71
+ echo " curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash"
72
+ echo " source ~/.bashrc && nvm install 22"
73
+ echo " # 或访问 / or visit: https://nodejs.org/"
74
+ exit 1
75
+ fi
76
+
77
+ # ── 检测 npm ─────────────────────────────────────────────────
78
+ if ! command -v npm &>/dev/null; then
79
+ err "未检测到 npm / npm not found"
80
+ err "修复建议 / Fix: 重新安装 Node.js (npm 会一并安装)"
81
+ exit 1
82
+ fi
83
+
84
+ # ── 安装 OPC Agent ────────────────────────────────────────────
85
+ step "🚀 安装 OPC Agent / Installing OPC Agent"
86
+ info "运行 npm install -g opc-agent ..."
87
+ npm install -g opc-agent
88
+
89
+ OPC_VER=$(opc --version 2>/dev/null || echo "unknown")
90
+ ok "OPC Agent v${OPC_VER} 安装成功 / installed successfully"
91
+
92
+ # ── 初始化 ────────────────────────────────────────────────────
93
+ step "⚙️ 初始化 OPC Agent / Initializing"
94
+ info "运行 opc init --yes ..."
95
+ opc init --yes && ok "初始化完成 / initialized" || warn "初始化跳过(可能已初始化)/ init skipped (may already exist)"
96
+
97
+ # ── 环境检查 ──────────────────────────────────────────────────
98
+ step "🩺 环境检查 / Running Doctor"
99
+ info "运行 opc doctor ..."
100
+ opc doctor || warn "部分检查未通过,请查看上方输出 / Some checks failed, see above"
101
+
102
+ # ── Ollama(可选)─────────────────────────────────────────────
103
+ if ! $SKIP_OLLAMA; then
104
+ step "🦙 检测 Ollama (可选) / Checking Ollama (optional)"
105
+
106
+ if command -v ollama &>/dev/null; then
107
+ ok "Ollama 已安装 / installed "
108
+ else
109
+ warn "未检测到 Ollama / Ollama not found"
110
+ info "Ollama 可让你在本地运行 AI 模型(免费、隐私安全)"
111
+ info "Ollama lets you run AI models locally (free & private)"
112
+ info "安装方法 / Install: curl -fsSL https://ollama.com/install.sh | sh"
113
+ info "或访问 / or visit: https://ollama.com/download"
114
+ fi
115
+ fi
116
+
117
+ # ── 完成 ──────────────────────────────────────────────────────
118
+ step "🎉 安装完成!/ Installation Complete!"
119
+ echo ""
120
+ echo -e "${GREEN}┌──────────────────────────────────────────────────────┐${NC}"
121
+ echo -e "${GREEN}│ │${NC}"
122
+ echo -e "${GREEN}│ 🎊 OPC Agent 已就绪!/ OPC Agent is ready! │${NC}"
123
+ echo -e "${GREEN}│ │${NC}"
124
+ echo -e "${GREEN}│ 快速开始 / Quick Start: │${NC}"
125
+ echo -e "${GREEN}│ │${NC}"
126
+ echo -e "${GREEN}│ opc chat 💬 开始对话 / Start chat │${NC}"
127
+ echo -e "${GREEN}│ opc init my-agent 📁 创建新 Agent │${NC}"
128
+ echo -e "${GREEN}│ opc studio 🖥️ 打开面板 / Dashboard │${NC}"
129
+ echo -e "${GREEN}│ opc --help 📖 查看帮助 / Help │${NC}"
130
+ echo -e "${GREEN}│ │${NC}"
131
+ echo -e "${GREEN}│ 无需全局安装也可使用 / Without global install: │${NC}"
132
+ echo -e "${GREEN}│ npx opc-agent chat │${NC}"
133
+ echo -e "${GREEN}│ npx opc-agent init my-agent │${NC}"
134
+ echo -e "${GREEN}│ │${NC}"
135
+ echo -e "${GREEN}│ 文档 / Docs: https://github.com/Deepleaper/opc-agent│${NC}"
136
+ echo -e "${GREEN}│ │${NC}"
137
+ echo -e "${GREEN}└──────────────────────────────────────────────────────┘${NC}"
138
+ echo ""
package/package.json CHANGED
@@ -1,65 +1,66 @@
1
- {
2
- "name": "opc-agent",
3
- "version": "4.1.14",
4
- "description": "Open Agent Framework — Build, test, and run AI Agents for business workstations",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "bin": {
8
- "opc": "dist/cli.js"
9
- },
10
- "scripts": {
11
- "build": "tsc",
12
- "postbuild": "xcopy /E /I /Y src\\studio-ui dist\\studio-ui",
13
- "test": "vitest run",
14
- "dev": "tsc --watch",
15
- "lint": "tsc --noEmit",
16
- "setup": "opc setup",
17
- "docs:dev": "vitepress dev docs",
18
- "docs:build": "vitepress build docs",
19
- "docs:preview": "vitepress preview docs"
20
- },
21
- "keywords": [
22
- "agent",
23
- "ai",
24
- "llm",
25
- "framework",
26
- "typescript",
27
- "agent-framework"
28
- ],
29
- "author": "Deepleaper",
30
- "license": "Apache-2.0",
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/Deepleaper/opc-agent.git"
34
- },
35
- "dependencies": {
36
- "agent-workstation": "^2.1.2",
37
- "agentkits": "^2.0.1",
38
- "commander": "^12.0.0",
39
- "express": "^4.21.0",
40
- "js-yaml": "^4.1.0",
41
- "mammoth": "^1.12.0",
42
- "pdf-parse": "^1.1.4",
43
- "sql.js": "^1.14.1",
44
- "ws": "^8.20.0",
45
- "zod": "^3.23.0"
46
- },
47
- "devDependencies": {
48
- "@types/express": "^4.17.21",
49
- "@types/js-yaml": "^4.0.9",
50
- "@types/node": "^20.11.0",
51
- "@types/sql.js": "^1.4.11",
52
- "@types/ws": "^8.18.1",
53
- "typescript": "^5.5.0",
54
- "vitepress": "^1.5.0",
55
- "vitest": "^2.0.0"
56
- },
57
- "peerDependencies": {
58
- "deepbrain": "^2.0.5"
59
- },
60
- "peerDependenciesMeta": {
61
- "deepbrain": {
62
- "optional": true
63
- }
64
- }
65
- }
1
+ {
2
+ "name": "opc-agent",
3
+ "version": "4.1.16",
4
+ "description": "Open Agent Framework — Build, test, and run AI Agents for business workstations",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "opc": "dist/cli.js",
9
+ "opc-agent": "dist/cli.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "postbuild": "xcopy /E /I /Y src\\studio-ui dist\\studio-ui",
14
+ "test": "vitest run",
15
+ "dev": "tsc --watch",
16
+ "lint": "tsc --noEmit",
17
+ "setup": "opc setup",
18
+ "docs:dev": "vitepress dev docs",
19
+ "docs:build": "vitepress build docs",
20
+ "docs:preview": "vitepress preview docs"
21
+ },
22
+ "keywords": [
23
+ "agent",
24
+ "ai",
25
+ "llm",
26
+ "framework",
27
+ "typescript",
28
+ "agent-framework"
29
+ ],
30
+ "author": "Deepleaper",
31
+ "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Deepleaper/opc-agent.git"
35
+ },
36
+ "dependencies": {
37
+ "agent-workstation": "^2.1.2",
38
+ "agentkits": "^2.0.1",
39
+ "commander": "^12.0.0",
40
+ "express": "^4.21.0",
41
+ "js-yaml": "^4.1.0",
42
+ "mammoth": "^1.12.0",
43
+ "pdf-parse": "^1.1.4",
44
+ "sql.js": "^1.14.1",
45
+ "ws": "^8.20.0",
46
+ "zod": "^3.23.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/express": "^4.17.21",
50
+ "@types/js-yaml": "^4.0.9",
51
+ "@types/node": "^20.11.0",
52
+ "@types/sql.js": "^1.4.11",
53
+ "@types/ws": "^8.18.1",
54
+ "typescript": "^5.5.0",
55
+ "vitepress": "^1.5.0",
56
+ "vitest": "^2.0.0"
57
+ },
58
+ "peerDependencies": {
59
+ "deepbrain": "^2.0.5"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "deepbrain": {
63
+ "optional": true
64
+ }
65
+ }
66
+ }