opc-agent 4.2.0 → 4.2.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.
Files changed (119) hide show
  1. package/.opc/memory.db +0 -0
  2. package/COMPETITIVE-GAP.md +92 -92
  3. package/CONTRIBUTING.md +36 -36
  4. package/README.md +290 -290
  5. package/README.zh-CN.md +269 -269
  6. package/STUDIO-REWRITE-TASK.md +76 -0
  7. package/dist/channels/telegram.d.ts +5 -0
  8. package/dist/channels/telegram.d.ts.map +1 -1
  9. package/dist/channels/telegram.js +108 -0
  10. package/dist/channels/telegram.js.map +1 -1
  11. package/dist/channels/voice.d.ts +71 -97
  12. package/dist/channels/voice.d.ts.map +1 -1
  13. package/dist/channels/voice.js +369 -347
  14. package/dist/channels/voice.js.map +1 -1
  15. package/dist/channels/web.d.ts.map +1 -1
  16. package/dist/channels/web.js +8 -2
  17. package/dist/channels/web.js.map +1 -1
  18. package/dist/channels/wechat.js +6 -6
  19. package/dist/cli/chat.d.ts +4 -1
  20. package/dist/cli/chat.d.ts.map +1 -1
  21. package/dist/cli/chat.js +680 -73
  22. package/dist/cli/chat.js.map +1 -1
  23. package/dist/cli/setup.js +1 -1
  24. package/dist/cli/setup.js.map +1 -1
  25. package/dist/cli.js +373 -280
  26. package/dist/cli.js.map +1 -1
  27. package/dist/core/a2a-http.d.ts +75 -0
  28. package/dist/core/a2a-http.d.ts.map +1 -0
  29. package/dist/core/a2a-http.js +217 -0
  30. package/dist/core/a2a-http.js.map +1 -0
  31. package/dist/core/a2a.d.ts +2 -0
  32. package/dist/core/a2a.d.ts.map +1 -1
  33. package/dist/core/a2a.js +6 -1
  34. package/dist/core/a2a.js.map +1 -1
  35. package/dist/core/agent.d.ts +1 -0
  36. package/dist/core/agent.d.ts.map +1 -1
  37. package/dist/core/agent.js +3 -0
  38. package/dist/core/agent.js.map +1 -1
  39. package/dist/core/gateway-registry.d.ts +116 -0
  40. package/dist/core/gateway-registry.d.ts.map +1 -0
  41. package/dist/core/gateway-registry.js +280 -0
  42. package/dist/core/gateway-registry.js.map +1 -0
  43. package/dist/core/model-recommender.d.ts +40 -0
  44. package/dist/core/model-recommender.d.ts.map +1 -0
  45. package/dist/core/model-recommender.js +186 -0
  46. package/dist/core/model-recommender.js.map +1 -0
  47. package/dist/core/priority-queue.d.ts +100 -0
  48. package/dist/core/priority-queue.d.ts.map +1 -0
  49. package/dist/core/priority-queue.js +181 -0
  50. package/dist/core/priority-queue.js.map +1 -0
  51. package/dist/core/runtime.d.ts.map +1 -1
  52. package/dist/core/runtime.js +192 -22
  53. package/dist/core/runtime.js.map +1 -1
  54. package/dist/deploy/index.js +56 -56
  55. package/dist/doctor.d.ts +1 -0
  56. package/dist/doctor.d.ts.map +1 -1
  57. package/dist/doctor.js +155 -10
  58. package/dist/doctor.js.map +1 -1
  59. package/dist/index.d.ts +10 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +24 -13
  62. package/dist/index.js.map +1 -1
  63. package/dist/memory/deepbrain.d.ts +1 -1
  64. package/dist/memory/deepbrain.d.ts.map +1 -1
  65. package/dist/memory/deepbrain.js +95 -4
  66. package/dist/memory/deepbrain.js.map +1 -1
  67. package/dist/memory/evolve-engine.d.ts +113 -0
  68. package/dist/memory/evolve-engine.d.ts.map +1 -0
  69. package/dist/memory/evolve-engine.js +549 -0
  70. package/dist/memory/evolve-engine.js.map +1 -0
  71. package/dist/memory/index.d.ts +2 -0
  72. package/dist/memory/index.d.ts.map +1 -1
  73. package/dist/memory/index.js +3 -1
  74. package/dist/memory/index.js.map +1 -1
  75. package/dist/memory/sqlite-store.d.ts +40 -0
  76. package/dist/memory/sqlite-store.d.ts.map +1 -0
  77. package/dist/memory/sqlite-store.js +269 -0
  78. package/dist/memory/sqlite-store.js.map +1 -0
  79. package/dist/memory/user-profiler.d.ts +8 -0
  80. package/dist/memory/user-profiler.d.ts.map +1 -1
  81. package/dist/memory/user-profiler.js +89 -0
  82. package/dist/memory/user-profiler.js.map +1 -1
  83. package/dist/scheduler/cron-engine.d.ts.map +1 -1
  84. package/dist/scheduler/cron-engine.js +3 -36
  85. package/dist/scheduler/cron-engine.js.map +1 -1
  86. package/dist/scheduler/proactive.d.ts +62 -0
  87. package/dist/scheduler/proactive.d.ts.map +1 -0
  88. package/dist/scheduler/proactive.js +185 -0
  89. package/dist/scheduler/proactive.js.map +1 -0
  90. package/dist/skills/auto-learn.d.ts.map +1 -1
  91. package/dist/skills/auto-learn.js +65 -11
  92. package/dist/skills/auto-learn.js.map +1 -1
  93. package/dist/skills/builtin/index.d.ts.map +1 -1
  94. package/dist/skills/builtin/index.js +163 -30
  95. package/dist/skills/builtin/index.js.map +1 -1
  96. package/dist/skills/types.d.ts +1 -1
  97. package/dist/skills/types.d.ts.map +1 -1
  98. package/dist/skills/types.js +1 -0
  99. package/dist/skills/types.js.map +1 -1
  100. package/dist/studio/server.d.ts +1 -0
  101. package/dist/studio/server.d.ts.map +1 -1
  102. package/dist/studio/server.js +148 -17
  103. package/dist/studio/server.js.map +1 -1
  104. package/dist/studio-ui/index.html +867 -2630
  105. package/dist/ui/components.js +105 -105
  106. package/examples/README.md +22 -22
  107. package/examples/basic-agent.ts +90 -90
  108. package/examples/brain-integration.ts +71 -71
  109. package/examples/multi-channel.ts +74 -74
  110. package/install.ps1 +127 -127
  111. package/install.sh +154 -154
  112. package/models.json +164 -164
  113. package/package.json +5 -2
  114. package/scripts/install.ps1 +31 -31
  115. package/scripts/install.sh +40 -40
  116. package/templates/ecommerce-assistant/README.md +45 -45
  117. package/templates/ecommerce-assistant/oad.yaml +47 -47
  118. package/templates/tech-support/README.md +43 -43
  119. package/templates/tech-support/oad.yaml +45 -45
