@bolloon/bolloon-agent 0.1.1 → 0.1.2

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 (200) hide show
  1. package/bin/bolloon-cli.cjs +157 -0
  2. package/bin/bolloon-daemon.sh +207 -0
  3. package/bin/bolloon.cmd +11 -0
  4. package/dist/agents/constraint-layer.js +10 -15
  5. package/dist/agents/pi-sdk.js +433 -106
  6. package/dist/agents/protocol.js +82 -1
  7. package/dist/agents/subagent-manager.js +2 -2
  8. package/dist/agents/workflow-engine.js +15 -20
  9. package/dist/agents/workflow-pivot-loop.js +541 -0
  10. package/dist/bollharness/src/index.js +5 -0
  11. package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +6 -0
  12. package/dist/bollharness/src/scripts/checks/check_api_types.js +45 -0
  13. package/dist/bollharness/src/scripts/checks/check_artifact_link.js +146 -0
  14. package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +6 -0
  15. package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +6 -0
  16. package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +6 -0
  17. package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +6 -0
  18. package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +135 -0
  19. package/dist/bollharness/src/scripts/checks/check_doc_links.js +31 -0
  20. package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +6 -0
  21. package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +34 -0
  22. package/dist/bollharness/src/scripts/checks/check_hook_installed.js +63 -0
  23. package/dist/bollharness/src/scripts/checks/check_issue_closure.js +41 -0
  24. package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +6 -0
  25. package/dist/bollharness/src/scripts/checks/check_security.js +48 -0
  26. package/dist/bollharness/src/scripts/checks/check_skill_parity.js +6 -0
  27. package/dist/bollharness/src/scripts/checks/check_versions.js +6 -0
  28. package/dist/bollharness/src/scripts/checks/finding.js +13 -0
  29. package/dist/bollharness/src/scripts/checks/next_decision_number.js +20 -0
  30. package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +6 -0
  31. package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +8 -0
  32. package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +8 -0
  33. package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +8 -0
  34. package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +8 -0
  35. package/dist/bollharness/src/scripts/context_router.js +67 -0
  36. package/dist/bollharness/src/scripts/deploy-guard.js +157 -0
  37. package/dist/bollharness/src/scripts/guard-feedback.js +192 -0
  38. package/dist/bollharness/src/scripts/guard_router.js +158 -0
  39. package/dist/bollharness/src/scripts/hooks/_hook_output.js +6 -0
  40. package/dist/bollharness/src/scripts/hooks/auto-python3.js +6 -0
  41. package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +6 -0
  42. package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +6 -0
  43. package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +92 -0
  44. package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +63 -0
  45. package/dist/bollharness/src/scripts/hooks/inbox-ack.js +6 -0
  46. package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +6 -0
  47. package/dist/bollharness/src/scripts/hooks/inbox-validate.js +6 -0
  48. package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +6 -0
  49. package/dist/bollharness/src/scripts/hooks/initializer-agent.js +6 -0
  50. package/dist/bollharness/src/scripts/hooks/loop-detection.js +73 -0
  51. package/dist/bollharness/src/scripts/hooks/owner-guard.js +6 -0
  52. package/dist/bollharness/src/scripts/hooks/precompact.js +6 -0
  53. package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +6 -0
  54. package/dist/bollharness/src/scripts/hooks/risk-tracker.js +108 -0
  55. package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +6 -0
  56. package/dist/bollharness/src/scripts/hooks/session-reflection.js +7 -0
  57. package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +7 -0
  58. package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +7 -0
  59. package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +7 -0
  60. package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +157 -0
  61. package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +6 -0
  62. package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +10 -0
  63. package/dist/bollharness/src/scripts/install/install-trust-token.js +7 -0
  64. package/dist/bollharness/src/scripts/install/multi_project_registry.js +9 -0
  65. package/dist/bollharness/src/scripts/install/phase2_auto.js +21 -0
  66. package/dist/bollharness/src/scripts/install/pre_commit_installer.js +6 -0
  67. package/dist/bollharness/src/scripts/install/tier_selector.js +7 -0
  68. package/dist/bollharness/src/scripts/install/transcript_miner.js +7 -0
  69. package/dist/bollharness/src/scripts/lib/claim_patterns.js +10 -0
  70. package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +12 -0
  71. package/dist/bollharness/src/scripts/sanitize.js +6 -0
  72. package/dist/bollharness-integration/channel-judgment-engine.js +530 -0
  73. package/dist/bollharness-integration/context-chain-router.js +383 -0
  74. package/dist/bollharness-integration/context-router-judgment.js +13 -21
  75. package/dist/bollharness-integration/context-router.js +22 -64
  76. package/dist/bollharness-integration/gate-state-machine.js +14 -19
  77. package/dist/bollharness-integration/gate-transition-hooks.js +16 -61
  78. package/dist/bollharness-integration/guard-checker.js +21 -68
  79. package/dist/bollharness-integration/index.js +14 -124
  80. package/dist/bollharness-integration/integration.js +13 -20
  81. package/dist/bollharness-integration/llm-judgment-engine.js +569 -0
  82. package/dist/bollharness-integration/skill-adapter.js +18 -64
  83. package/dist/cli-entry.js +261 -0
  84. package/dist/constraint-runtime/src/commands.js +17 -7
  85. package/dist/constraint-runtime/src/constraint/budget.js +1 -6
  86. package/dist/constraint-runtime/src/constraint/permission.js +1 -6
  87. package/dist/constraint-runtime/src/models.js +1 -3
  88. package/dist/constraint-runtime/src/tools.js +17 -7
  89. package/dist/constraints/index.js +1 -7
  90. package/dist/documents/reader.js +8 -49
  91. package/dist/heartbeat/DaemonManager.js +242 -0
  92. package/dist/heartbeat/HealthMonitor.js +285 -0
  93. package/dist/heartbeat/StartupVerifier.js +205 -0
  94. package/dist/heartbeat/Watchdog.js +168 -0
  95. package/dist/heartbeat/index.js +84 -0
  96. package/dist/heartbeat/types.js +5 -0
  97. package/dist/index.js +381 -28
  98. package/dist/llm/config-store.js +31 -57
  99. package/dist/llm/llm-judgment-client.js +389 -0
  100. package/dist/llm/pi-ai.js +9 -52
  101. package/dist/network/agent-network.js +46 -90
  102. package/dist/network/hybrid-messenger.js +125 -0
  103. package/dist/network/iroh-bootstrap.js +38 -0
  104. package/dist/network/iroh-discovery.js +145 -0
  105. package/dist/network/iroh-integration.js +9 -16
  106. package/dist/network/iroh-transport.js +10 -48
  107. package/dist/network/p2p.js +23 -62
  108. package/dist/network/storage/adapters/json-adapter.js +4 -42
  109. package/dist/network/storage/index.js +147 -0
  110. package/dist/network/storage/types.js +14 -0
  111. package/dist/pi-ecosystem/index.js +233 -0
  112. package/dist/pi-ecosystem-colony/index.js +29 -90
  113. package/dist/pi-ecosystem-goals/index.js +20 -74
  114. package/dist/pi-ecosystem-judgment/decision.js +29 -47
  115. package/dist/pi-ecosystem-judgment/distillation.js +16 -29
  116. package/dist/pi-ecosystem-judgment/human-value-store.js +13 -60
  117. package/dist/pi-ecosystem-judgment/index.js +21 -74
  118. package/dist/pi-ecosystem-judgment/value-injection.js +26 -72
  119. package/dist/pi-ecosystem-mcp/index.js +24 -78
  120. package/dist/pi-ecosystem-subagents/index.js +20 -69
  121. package/dist/social/ant-colony/AdaptiveHeartbeat.js +3 -8
  122. package/dist/social/ant-colony/PheromoneEngine.js +11 -49
  123. package/dist/social/ant-colony/index.js +6 -0
  124. package/dist/social/ant-colony/types.js +4 -8
  125. package/dist/social/channels/ChannelManager.js +8 -46
  126. package/dist/social/channels/DiapChannelBridge.js +9 -47
  127. package/dist/social/channels/InterestMatcher.js +2 -7
  128. package/dist/social/channels/channel-agent-session.js +309 -0
  129. package/dist/social/channels/channel-heartbeat-agent.js +494 -0
  130. package/dist/social/channels/diap-doc-parser.js +204 -0
  131. package/dist/social/channels/harness-workflow-integrator.js +446 -0
  132. package/dist/social/channels/index.js +9 -0
  133. package/dist/social/channels/types.js +3 -7
  134. package/dist/social/global-shared-context.js +6 -47
  135. package/dist/social/heartbeat.js +29 -72
  136. package/dist/social/persona/enhanced-persona.js +299 -0
  137. package/dist/web/client.js +302 -136
  138. package/dist/web/components/p2p/index.js +159 -9
  139. package/dist/web/components/p2p/p2p-connection.js +136 -0
  140. package/dist/web/components/p2p/p2p-manager.js +24 -0
  141. package/dist/web/components/p2p/p2p-store-memory.js +1 -1
  142. package/dist/web/components/p2p/types.js +7 -0
  143. package/dist/web/index.html +5 -0
  144. package/dist/web/style.css +118 -0
  145. package/package.json +12 -6
  146. package/scripts/build-cli.js +206 -0
  147. package/scripts/postinstall.js +153 -0
  148. package/src/agents/pi-sdk.ts +347 -28
  149. package/src/agents/protocol.ts +95 -1
  150. package/src/agents/workflow-pivot-loop.ts +674 -0
  151. package/src/bollharness/CLAUDE.md +73 -0
  152. package/src/bollharness/README.md +143 -0
  153. package/src/bollharness/README.zh-CN.md +131 -0
  154. package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +57 -0
  155. package/src/bollharness/scripts/context-fragments/artifact-linkage.md +14 -0
  156. package/src/bollharness/scripts/context-fragments/auth-consumers.md +17 -0
  157. package/src/bollharness/scripts/context-fragments/bridge-constitution.md +13 -0
  158. package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +18 -0
  159. package/src/bollharness/scripts/context-fragments/closure-checklist.md +13 -0
  160. package/src/bollharness/scripts/context-fragments/contract-consumers.md +15 -0
  161. package/src/bollharness/scripts/context-fragments/db-shared-structures.md +15 -0
  162. package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +19 -0
  163. package/src/bollharness/scripts/context-fragments/general-dev-principles.md +11 -0
  164. package/src/bollharness/scripts/context-fragments/issue-first.md +8 -0
  165. package/src/bollharness/scripts/context-fragments/mcp-parity.md +16 -0
  166. package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +108 -0
  167. package/src/bollharness/scripts/context-fragments/protocol-consumers.md +15 -0
  168. package/src/bollharness/scripts/context-fragments/run-events-consumers.md +15 -0
  169. package/src/bollharness/scripts/context-fragments/scene-fidelity.md +13 -0
  170. package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +15 -0
  171. package/src/bollharness/scripts/context-fragments/two-language.md +15 -0
  172. package/src/bollharness/scripts/context-fragments/version-sources.md +14 -0
  173. package/src/bollharness/scripts/hooks/stop-evaluator.md +83 -0
  174. package/src/bollharness/templates/scaffold/CLAUDE.md +89 -0
  175. package/src/cli-entry.ts +304 -0
  176. package/src/heartbeat/DaemonManager.ts +283 -0
  177. package/src/heartbeat/HealthMonitor.ts +316 -0
  178. package/src/heartbeat/StartupVerifier.ts +223 -0
  179. package/src/heartbeat/Watchdog.ts +198 -0
  180. package/src/heartbeat/index.ts +108 -0
  181. package/src/heartbeat/types.ts +82 -0
  182. package/src/llm/config-store.ts +23 -5
  183. package/src/network/iroh-transport.ts +3 -3
  184. package/src/web/client.js +302 -136
  185. package/src/web/components/p2p/P2PModal.tsx +91 -3
  186. package/src/web/components/p2p/index.ts +171 -9
  187. package/src/web/components/p2p/p2p-connection.ts +153 -1
  188. package/src/web/components/p2p/p2p-manager.ts +39 -1
  189. package/src/web/components/p2p/p2p-store-memory.ts +1 -1
  190. package/src/web/components/p2p/p2p-tools.ts +315 -0
  191. package/src/web/components/p2p/types.ts +58 -0
  192. package/src/web/design.md +99 -0
  193. package/src/web/index.html +5 -0
  194. package/src/web/server.ts +353 -36
  195. package/src/web/style.css +118 -0
  196. package/tsconfig.cli.json +16 -0
  197. package/tsconfig.electron.json +1 -1
  198. package/tsconfig.json +1 -2
  199. package/dist/web/server.js +0 -1647
  200. package/dist/web/server.js.map +0 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Skill Adapter - Bridge between Bollharness skills and Bolloon's SkillRegistry
