@bolloon/bolloon-agent 0.3.10 → 0.3.12

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/dist/index.js CHANGED
@@ -553,7 +553,7 @@ const AVAILABLE_TOOLS = [
553
553
  { name: 'update_check', description: '检查 npm 包更新', example: '--update-check' },
554
554
  { name: 'update_now', description: '立即更新到最新版本', example: '--update-now [package]' },
555
555
  ];
556
- async function runToolCommand(tool, args, outputJson, comm) {
556
+ async function runToolCommand(tool, args, outputJson, comm, model, prompt) {
557
557
  const a = await getAgent();
558
558
  const startTime = Date.now();
559
559
  let response;
@@ -1028,6 +1028,29 @@ async function runToolCommand(tool, args, outputJson, comm) {
1028
1028
  }
1029
1029
  break;
1030
1030
  }
1031
+ case 'engine': {
1032
+ const { delegateToEngine } = await import('./external-engines/delegate.js');
1033
+ const engineId = args[0];
1034
+ if (!engineId) {
1035
+ response = '用法: --engine <engine-id> [--model <model>] <prompt>\n可用引擎: opencode, codex, claude-code, hermes';
1036
+ error = response;
1037
+ break;
1038
+ }
1039
+ const result = await delegateToEngine(engineId, prompt || '', {
1040
+ ...(model ? { model } : {}),
1041
+ });
1042
+ const elapsed = Date.now() - startTime;
1043
+ if (result.success) {
1044
+ response = result.output || '(无输出)';
1045
+ }
1046
+ else {
1047
+ response = `❌ 委派失败: ${result.error}`;
1048
+ if (result.output)
1049
+ response += `\n[输出]\n${result.output.slice(0, 2000)}`;
1050
+ }
1051
+ metadata = { ...metadata, duration: elapsed };
1052
+ break;
1053
+ }
1031
1054
  case 'context': {
1032
1055
  const ctx = await getGlobalSharedContext();
1033
1056
  response = await ctx.getContextSummary();
@@ -1402,7 +1425,7 @@ async function runNonInteractive(args, comm) {
1402
1425
  outputBuffer += params.join(' ') + '\n';
1403
1426
  };
1404
1427
  if (tool) {
1405
- await runToolCommand(tool, toolArgs, false, comm);
1428
+ await runToolCommand(tool, toolArgs, false, comm, args.model, prompt);
1406
1429
  }
1407
1430
  else if (prompt) {
1408
1431
  const a = await getAgent();
@@ -1442,7 +1465,7 @@ async function runNonInteractive(args, comm) {
1442
1465
  return;
1443
1466
  }
1444
1467
  if (tool) {
1445
- await runToolCommand(tool, toolArgs, !!json, comm);
1468
+ await runToolCommand(tool, toolArgs, !!json, comm, args.model, prompt);
1446
1469
  }
1447
1470
  else if (prompt) {
1448
1471
  const startTime = Date.now();
@@ -1576,6 +1599,12 @@ function parseArgs() {
1576
1599
  }
1577
1600
  result.toolArgs = delArgs;
1578
1601
  break;
1602
+ case '--engine':
1603
+ case '-e':
1604
+ result.engine = args[++i];
1605
+ result.tool = 'engine';
1606
+ result.toolArgs = [result.engine];
1607
+ break;
1579
1608
  case '--context':
1580
1609
  result.context = true;
1581
1610
  result.tool = 'context';
@@ -1725,6 +1754,7 @@ function parseArgs() {
1725
1754
  result.tui = true;
1726
1755
  break;
1727
1756
  case '--model':
1757
+ case '-m':
1728
1758
  result.model = args[++i];
1729
1759
  break;
1730
1760
  case '--output':
@@ -1736,9 +1766,10 @@ function parseArgs() {
1736
1766
  i = args.length;
1737
1767
  break;
1738
1768
  default:
1739
- if (!arg.startsWith('-') && !result.prompt && !result.tool) {
1769
+ if (!arg.startsWith('-') && !result.prompt) {
1740
1770
  result.prompt = arg;
1741
- result.tool = 'prompt';
1771
+ if (!result.tool)
1772
+ result.tool = 'prompt';
1742
1773
  }
1743
1774
  }
1744
1775
  }
@@ -1809,9 +1840,9 @@ function printHelp() {
1809
1840
  # 跨机 agent 协作 (对方 bolloon --web 起着才能处理, 走 P2P 不经 GitHub)
1810
1841
  --collab <peer|publicKey> "<任务描述>" 派任务给对端 LLM 干活, 等回结果 (90s 超时)
1811
1842
 
1812
- # AI 对话
1813
- --prompt, -p <text> 通用 AI 对话(默认)
1814
- --model <name> 指定使用的模型
1843
+ # 外部编码智能体委派
1844
+ --engine, -e <id> [--model <m>] <prompt> 委派任务给外部引擎,如 opencode/codex
1845
+ --model <name> 指定委派时使用的模型
1815
1846
 
1816
1847
  # 输出控制
1817
1848
  --json, -j 输出 JSON 格式
@@ -1838,6 +1869,9 @@ function printHelp() {
1838
1869
  # 交互模式
1839
1870
  npx tsx src/index.ts
1840
1871
 
1872
+ # 外部引擎委派
1873
+ npx tsx src/index.ts --engine opencode --model opencode/deepseek-v4-flash-free "说你好"
1874
+
1841
1875
  # Web 模式
1842
1876
  npx tsx src/index.ts --web
1843
1877
 
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * npm 自动更新检查器
4
3
  *
@@ -14,48 +13,11 @@
14
13
  * 开发态下若 cwd 的 package.json 就是本包则回退到 cwd,不受任意工作目录影响。
15
14
  * - 检查频率受节流缓存约束(默认 24h 一次),不会每次启动都打 npm。
16
15
  */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || (function () {
34
- var ownKeys = function(o) {
35
- ownKeys = Object.getOwnPropertyNames || function (o) {
36
- var ar = [];
37
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
- return ar;
39
- };
40
- return ownKeys(o);
41
- };
42
- return function (mod) {
43
- if (mod && mod.__esModule) return mod;
44
- var result = {};
45
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
- __setModuleDefault(result, mod);
47
- return result;
48
- };
49
- })();
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.checkAndUpdate = checkAndUpdate;
52
- exports.checkForUpdates = checkForUpdates;
53
- exports.performUpdate = performUpdate;
54
- const child_process_1 = require("child_process");
55
- const fs = __importStar(require("fs"));
56
- const path = __importStar(require("path"));
57
- const https = __importStar(require("https"));
58
- const http = __importStar(require("http"));
16
+ import { execSync } from 'child_process';
17
+ import * as fs from 'fs';
18
+ import * as path from 'path';
19
+ import * as https from 'https';
20
+ import * as http from 'http';
59
21
  // ANSI 颜色
60
22
  const RESET = '\x1b[0m';
61
23
  const BOLD = '\x1b[1m';
@@ -113,7 +75,7 @@ function getGlobalBolloonDir() {
113
75
  const candidates = [];
114
76
  // 1. npm root -g(最可靠)
115
77
  try {
116
- const npmRoot = (0, child_process_1.execSync)('npm root -g', { encoding: 'utf-8', timeout: 8000 }).trim();
78
+ const npmRoot = execSync('npm root -g', { encoding: 'utf-8', timeout: 8000 }).trim();
117
79
  if (npmRoot)
118
80
  candidates.push(path.join(npmRoot, '@bolloon', 'bolloon-agent'));
119
81
  }
@@ -122,7 +84,7 @@ function getGlobalBolloonDir() {
122
84
  }
123
85
  // 2. npm prefix -g
124
86
  try {
125
- const npmPrefix = (0, child_process_1.execSync)('npm prefix -g', { encoding: 'utf-8', timeout: 8000 }).trim();
87
+ const npmPrefix = execSync('npm prefix -g', { encoding: 'utf-8', timeout: 8000 }).trim();
126
88
  if (npmPrefix)
127
89
  candidates.push(path.join(npmPrefix, 'lib', 'node_modules', '@bolloon', 'bolloon-agent'));
128
90
  }
@@ -280,7 +242,7 @@ async function checkBolloonUpdates() {
280
242
  */
281
243
  function checkNpmOutdated() {
282
244
  try {
283
- const output = (0, child_process_1.execSync)('npm outdated --json', {
245
+ const output = execSync('npm outdated --json', {
284
246
  encoding: 'utf-8',
285
247
  timeout: 30000,
286
248
  maxBuffer: 10 * 1024 * 1024,
@@ -344,7 +306,7 @@ async function updatePackagesWithVersion(packagesWithVersion) {
344
306
  const args = ['npm', 'install', '-g', ...packagesWithVersion];
345
307
  notify(`\n${CYAN}📦 正在更新包...${RESET}\n`, RESET);
346
308
  try {
347
- (0, child_process_1.execSync)(args.join(' '), {
309
+ execSync(args.join(' '), {
348
310
  encoding: 'utf-8',
349
311
  timeout: 300000,
350
312
  stdio: 'inherit',
@@ -462,7 +424,7 @@ function resolveAutoUpdatePolicy() {
462
424
  * 例如 Electron 用 app.relaunch(),Node 用 detached 重新 spawn)。
463
425
  * 若未提供或 autoRestart=false,则仅提示用户手动重启。
464
426
  */
465
- async function checkAndUpdate(opts = {}) {
427
+ export async function checkAndUpdate(opts = {}) {
466
428
  const policy = resolveAutoUpdatePolicy();
467
429
  if (policy.blocked) {
468
430
  return { hasUpdate: false, info: null, updated: false, message: '跳过更新检查(已显式禁用)' };
@@ -566,13 +528,13 @@ async function checkAndUpdate(opts = {}) {
566
528
  /**
567
529
  * 仅检查更新,不自动安装
568
530
  */
569
- async function checkForUpdates() {
531
+ export async function checkForUpdates() {
570
532
  return await checkBolloonUpdates();
571
533
  }
572
534
  /**
573
535
  * 手动触发更新
574
536
  */
575
- async function performUpdate(packages) {
537
+ export async function performUpdate(packages) {
576
538
  return await updatePackages(packages);
577
539
  }
578
540
  // CLI 入口
@@ -595,4 +557,3 @@ if (process.argv[1]?.includes('auto-update')) {
595
557
  }
596
558
  })();
597
559
  }
598
- //# sourceMappingURL=auto-update.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolloon/bolloon-agent",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "type": "module",
5
5
  "description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
6
6
  "main": "dist/cli-entry.js",
@@ -18,7 +18,7 @@
18
18
  "scripts/build-web.ts"
19
19
  ],
20
20
  "bin": {
21
- "bolloon": "./bin/bolloon-cli.cjs"
21
+ "bolloon": "./dist/cli-entry.js"
22
22
  },
23
23
  "scripts": {
24
24
  "build": "npm run build --workspaces --if-present",
@@ -48,7 +48,7 @@
48
48
  "src/constraint-runtime"
49
49
  ],
50
50
  "dependencies": {
51
- "@bolloon/bolloon-agent": "^0.3.3",
51
+ "@bolloon/bolloon-agent": "^0.3.10",
52
52
  "@bolloon/constraint-runtime": "0.1.0",
53
53
  "@capacitor/core": "^8.4.1",
54
54
  "@capacitor/ios": "^8.4.1",
@@ -56,7 +56,7 @@
56
56
  "@chainsafe/libp2p-yamux": "^8.0.1",
57
57
  "@diap/sdk": "^0.1.10",
58
58
  "@libp2p/autonat": "^3.0.20",
59
- "@libp2p/circuit-relay-v2": "^4.2.5",
59
+ "@libp2p/circuit-relay-v2": "^4.2.9",
60
60
  "@libp2p/dcutr": "^3.0.20",
61
61
  "@libp2p/identify": "^4.1.6",
62
62
  "@libp2p/kad-dht": "^16.2.6",