@@ -1,74 +1,74 @@
1
- /**
2
- * OPC Agent Example: Multi-Channel Setup
3
- *
4
- * Shows how to configure Web + Telegram channels for an agent.
5
- * Note: This is a configuration demo — actual channel connections
6
- * require valid tokens/endpoints.
7
- *
8
- * Run: npx tsx examples/multi-channel.ts
9
- */
10
-
11
- import {
12
- BaseAgent,
13
- AgentRuntime,
14
- WebChannel,
15
- TelegramChannel,
16
- InMemoryStore,
17
- } from 'opc-agent';
18
-
19
- async function main() {
20
- console.log('🌐 OPC Agent — Multi-Channel Demo\n');
21
-
22
- try {
23
- const agent = new BaseAgent({
24
- name: 'multi-channel-agent',
25
- description: 'Agent that works across multiple channels',
26
- version: '1.0.0',
27
- });
28
-
29
- const memory = new InMemoryStore();
30
- const runtime = new AgentRuntime(agent, { memory });
31
-
32
- // Channel 1: Web (HTTP endpoint)
33
- const webChannel = new WebChannel({
34
- port: 3000,
35
- path: '/chat',
36
- });
37
- console.log('📡 Web channel configured: http://localhost:3000/chat');
38
-
39
- // Channel 2: Telegram (requires BOT_TOKEN)
40
- const telegramToken = process.env.TELEGRAM_BOT_TOKEN;
41
- if (telegramToken) {
42
- const telegramChannel = new TelegramChannel({
43
- token: telegramToken,
44
- });
45
- runtime.addChannel(telegramChannel);
46
- console.log('📱 Telegram channel configured');
47
- } else {
48
- console.log('📱 Telegram: skipped (set TELEGRAM_BOT_TOKEN to enable)');
49
- }
50
-
51
- // Register web channel
52
- runtime.addChannel(webChannel);
53
-
54
- console.log('\n✅ Agent configured with channels:');
55
- console.log(' • Web: HTTP REST endpoint');
56
- console.log(' • Telegram: Bot API (optional)');
57
- console.log('\nAvailable channels in OPC Agent:');
58
- console.log(' WebChannel, TelegramChannel, WebSocketChannel,');
59
- console.log(' SlackChannel, DiscordChannel, FeishuChannel,');
60
- console.log(' EmailChannel, WeChatChannel, VoiceChannel,');
61
- console.log(' WebhookChannel\n');
62
-
63
- // In production you would call: await runtime.start();
64
- console.log('💡 To start: await runtime.start()');
65
- } catch (e: any) {
66
- console.error(`❌ Error: ${e.message}`);
67
- process.exit(1);
68
- }
69
- }
70
-
71
- main().catch(e => {
72
- console.error(`\n❌ Error: ${e.message}\n`);
73
- process.exit(1);
74
- });
1
+ /**
2
+ * OPC Agent Example: Multi-Channel Setup
3
+ *
4
+ * Shows how to configure Web + Telegram channels for an agent.
5
+ * Note: This is a configuration demo — actual channel connections
6
+ * require valid tokens/endpoints.
7
+ *
8
+ * Run: npx tsx examples/multi-channel.ts
9
+ */
10
+
11
+ import {
12
+ BaseAgent,
13
+ AgentRuntime,
14
+ WebChannel,
15
+ TelegramChannel,
16
+ InMemoryStore,
17
+ } from 'opc-agent';
18
+
19
+ async function main() {
20
+ console.log('🌐 OPC Agent — Multi-Channel Demo\n');
21
+
22
+ try {
23
+ const agent = new BaseAgent({
24
+ name: 'multi-channel-agent',
25
+ description: 'Agent that works across multiple channels',
26
+ version: '1.0.0',
27
+ });
28
+
29
+ const memory = new InMemoryStore();
30
+ const runtime = new AgentRuntime(agent, { memory });
31
+
32
+ // Channel 1: Web (HTTP endpoint)
33
+ const webChannel = new WebChannel({
34
+ port: 3000,
35
+ path: '/chat',
36
+ });
37
+ console.log('📡 Web channel configured: http://localhost:3000/chat');
38
+
39
+ // Channel 2: Telegram (requires BOT_TOKEN)
40
+ const telegramToken = process.env.TELEGRAM_BOT_TOKEN;
41
+ if (telegramToken) {
42
+ const telegramChannel = new TelegramChannel({
43
+ token: telegramToken,
44
+ });
45
+ runtime.addChannel(telegramChannel);
46
+ console.log('📱 Telegram channel configured');
47
+ } else {
48
+ console.log('📱 Telegram: skipped (set TELEGRAM_BOT_TOKEN to enable)');
49
+ }
50
+
51
+ // Register web channel
52
+ runtime.addChannel(webChannel);
53
+
54
+ console.log('\n✅ Agent configured with channels:');
55
+ console.log(' • Web: HTTP REST endpoint');
56
+ console.log(' • Telegram: Bot API (optional)');
57
+ console.log('\nAvailable channels in OPC Agent:');
58
+ console.log(' WebChannel, TelegramChannel, WebSocketChannel,');
59
+ console.log(' SlackChannel, DiscordChannel, FeishuChannel,');
60
+ console.log(' EmailChannel, WeChatChannel, VoiceChannel,');
61
+ console.log(' WebhookChannel\n');
62
+
63
+ // In production you would call: await runtime.start();
64
+ console.log('💡 To start: await runtime.start()');
65
+ } catch (e: any) {
66
+ console.error(`❌ Error: ${e.message}`);
67
+ process.exit(1);
68
+ }
69
+ }
70
+
71
+ main().catch(e => {
72
+ console.error(`\n❌ Error: ${e.message}\n`);
73
+ process.exit(1);
74
+ });
package/install.ps1 CHANGED
@@ -1,127 +1,127 @@
1
- # ============================================================================
2
- # OPC Agent 一键安装脚本 for Windows PowerShell
3
- # 用法: irm https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.ps1 | iex
4
- # 高级: $env:OPC_NO_OLLAMA='1'; irm ... | iex
5
- # ============================================================================
6
-
7
- $ErrorActionPreference = "Stop"
8
-
9
- # ── 颜色输出 ──────────────────────────────────────────────────
10
- function Write-Step($msg) { Write-Host "`n━━━ $msg ━━━" -ForegroundColor Blue }
11
- function Write-Ok($msg) { Write-Host "✅ $msg" -ForegroundColor Green }
12
- function Write-Warn($msg) { Write-Host "⚠️ $msg" -ForegroundColor Yellow }
13
- function Write-Err($msg) { Write-Host "❌ $msg" -ForegroundColor Red }
14
- function Write-Info($msg) { Write-Host "ℹ️ $msg" -ForegroundColor Cyan }
15
-
16
- $SkipOllama = $env:OPC_NO_OLLAMA -eq '1'
17
-
18
- # ── Banner ────────────────────────────────────────────────────
19
- Write-Host ""
20
- Write-Host " ___ ____ ____ _ _ " -ForegroundColor Cyan
21
- Write-Host " / _ \| _ \/ ___| / \ __ _ ___ _ __ | |_ " -ForegroundColor Cyan
22
- Write-Host " | | | | |_) \___ \ / _ \ / _`` |/ _ \ '_ \| __|" -ForegroundColor Cyan
23
- Write-Host " | |_| | __/ ___) / ___ \ (_| | __/ | | | |_ " -ForegroundColor Cyan
24
- Write-Host " \___/|_| |____/_/ \_\__, |\___|_| |_|\__|" -ForegroundColor Cyan
25
- Write-Host " |___/ " -ForegroundColor Cyan
26
- Write-Host ""
27
- Write-Info "一键安装 OPC Agent / One-line installer for OPC Agent"
28
- Write-Host ""
29
-
30
- # ── 检测操作系统 ──────────────────────────────────────────────
31
- Write-Step "🔍 检测操作系统 / Detecting OS"
32
- Write-Ok "Windows $([System.Environment]::OSVersion.Version) detected"
33
-
34
- # ── 检测 Node.js ─────────────────────────────────────────────
35
- Write-Step "📦 检测 Node.js (>=18) / Checking Node.js"
36
-
37
- try {
38
- $nodeVerFull = (node -v)
39
- $nodeVerMajor = [int]($nodeVerFull -replace 'v','' -split '\.' | Select-Object -First 1)
40
- if ($nodeVerMajor -ge 18) {
41
- Write-Ok "Node.js $nodeVerFull ✓"
42
- } else {
43
- Write-Err "Node.js $nodeVerFull 版本过低 / version too old (need >=18)"
44
- Write-Err "修复建议 / Fix: winget install OpenJS.NodeJS.LTS"
45
- Write-Info "或访问 / or visit: https://nodejs.org/"
46
- exit 1
47
- }
48
- } catch {
49
- Write-Err "未检测到 Node.js / Node.js not found"
50
- Write-Err "修复建议 / Fix:"
51
- Write-Info " winget install OpenJS.NodeJS.LTS"
52
- Write-Info " # 或访问 / or visit: https://nodejs.org/"
53
- exit 1
54
- }
55
-
56
- # ── 检测 npm ─────────────────────────────────────────────────
57
- try { npm --version | Out-Null } catch {
58
- Write-Err "未检测到 npm / npm not found"
59
- Write-Err "修复建议 / Fix: 重新安装 Node.js"
60
- exit 1
61
- }
62
-
63
- # ── 安装 OPC Agent ────────────────────────────────────────────
64
- Write-Step "🚀 安装 OPC Agent / Installing OPC Agent"
65
- Write-Info "运行 npm install -g opc-agent ..."
66
- npm install -g opc-agent
67
- if ($LASTEXITCODE -ne 0) { Write-Err "安装失败 / Install failed"; exit 1 }
68
-
69
- $opcVer = try { opc --version 2>$null } catch { "unknown" }
70
- Write-Ok "OPC Agent v$opcVer 安装成功 / installed successfully"
71
-
72
- # ── 初始化 ────────────────────────────────────────────────────
73
- Write-Step "⚙️ 初始化 OPC Agent / Initializing"
74
- Write-Info "运行 opc init --yes ..."
75
- try { opc init --yes; Write-Ok "初始化完成 / initialized" } catch { Write-Warn "初始化跳过(可能已初始化)/ init skipped" }
76
-
77
- # ── 进入项目目录后再检查 ──────────────────────────────────────
78
- if (Test-Path "my-agent") {
79
- Set-Location "my-agent"
80
- Write-Info "已进入 my-agent/ 目录 / Entered my-agent/ directory"
81
- }
82
-
83
- # ── 环境检查 ──────────────────────────────────────────────────
84
- Write-Step "🩺 环境检查 / Running Doctor"
85
- Write-Info "运行 opc doctor ..."
86
- try { opc doctor } catch { Write-Warn "部分检查未通过,请查看上方输出 / Some checks failed" }
87
-
88
- # ── Ollama(可选)─────────────────────────────────────────────
89
- if (-not $SkipOllama) {
90
- Write-Step "🦙 检测 Ollama (可选) / Checking Ollama (optional)"
91
-
92
- $hasOllama = $false
93
- try { ollama --version 2>$null | Out-Null; $hasOllama = $true } catch {}
94
-
95
- if ($hasOllama) {
96
- Write-Ok "Ollama 已安装 / installed ✓"
97
- } else {
98
- Write-Warn "未检测到 Ollama / Ollama not found"
99
- Write-Info "Ollama 可让你在本地运行 AI 模型(免费、隐私安全)"
100
- Write-Info "Ollama lets you run AI models locally (free & private)"
101
- Write-Info "安装方法 / Install: winget install Ollama.Ollama"
102
- Write-Info "或访问 / or visit: https://ollama.com/download"
103
- }
104
- }
105
-
106
- # ── 完成 ──────────────────────────────────────────────────────
107
- Write-Step "🎉 安装完成!/ Installation Complete!"
108
- Write-Host ""
109
- Write-Host "┌──────────────────────────────────────────────────────┐" -ForegroundColor Green
110
- Write-Host "│ │" -ForegroundColor Green
111
- Write-Host "│ 🎊 OPC Agent 已就绪!/ OPC Agent is ready! │" -ForegroundColor Green
112
- Write-Host "│ │" -ForegroundColor Green
113
- Write-Host "│ 快速开始 / Quick Start: │" -ForegroundColor Green
114
- Write-Host "│ │" -ForegroundColor Green
115
- Write-Host "│ opc chat 💬 开始对话 / Start chat │" -ForegroundColor Green
116
- Write-Host "│ opc init my-agent 📁 创建新 Agent │" -ForegroundColor Green
117
- Write-Host "│ opc studio 🖥️ 打开面板 / Dashboard │" -ForegroundColor Green
118
- Write-Host "│ opc --help 📖 查看帮助 / Help │" -ForegroundColor Green
119
- Write-Host "│ │" -ForegroundColor Green
120
- Write-Host "│ 无需全局安装也可使用 / Without global install: │" -ForegroundColor Green
121
- Write-Host "│ npx opc-agent chat │" -ForegroundColor Green
122
- Write-Host "│ npx opc-agent init my-agent │" -ForegroundColor Green
123
- Write-Host "│ │" -ForegroundColor Green
124
- Write-Host "│ 文档 / Docs: https://github.com/Deepleaper/opc-agent│" -ForegroundColor Green
125
- Write-Host "│ │" -ForegroundColor Green
126
- Write-Host "└──────────────────────────────────────────────────────┘" -ForegroundColor Green
127
- Write-Host ""
1
+ # ============================================================================
2
+ # OPC Agent 一键安装脚本 for Windows PowerShell
3
+ # 用法: irm https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.ps1 | iex
4
+ # 高级: $env:OPC_NO_OLLAMA='1'; irm ... | iex
5
+ # ============================================================================
6
+
7
+ $ErrorActionPreference = "Stop"
8
+
9
+ # ── 颜色输出 ──────────────────────────────────────────────────
10
+ function Write-Step($msg) { Write-Host "`n━━━ $msg ━━━" -ForegroundColor Blue }
11
+ function Write-Ok($msg) { Write-Host "✅ $msg" -ForegroundColor Green }
12
+ function Write-Warn($msg) { Write-Host "⚠️ $msg" -ForegroundColor Yellow }
13
+ function Write-Err($msg) { Write-Host "❌ $msg" -ForegroundColor Red }
14
+ function Write-Info($msg) { Write-Host "ℹ️ $msg" -ForegroundColor Cyan }
15
+
16
+ $SkipOllama = $env:OPC_NO_OLLAMA -eq '1'
17
+
18
+ # ── Banner ────────────────────────────────────────────────────
19
+ Write-Host ""
20
+ Write-Host " ___ ____ ____ _ _ " -ForegroundColor Cyan
21
+ Write-Host " / _ \| _ \/ ___| / \ __ _ ___ _ __ | |_ " -ForegroundColor Cyan
22
+ Write-Host " | | | | |_) \___ \ / _ \ / _`` |/ _ \ '_ \| __|" -ForegroundColor Cyan
23
+ Write-Host " | |_| | __/ ___) / ___ \ (_| | __/ | | | |_ " -ForegroundColor Cyan
24
+ Write-Host " \___/|_| |____/_/ \_\__, |\___|_| |_|\__|" -ForegroundColor Cyan
25
+ Write-Host " |___/ " -ForegroundColor Cyan
26
+ Write-Host ""
27
+ Write-Info "一键安装 OPC Agent / One-line installer for OPC Agent"
28
+ Write-Host ""
29
+
30
+ # ── 检测操作系统 ──────────────────────────────────────────────
31
+ Write-Step "🔍 检测操作系统 / Detecting OS"
32
+ Write-Ok "Windows $([System.Environment]::OSVersion.Version) detected"
33
+
34
+ # ── 检测 Node.js ─────────────────────────────────────────────
35
+ Write-Step "📦 检测 Node.js (>=18) / Checking Node.js"
36
+
37
+ try {
38
+ $nodeVerFull = (node -v)
39
+ $nodeVerMajor = [int]($nodeVerFull -replace 'v','' -split '\.' | Select-Object -First 1)
40
+ if ($nodeVerMajor -ge 18) {
41
+ Write-Ok "Node.js $nodeVerFull ✓"
42
+ } else {
43
+ Write-Err "Node.js $nodeVerFull 版本过低 / version too old (need >=18)"
44
+ Write-Err "修复建议 / Fix: winget install OpenJS.NodeJS.LTS"
45
+ Write-Info "或访问 / or visit: https://nodejs.org/"
46
+ exit 1
47
+ }
48
+ } catch {
49
+ Write-Err "未检测到 Node.js / Node.js not found"
50
+ Write-Err "修复建议 / Fix:"
51
+ Write-Info " winget install OpenJS.NodeJS.LTS"
52
+ Write-Info " # 或访问 / or visit: https://nodejs.org/"
53
+ exit 1
54
+ }
55
+
56
+ # ── 检测 npm ─────────────────────────────────────────────────
57
+ try { npm --version | Out-Null } catch {
58
+ Write-Err "未检测到 npm / npm not found"
59
+ Write-Err "修复建议 / Fix: 重新安装 Node.js"
60
+ exit 1
61
+ }
62
+
63
+ # ── 安装 OPC Agent ────────────────────────────────────────────
64
+ Write-Step "🚀 安装 OPC Agent / Installing OPC Agent"
65
+ Write-Info "运行 npm install -g opc-agent ..."
66
+ npm install -g opc-agent
67
+ if ($LASTEXITCODE -ne 0) { Write-Err "安装失败 / Install failed"; exit 1 }
68
+
69
+ $opcVer = try { opc --version 2>$null } catch { "unknown" }
70
+ Write-Ok "OPC Agent v$opcVer 安装成功 / installed successfully"
71
+
72
+ # ── 初始化 ────────────────────────────────────────────────────
73
+ Write-Step "⚙️ 初始化 OPC Agent / Initializing"
74
+ Write-Info "运行 opc init --yes ..."
75
+ try { opc init --yes; Write-Ok "初始化完成 / initialized" } catch { Write-Warn "初始化跳过(可能已初始化)/ init skipped" }
76
+
77
+ # ── 进入项目目录后再检查 ──────────────────────────────────────
78
+ if (Test-Path "my-agent") {
79
+ Set-Location "my-agent"
80
+ Write-Info "已进入 my-agent/ 目录 / Entered my-agent/ directory"
81
+ }
82
+
83
+ # ── 环境检查 ──────────────────────────────────────────────────
84
+ Write-Step "🩺 环境检查 / Running Doctor"
85
+ Write-Info "运行 opc doctor ..."
86
+ try { opc doctor } catch { Write-Warn "部分检查未通过,请查看上方输出 / Some checks failed" }
87
+
88
+ # ── Ollama(可选)─────────────────────────────────────────────
89
+ if (-not $SkipOllama) {
90
+ Write-Step "🦙 检测 Ollama (可选) / Checking Ollama (optional)"
91
+
92
+ $hasOllama = $false
93
+ try { ollama --version 2>$null | Out-Null; $hasOllama = $true } catch {}
94
+
95
+ if ($hasOllama) {
96
+ Write-Ok "Ollama 已安装 / installed ✓"
97
+ } else {
98
+ Write-Warn "未检测到 Ollama / Ollama not found"
99
+ Write-Info "Ollama 可让你在本地运行 AI 模型(免费、隐私安全)"
100
+ Write-Info "Ollama lets you run AI models locally (free & private)"
101
+ Write-Info "安装方法 / Install: winget install Ollama.Ollama"
102
+ Write-Info "或访问 / or visit: https://ollama.com/download"
103
+ }
104
+ }
105
+
106
+ # ── 完成 ──────────────────────────────────────────────────────
107
+ Write-Step "🎉 安装完成!/ Installation Complete!"
108
+ Write-Host ""
109
+ Write-Host "┌──────────────────────────────────────────────────────┐" -ForegroundColor Green
110
+ Write-Host "│ │" -ForegroundColor Green
111
+ Write-Host "│ 🎊 OPC Agent 已就绪!/ OPC Agent is ready! │" -ForegroundColor Green
112
+ Write-Host "│ │" -ForegroundColor Green
113
+ Write-Host "│ 快速开始 / Quick Start: │" -ForegroundColor Green
114
+ Write-Host "│ │" -ForegroundColor Green
115
+ Write-Host "│ opc chat 💬 开始对话 / Start chat │" -ForegroundColor Green
116
+ Write-Host "│ opc init my-agent 📁 创建新 Agent │" -ForegroundColor Green
117
+ Write-Host "│ opc studio 🖥️ 打开面板 / Dashboard │" -ForegroundColor Green
118
+ Write-Host "│ opc --help 📖 查看帮助 / Help │" -ForegroundColor Green
119
+ Write-Host "│ │" -ForegroundColor Green
120
+ Write-Host "│ 无需全局安装也可使用 / Without global install: │" -ForegroundColor Green
121
+ Write-Host "│ npx opc-agent chat │" -ForegroundColor Green
122
+ Write-Host "│ npx opc-agent init my-agent │" -ForegroundColor Green
123
+ Write-Host "│ │" -ForegroundColor Green
124
+ Write-Host "│ 文档 / Docs: https://github.com/Deepleaper/opc-agent│" -ForegroundColor Green
125
+ Write-Host "│ │" -ForegroundColor Green
126
+ Write-Host "└──────────────────────────────────────────────────────┘" -ForegroundColor Green
127
+ Write-Host ""