4
3
  *
@@ -21,45 +20,10 @@
21
20
  * - skill-discovery: Skill discovery and recommendation
22
21
  * - toolkit: Toolkit management
23
22
  */
24
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- var desc = Object.getOwnPropertyDescriptor(m, k);
27
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
- desc = { enumerable: true, get: function() { return m[k]; } };
29
- }
30
- Object.defineProperty(o, k2, desc);
31
- }) : (function(o, m, k, k2) {
32
- if (k2 === undefined) k2 = k;
33
- o[k2] = m[k];
34
- }));
35
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
- Object.defineProperty(o, "default", { enumerable: true, value: v });
37
- }) : function(o, v) {
38
- o["default"] = v;
39
- });
40
- var __importStar = (this && this.__importStar) || (function () {
41
- var ownKeys = function(o) {
42
- ownKeys = Object.getOwnPropertyNames || function (o) {
43
- var ar = [];
44
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
45
- return ar;
46
- };
47
- return ownKeys(o);
48
- };
49
- return function (mod) {
50
- if (mod && mod.__esModule) return mod;
51
- var result = {};
52
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
53
- __setModuleDefault(result, mod);
54
- return result;
55
- };
56
- })();
57
- Object.defineProperty(exports, "__esModule", { value: true });
58
- exports.createSkillAdapter = exports.SkillAdapter = exports.CrystalLearnSkill = exports.HarnessEngTestSkill = exports.HarnessEngSkill = exports.TaskArchSkill = exports.LeadSkill = exports.ArchSkill = exports.BaseSkill = exports.BOLLHARNESS_SKILLS_DIR = void 0;
59
- const constraint_runtime_1 = require("@bolloon/constraint-runtime");
60
- const fs = __importStar(require("fs"));
61
- const path = __importStar(require("path"));
62
- exports.BOLLHARNESS_SKILLS_DIR = path.join('src', 'bollharness', '.claude', 'skills');
23
+ import { SkillRegistry } from '@bolloon/constraint-runtime';
24
+ import * as fs from 'fs';
25
+ import * as path from 'path';
26
+ export const BOLLHARNESS_SKILLS_DIR = path.join('src', 'bollharness', '.claude', 'skills');
63
27
  function parseYamlFrontmatter(content) {
64
28
  const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
65
29
  if (!match) {
@@ -102,15 +66,15 @@ function loadHarnessSkill(skillPath) {
102
66
  }
103
67
  function loadAllHarnessSkills() {
104
68
  const skills = [];
105
- if (!fs.existsSync(exports.BOLLHARNESS_SKILLS_DIR)) {
106
- console.warn(`[SkillAdapter] Bollharness skills dir not found: ${exports.BOLLHARNESS_SKILLS_DIR}`);
69
+ if (!fs.existsSync(BOLLHARNESS_SKILLS_DIR)) {
70
+ console.warn(`[SkillAdapter] Bollharness skills dir not found: ${BOLLHARNESS_SKILLS_DIR}`);
107
71
  return skills;
108
72
  }
109
- const entries = fs.readdirSync(exports.BOLLHARNESS_SKILLS_DIR, { withFileTypes: true });
73
+ const entries = fs.readdirSync(BOLLHARNESS_SKILLS_DIR, { withFileTypes: true });
110
74
  for (const entry of entries) {
111
75
  if (!entry.isDirectory())
112
76
  continue;
113
- const skillPath = path.join(exports.BOLLHARNESS_SKILLS_DIR, entry.name, 'SKILL.md');
77
+ const skillPath = path.join(BOLLHARNESS_SKILLS_DIR, entry.name, 'SKILL.md');
114
78
  if (fs.existsSync(skillPath)) {
115
79
  const metadata = loadHarnessSkill(skillPath);
116
80
  if (metadata) {
@@ -123,7 +87,7 @@ function loadAllHarnessSkills() {
123
87
  /**
124
88
  * Base skill class for bollharness-compatible skills
125
89
  */
126
- class BaseSkill {
90
+ export class BaseSkill {
127
91
  log(message, level = 'info') {
128
92
  const prefix = level === 'error' ? '❌' : level === 'warn' ? '⚠️' : 'ℹ️';
129
93
  console.log(`${prefix} [${this.name}] ${message}`);
@@ -132,11 +96,10 @@ class BaseSkill {
132
96
  return JSON.stringify(output, null, 2);
133
97
  }
134
98
  }
135
- exports.BaseSkill = BaseSkill;
136
99
  /**
137
100
  * Architecture Skill - Project architect for architecture decisions
138
101
  */
139
- class ArchSkill extends BaseSkill {
102
+ export class ArchSkill extends BaseSkill {
140
103
  name = 'arch';
141
104
  description = 'Project architect. Responsible for architecture decisions, scheme comparison, and boundary freezing.';
142
105
  async execute(params) {
@@ -194,11 +157,10 @@ class ArchSkill extends BaseSkill {
194
157
  return alternatives[1]?.recommendation || 'Consider abstraction layer for long-term maintainability';
195
158
  }
196
159
  }
197
- exports.ArchSkill = ArchSkill;
198
160
  /**
199
161
  * Lead Skill - Development workflow commander (fail-closed state machine)
200
162
  */
201
- class LeadSkill extends BaseSkill {
163
+ export class LeadSkill extends BaseSkill {
202
164
  name = 'lead';
203
165
  description = 'Development workflow commander. Fail-closed state machine from idea to production code.';
204
166
  currentGate = 0;
@@ -273,11 +235,10 @@ class LeadSkill extends BaseSkill {
273
235
  });
274
236
  }
275
237
  }
276
- exports.LeadSkill = LeadSkill;
277
238
  /**
278
239
  * Task Architecture Skill - Task decomposition
279
240
  */
280
- class TaskArchSkill extends BaseSkill {
241
+ export class TaskArchSkill extends BaseSkill {
281
242
  name = 'task-arch';
282
243
  description = 'Task decomposition. Breaks down PLAN into parallelizable work packages (WP).';
283
244
  async execute(params) {
@@ -321,11 +282,10 @@ class TaskArchSkill extends BaseSkill {
321
282
  return owners;
322
283
  }
323
284
  }
324
- exports.TaskArchSkill = TaskArchSkill;
325
285
  /**
326
286
  * Harness Engineering Skill - Engineering execution
327
287
  */
328
- class HarnessEngSkill extends BaseSkill {
288
+ export class HarnessEngSkill extends BaseSkill {
329
289
  name = 'harness-eng';
330
290
  description = 'Engineering execution. Implements code according to PLAN.';
331
291
  async execute(params) {
@@ -362,12 +322,11 @@ class HarnessEngSkill extends BaseSkill {
362
322
  return `# Execution Log\n\n${steps.map((s, i) => `${i + 1}. ${s}`).join('\n')}`;
363
323
  }
364
324
  }
365
- exports.HarnessEngSkill = HarnessEngSkill;
366
325
  /**
367
326
  * Harness Engineering Test Skill - Test strategy and execution
368
327
  * Ported from src/bollharness/.claude/skills/harness-eng-test/SKILL.md
369
328
  */
370
- class HarnessEngTestSkill extends BaseSkill {
329
+ export class HarnessEngTestSkill extends BaseSkill {
371
330
  name = 'harness-eng-test';
372
331
  description = 'Testing engineering specialist. Test strategy, test case design, test execution and quality verification. Scheduled by lead at Gate 8.';
373
332
  async execute(params) {
@@ -432,11 +391,10 @@ class HarnessEngTestSkill extends BaseSkill {
432
391
  });
433
392
  }
434
393
  }
435
- exports.HarnessEngTestSkill = HarnessEngTestSkill;
436
394
  /**
437
395
  * Crystal Learn Skill - Failure pattern extraction
438
396
  */
439
- class CrystalLearnSkill extends BaseSkill {
397
+ export class CrystalLearnSkill extends BaseSkill {
440
398
  name = 'crystal-learn';
441
399
  description = 'Extracts failure patterns and maintains invariants.';
442
400
  async execute(params) {
@@ -471,15 +429,14 @@ class CrystalLearnSkill extends BaseSkill {
471
429
  return patterns.map(p => `INV: ${p.pattern} must not occur`);
472
430
  }
473
431
  }
474
- exports.CrystalLearnSkill = CrystalLearnSkill;
475
432
  /**
476
433
  * Skill Adapter - Registers all bollharness skills with Bolloon's SkillRegistry
477
434
  */
478
- class SkillAdapter {
435
+ export class SkillAdapter {
479
436
  registry;
480
437
  harnessSkills = [];
481
438
  constructor() {
482
- this.registry = new constraint_runtime_1.SkillRegistry();
439
+ this.registry = new SkillRegistry();
483
440
  this.registerSkills();
484
441
  }
485
442
  registerSkills() {
@@ -539,7 +496,6 @@ class SkillAdapter {
539
496
  console.log(`${prefix} [SkillAdapter] ${message}`);
540
497
  }
541
498
  }
542
- exports.SkillAdapter = SkillAdapter;
543
499
  function createHarnessProxySkill(meta) {
544
500
  return {
545
501
  name: meta.name,
@@ -557,8 +513,6 @@ function createHarnessProxySkill(meta) {
557
513
  },
558
514
  };
559
515
  }
560
- const createSkillAdapter = () => {
516
+ export const createSkillAdapter = () => {
561
517
  return new SkillAdapter();
562
518
  };
563
- exports.createSkillAdapter = createSkillAdapter;
564
- //# sourceMappingURL=skill-adapter.js.map
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Bolloon CLI 入口
4
+ *
5
+ * 使用方式:
6
+ * bolloon # 启动 GUI(Electron 或 Web)
7
+ * bolloon --cli # 启动命令行界面
8
+ * bolloon --read <file> # 读取文档
9
+ * bolloon --summarize <file> # 总结文档
10
+ * bolloon --web # 启动 Web UI
11
+ * bolloon --version # 显示版本
12
+ */
13
+ import { spawn } from 'child_process';
14
+ import * as path from 'path';
15
+ import * as fs from 'fs';
16
+ const isWindows = process.platform === 'win32';
17
+ // ANSI 颜色
18
+ const RESET = '\x1b[0m';
19
+ const BOLD = '\x1b[1m';
20
+ const CYAN = '\x1b[36m';
21
+ const YELLOW = '\x1b[33m';
22
+ const GREEN = '\x1b[32m';
23
+ const MAGENTA = '\x1b[35m';
24
+ // 版本信息
25
+ const VERSION = '0.1.1';
26
+ function log(msg, color = RESET) {
27
+ console.log(`${color}${msg}${RESET}`);
28
+ }
29
+ function printBanner() {
30
+ console.log(`
31
+ ${CYAN}${BOLD}
32
+ ╔═══════════════════════════════════════════╗
33
+ ║ 🤖 Bolloon Agent ${VERSION} ║
34
+ ║ P2P AI Document Processor ║
35
+ ╚═══════════════════════════════════════════╝${RESET}
36
+ `);
37
+ }
38
+ function printHelp() {
39
+ console.log(`
40
+ ${BOLD}用法:${RESET}
41
+ bolloon [选项] [命令] [参数]
42
+
43
+ ${BOLD}选项:${RESET}
44
+ --gui, -g 启动图形界面 (Electron)
45
+ --web, -w 启动 Web UI (浏览器)
46
+ --cli, -c 启动命令行界面
47
+ --version, -v 显示版本信息
48
+ --help, -h 显示帮助信息
49
+
50
+ ${BOLD}命令:${RESET}
51
+ bolloon --read <file> 读取文档
52
+ bolloon --summarize <file> 总结文档
53
+ bolloon --improve <file> <req> 改进文档
54
+
55
+ ${BOLD}示例:${RESET}
56
+ bolloon # 启动图形界面
57
+ bolloon --web # 启动 Web UI
58
+ bolloon --read 想法.md # 读取文档
59
+ bolloon --cli # 命令行模式
60
+
61
+ ${BOLD}环境变量:${RESET}
62
+ MINIMAX_API_KEY MiniMax API 密钥
63
+ OPENAI_API_KEY OpenAI API 密钥
64
+ ANTHROPIC_API_KEY Anthropic API 密钥
65
+ PORT Web 服务端口 (默认 54188)
66
+ `);
67
+ }
68
+ function getDistDir() {
69
+ // 对于打包后的应用,__dirname 是 dist 目录
70
+ return __dirname;
71
+ }
72
+ function getMainScript() {
73
+ const distDir = getDistDir();
74
+ // 检查 dist/index.js 是否存在
75
+ const indexPath = path.join(distDir, 'index.js');
76
+ if (fs.existsSync(indexPath)) {
77
+ return indexPath;
78
+ }
79
+ // 回退到源目录
80
+ const srcPath = path.join(process.cwd(), 'src', 'index.ts');
81
+ if (fs.existsSync(srcPath)) {
82
+ return path.join(process.cwd(), 'src', 'index.ts');
83
+ }
84
+ throw new Error('找不到入口脚本,请确保已执行 npm run build');
85
+ }
86
+ function getElectronPath() {
87
+ // 获取 electron 可执行文件路径
88
+ const electronPath = require('electron');
89
+ return electronPath;
90
+ }
91
+ // 解析命令行参数
92
+ function parseArgs() {
93
+ const args = process.argv.slice(2);
94
+ if (args.length === 0) {
95
+ return { mode: 'gui', args: [] };
96
+ }
97
+ const mode = args[0];
98
+ // 处理简写选项
99
+ switch (mode) {
100
+ case '-v':
101
+ case '--version':
102
+ return { mode: 'version', args: [] };
103
+ case '-h':
104
+ case '--help':
105
+ return { mode: 'help', args: [] };
106
+ case '-g':
107
+ case '--gui':
108
+ return { mode: 'gui', args: args.slice(1) };
109
+ case '-w':
110
+ case '--web':
111
+ return { mode: 'web', args: args.slice(1) };
112
+ case '-c':
113
+ case '--cli':
114
+ return { mode: 'cli', args: args.slice(1) };
115
+ default:
116
+ // 传递所有参数给主程序
117
+ return { mode: 'passthrough', args };
118
+ }
119
+ }
120
+ // 执行 Node.js 脚本
121
+ async function runNodeScript(scriptPath, additionalArgs) {
122
+ return new Promise((resolve, reject) => {
123
+ const child = spawn(process.execPath, [scriptPath, ...additionalArgs], {
124
+ stdio: 'inherit',
125
+ env: { ...process.env }
126
+ });
127
+ child.on('error', reject);
128
+ child.on('exit', (code) => {
129
+ if (code === 0) {
130
+ resolve();
131
+ }
132
+ else {
133
+ reject(new Error(`进程退出,代码: ${code}`));
134
+ }
135
+ });
136
+ });
137
+ }
138
+ // 启动 Electron
139
+ async function startElectron(additionalArgs) {
140
+ const electronPath = getElectronPath();
141
+ const distDir = getDistDir();
142
+ // 确定主进程入口
143
+ let mainPath = path.join(distDir, 'electron.js');
144
+ if (!fs.existsSync(mainPath)) {
145
+ mainPath = path.join(distDir, '..', 'src', 'electron.js');
146
+ }
147
+ if (!fs.existsSync(mainPath)) {
148
+ // 回退到开发模式
149
+ mainPath = path.join(process.cwd(), 'src', 'electron.ts');
150
+ }
151
+ log('启动 Electron...', CYAN);
152
+ const child = spawn(electronPath, [mainPath, ...additionalArgs], {
153
+ stdio: 'inherit',
154
+ env: { ...process.env, NODE_ENV: 'development' }
155
+ });
156
+ child.on('error', (err) => {
157
+ log(`Electron 启动失败: ${err.message}`, MAGENTA);
158
+ process.exit(1);
159
+ });
160
+ child.on('exit', (code) => {
161
+ process.exit(code || 0);
162
+ });
163
+ }
164
+ // 启动 Web 服务
165
+ async function startWebServer(additionalArgs) {
166
+ log('启动 Web 服务...', CYAN);
167
+ try {
168
+ const mainPath = getMainScript();
169
+ const webArgs = ['--web', ...additionalArgs];
170
+ const child = spawn(process.execPath, [mainPath, ...webArgs], {
171
+ stdio: 'inherit',
172
+ env: { ...process.env }
173
+ });
174
+ child.on('error', (err) => {
175
+ log(`Web 服务启动失败: ${err.message}`, MAGENTA);
176
+ process.exit(1);
177
+ });
178
+ child.on('exit', (code) => {
179
+ process.exit(code || 0);
180
+ });
181
+ }
182
+ catch (err) {
183
+ log(`启动失败: ${err.message}`, MAGENTA);
184
+ process.exit(1);
185
+ }
186
+ }
187
+ // 启动 CLI
188
+ async function startCLI(additionalArgs) {
189
+ log('启动命令行界面...', CYAN);
190
+ try {
191
+ const mainPath = getMainScript();
192
+ const cliArgs = [...additionalArgs];
193
+ const child = spawn(process.execPath, [mainPath, ...cliArgs], {
194
+ stdio: 'inherit',
195
+ env: { ...process.env }
196
+ });
197
+ child.on('error', (err) => {
198
+ log(`CLI 启动失败: ${err.message}`, MAGENTA);
199
+ process.exit(1);
200
+ });
201
+ child.on('exit', (code) => {
202
+ process.exit(code || 0);
203
+ });
204
+ }
205
+ catch (err) {
206
+ log(`启动失败: ${err.message}`, MAGENTA);
207
+ process.exit(1);
208
+ }
209
+ }
210
+ // 主入口
211
+ async function main() {
212
+ const { mode, args } = parseArgs();
213
+ switch (mode) {
214
+ case 'version':
215
+ console.log(`Bolloon Agent v${VERSION}`);
216
+ break;
217
+ case 'help':
218
+ printHelp();
219
+ break;
220
+ case 'gui':
221
+ printBanner();
222
+ await startElectron(args);
223
+ break;
224
+ case 'web':
225
+ printBanner();
226
+ await startWebServer(args);
227
+ break;
228
+ case 'cli':
229
+ await startCLI(args);
230
+ break;
231
+ case 'passthrough':
232
+ // 传递所有参数给主程序
233
+ try {
234
+ const mainPath = getMainScript();
235
+ const child = spawn(process.execPath, [mainPath, ...args], {
236
+ stdio: 'inherit',
237
+ env: { ...process.env }
238
+ });
239
+ child.on('error', (err) => {
240
+ log(`执行失败: ${err.message}`, MAGENTA);
241
+ process.exit(1);
242
+ });
243
+ child.on('exit', (code) => {
244
+ process.exit(code || 0);
245
+ });
246
+ }
247
+ catch (err) {
248
+ log(`执行失败: ${err.message}`, MAGENTA);
249
+ process.exit(1);
250
+ }
251
+ break;
252
+ default:
253
+ log(`未知模式: ${mode}`, MAGENTA);
254
+ printHelp();
255
+ process.exit(1);
256
+ }
257
+ }
258
+ main().catch((err) => {
259
+ console.error('Fatal error:', err);
260
+ process.exit(1);
261
+ });
@@ -5,13 +5,23 @@ const __filename = fileURLToPath(import.meta.url);
5
5
  const __dirname = path.dirname(__filename);
6
6
  const SNAPSHOT_PATH = path.join(__dirname, 'reference_data', 'commands_snapshot.json');
7
7
  function loadCommandSnapshot() {
8
- const raw = JSON.parse(fs.readFileSync(SNAPSHOT_PATH, 'utf-8'));
9
- return raw.map((e) => ({
10
- name: e.name,
11
- responsibility: e.responsibility,
12
- sourceHint: e.source_hint,
13
- status: 'mirrored',
14
- }));
8
+ try {
9
+ if (!fs.existsSync(SNAPSHOT_PATH)) {
10
+ console.warn(`[commands] Snapshot not found: ${SNAPSHOT_PATH}, using empty list`);
11
+ return [];
12
+ }
13
+ const raw = JSON.parse(fs.readFileSync(SNAPSHOT_PATH, 'utf-8'));
14
+ return raw.map((e) => ({
15
+ name: e.name,
16
+ responsibility: e.responsibility,
17
+ sourceHint: e.source_hint,
18
+ status: 'mirrored',
19
+ }));
20
+ }
21
+ catch (error) {
22
+ console.warn(`[commands] Failed to load snapshot: ${error}, using empty list`);
23
+ return [];
24
+ }
15
25
  }
16
26
  export const PORTED_COMMANDS = loadCommandSnapshot();
17
27
  export function builtInCommandNames() {
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BudgetTracker = void 0;
4
- class BudgetTracker {
1
+ export class BudgetTracker {
5
2
  maxBudgetTokens;
6
3
  maxTurns;
7
4
  compactAfterTurns;
@@ -23,5 +20,3 @@ class BudgetTracker {
23
20
  return turnCount > this.compactAfterTurns;
24
21
  }
25
22
  }
26
- exports.BudgetTracker = BudgetTracker;
27
- //# sourceMappingURL=budget.js.map
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToolPermissionContext = void 0;
4
- class ToolPermissionContext {
1
+ export class ToolPermissionContext {
5
2
  denyTools;
6
3
  denyPrefixes;
7
4
  constructor(denyTools, denyPrefixes) {
@@ -21,5 +18,3 @@ class ToolPermissionContext {
21
18
  return { toolName, reason };
22
19
  }
23
20
  }
24
- exports.ToolPermissionContext = ToolPermissionContext;
25
- //# sourceMappingURL=permission.js.map
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=models.js.map
1
+ export {};
@@ -6,13 +6,23 @@ const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
  const SNAPSHOT_PATH = path.join(__dirname, 'reference_data', 'tools_snapshot.json');
8
8
  function loadToolSnapshot() {
9
- const raw = JSON.parse(fs.readFileSync(SNAPSHOT_PATH, 'utf-8'));
10
- return raw.map((e) => ({
11
- name: e.name,
12
- responsibility: e.responsibility,
13
- sourceHint: e.source_hint,
14
- status: 'mirrored',
15
- }));
9
+ try {
10
+ if (!fs.existsSync(SNAPSHOT_PATH)) {
11
+ console.warn(`[tools] Snapshot not found: ${SNAPSHOT_PATH}, using empty list`);
12
+ return [];
13
+ }
14
+ const raw = JSON.parse(fs.readFileSync(SNAPSHOT_PATH, 'utf-8'));
15
+ return raw.map((e) => ({
16
+ name: e.name,
17
+ responsibility: e.responsibility,
18
+ sourceHint: e.source_hint,
19
+ status: 'mirrored',
20
+ }));
21
+ }
22
+ catch (error) {
23
+ console.warn(`[tools] Failed to load snapshot: ${error}, using empty list`);
24
+ return [];
25
+ }
16
26
  }
17
27
  export const PORTED_TOOLS = loadToolSnapshot();
18
28
  export function getTool(name) {
@@ -1,11 +1,5 @@
1
- "use strict";
2
1
  /**
3
2
  * Constraints Module
4
3
  * Re-exports LLM initialization functions for pi-sdk compatibility
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getMinimax = exports.initMinimax = void 0;
8
- var pi_ai_js_1 = require("../llm/pi-ai.js");
9
- Object.defineProperty(exports, "initMinimax", { enumerable: true, get: function () { return pi_ai_js_1.initMinimax; } });
10
- Object.defineProperty(exports, "getMinimax", { enumerable: true, get: function () { return pi_ai_js_1.getMinimax; } });
11
- //# sourceMappingURL=index.js.map
5
+ export { initMinimax, getMinimax } from '../llm/pi-ai.js';
@@ -1,47 +1,8 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.documentReader = exports.DocumentReader = void 0;
40
- const fs = __importStar(require("fs/promises"));
41
- const path = __importStar(require("path"));
42
- const pdf_parse_1 = __importDefault(require("pdf-parse"));
43
- const mammoth_1 = __importDefault(require("mammoth"));
44
- class DocumentReader {
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+ import pdfParse from 'pdf-parse';
4
+ import mammoth from 'mammoth';
5
+ export class DocumentReader {
45
6
  async read(filePath) {
46
7
  const stats = await fs.stat(filePath);
47
8
  const ext = path.extname(filePath).toLowerCase();
@@ -73,11 +34,11 @@ class DocumentReader {
73
34
  async readPdf(filePath) {
74
35
  const dataBuffer = await fs.readFile(filePath);
75
36
  // @ts-ignore - pdf-parse v2 API differs
76
- const data = await (0, pdf_parse_1.default)(dataBuffer);
37
+ const data = await pdfParse(dataBuffer);
77
38
  return data.text;
78
39
  }
79
40
  async readDocx(filePath) {
80
- const result = await mammoth_1.default.extractRawText({ path: filePath });
41
+ const result = await mammoth.extractRawText({ path: filePath });
81
42
  return result.value;
82
43
  }
83
44
  chunk(text, maxChunkSize = 4000) {
@@ -99,6 +60,4 @@ class DocumentReader {
99
60
  return chunks;
100
61
  }
101
62
  }
102
- exports.DocumentReader = DocumentReader;
103
- exports.documentReader = new DocumentReader();
104
- //# sourceMappingURL=reader.js.map
63
+ export const documentReader = new DocumentReader();