@bolloon/bolloon-agent 0.1.1 → 0.1.3

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 +165 -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
  * Pi MCP Adapter Integration for Bolloon
4
3
  *
@@ -10,75 +9,23 @@
10
9
  * - Minimal primitives: only read, write, edit, bash under the hood
11
10
  * - No schema validation black boxes - interfaces are simple by design
12
11
  */
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || (function () {
30
- var ownKeys = function(o) {
31
- ownKeys = Object.getOwnPropertyNames || function (o) {
32
- var ar = [];
33
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
- return ar;
35
- };
36
- return ownKeys(o);
37
- };
38
- return function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
45
- })();
46
- Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.discoverMcpServers = discoverMcpServers;
48
- exports.initializeMcpAdapter = initializeMcpAdapter;
49
- exports.registerServer = registerServer;
50
- exports.registerTool = registerTool;
51
- exports.listTools = listTools;
52
- exports.hasTool = hasTool;
53
- exports.getTool = getTool;
54
- exports.getToolCallLog = getToolCallLog;
55
- exports.clearToolCallLog = clearToolCallLog;
56
- exports.executeTool = executeTool;
57
- exports.startServer = startServer;
58
- exports.stopServer = stopServer;
59
- exports.discoverTools = discoverTools;
60
- exports.createTavilyTool = createTavilyTool;
61
- exports.createAmapTool = createAmapTool;
62
- exports.getAdapterStatus = getAdapterStatus;
63
- exports.on = on;
64
- exports.off = off;
65
- const fs = __importStar(require("fs/promises"));
66
- const path = __importStar(require("path"));
67
- const child_process_1 = require("child_process");
68
- const events_1 = require("events");
12
+ import * as fs from 'fs/promises';
13
+ import * as path from 'path';
14
+ import { spawn } from 'child_process';
15
+ import { EventEmitter } from 'events';
69
16
  // MCP adapter state
70
17
  let tools = new Map();
71
18
  let servers = new Map();
72
19
  let initialized = false;
73
20
  let toolCallLog = [];
74
21
  // Event emitter for MCP events
75
- class McpEventEmitter extends events_1.EventEmitter {
22
+ class McpEventEmitter extends EventEmitter {
76
23
  }
77
24
  const mcpEvents = new McpEventEmitter();
78
25
  /**
79
26
  * Discover MCP servers from standard config locations
80
27
  */
81
- async function discoverMcpServers() {
28
+ export async function discoverMcpServers() {
82
29
  const configs = [];
83
30
  const locations = [
84
31
  path.join(process.env.HOME || '/tmp', '.mcp.json'),
@@ -122,7 +69,7 @@ async function discoverMcpServers() {
122
69
  /**
123
70
  * Initialize the MCP adapter
124
71
  */
125
- async function initializeMcpAdapter() {
72
+ export async function initializeMcpAdapter() {
126
73
  if (initialized)
127
74
  return;
128
75
  const discoveredServers = await discoverMcpServers();
@@ -136,51 +83,51 @@ async function initializeMcpAdapter() {
136
83
  /**
137
84
  * Register an MCP server configuration
138
85
  */
139
- function registerServer(config) {
86
+ export function registerServer(config) {
140
87
  servers.set(config.name, { config, process: null, running: false });
141
88
  console.log(`[McpAdapter] Registered server: ${config.name}`);
142
89
  }
143
90
  /**
144
91
  * Register an MCP tool
145
92
  */
146
- function registerTool(tool) {
93
+ export function registerTool(tool) {
147
94
  tools.set(tool.name, tool);
148
95
  mcpEvents.emit('toolRegistered', tool);
149
96
  }
150
97
  /**
151
98
  * List all available MCP tools
152
99
  */
153
- function listTools() {
100
+ export function listTools() {
154
101
  return Array.from(tools.values());
155
102
  }
156
103
  /**
157
104
  * Check if a tool exists
158
105
  */
159
- function hasTool(name) {
106
+ export function hasTool(name) {
160
107
  return tools.has(name);
161
108
  }
162
109
  /**
163
110
  * Get a specific tool
164
111
  */
165
- function getTool(name) {
112
+ export function getTool(name) {
166
113
  return tools.get(name);
167
114
  }
168
115
  /**
169
116
  * Get tool call log for debugging
170
117
  */
171
- function getToolCallLog() {
118
+ export function getToolCallLog() {
172
119
  return [...toolCallLog];
173
120
  }
174
121
  /**
175
122
  * Clear tool call log
176
123
  */
177
- function clearToolCallLog() {
124
+ export function clearToolCallLog() {
178
125
  toolCallLog = [];
179
126
  }
180
127
  /**
181
128
  * Execute an MCP tool via JSON-RPC protocol
182
129
  */
183
- async function executeTool(name, args) {
130
+ export async function executeTool(name, args) {
184
131
  const tool = tools.get(name);
185
132
  if (!tool) {
186
133
  return { success: false, error: `Unknown tool: ${name}` };
@@ -246,7 +193,7 @@ async function sendMcpRequest(serverName, method, params) {
246
193
  /**
247
194
  * Start an MCP server process
248
195
  */
249
- async function startServer(serverName) {
196
+ export async function startServer(serverName) {
250
197
  const server = servers.get(serverName);
251
198
  if (!server) {
252
199
  console.error(`[McpAdapter] Server not found: ${serverName}`);
@@ -256,7 +203,7 @@ async function startServer(serverName) {
256
203
  return true;
257
204
  }
258
205
  try {
259
- const child = (0, child_process_1.spawn)(server.config.command, server.config.args || [], {
206
+ const child = spawn(server.config.command, server.config.args || [], {
260
207
  env: { ...process.env, ...server.config.env },
261
208
  stdio: ['pipe', 'pipe', 'pipe'],
262
209
  });
@@ -289,7 +236,7 @@ async function startServer(serverName) {
289
236
  /**
290
237
  * Stop an MCP server
291
238
  */
292
- function stopServer(serverName) {
239
+ export function stopServer(serverName) {
293
240
  const server = servers.get(serverName);
294
241
  if (server && server.process) {
295
242
  server.process.kill();
@@ -301,7 +248,7 @@ function stopServer(serverName) {
301
248
  /**
302
249
  * Discover tools from a server using MCP protocol
303
250
  */
304
- async function discoverTools(serverName) {
251
+ export async function discoverTools(serverName) {
305
252
  try {
306
253
  const result = await sendMcpRequest(serverName, 'tools/list');
307
254
  const toolsList = [];
@@ -327,7 +274,7 @@ async function discoverTools(serverName) {
327
274
  /**
328
275
  * Create a Tavily search tool (common MCP integration)
329
276
  */
330
- function createTavilyTool(apiKey) {
277
+ export function createTavilyTool(apiKey) {
331
278
  return {
332
279
  name: 'tavily_search',
333
280
  description: 'Search the web using Tavily',
@@ -345,7 +292,7 @@ function createTavilyTool(apiKey) {
345
292
  /**
346
293
  * Create an Amap maps tool
347
294
  */
348
- function createAmapTool(apiKey) {
295
+ export function createAmapTool(apiKey) {
349
296
  return {
350
297
  name: 'amap_weather',
351
298
  description: 'Get weather information from Amap',
@@ -362,7 +309,7 @@ function createAmapTool(apiKey) {
362
309
  /**
363
310
  * Get adapter status
364
311
  */
365
- function getAdapterStatus() {
312
+ export function getAdapterStatus() {
366
313
  return {
367
314
  initialized,
368
315
  serverCount: servers.size,
@@ -376,10 +323,9 @@ function getAdapterStatus() {
376
323
  /**
377
324
  * Event subscription
378
325
  */
379
- function on(event, callback) {
326
+ export function on(event, callback) {
380
327
  mcpEvents.on(event, callback);
381
328
  }
382
- function off(event, callback) {
329
+ export function off(event, callback) {
383
330
  mcpEvents.off(event, callback);
384
331
  }
385
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Pi Subagents Integration for Bolloon
4
3
  *
@@ -11,56 +10,9 @@
11
10
  * - Full visibility into what each subagent is doing
12
11
  * - No complex scheduling - suitable for single task splitting
13
12
  */
14
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
- Object.defineProperty(o, "default", { enumerable: true, value: v });
27
- }) : function(o, v) {
28
- o["default"] = v;
29
- });
30
- var __importStar = (this && this.__importStar) || (function () {
31
- var ownKeys = function(o) {
32
- ownKeys = Object.getOwnPropertyNames || function (o) {
33
- var ar = [];
34
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
- return ar;
36
- };
37
- return ownKeys(o);
38
- };
39
- return function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- })();
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.createSubagent = createSubagent;
49
- exports.startSubagent = startSubagent;
50
- exports.delegateTask = delegateTask;
51
- exports.sendToSubagent = sendToSubagent;
52
- exports.getSubagent = getSubagent;
53
- exports.listSubagents = listSubagents;
54
- exports.listRunningSubagents = listRunningSubagents;
55
- exports.terminateSubagent = terminateSubagent;
56
- exports.loadSubagents = loadSubagents;
57
- exports.getStats = getStats;
58
- exports.cleanupSubagents = cleanupSubagents;
59
- exports.parallelDelegate = parallelDelegate;
60
- exports.splitTask = splitTask;
61
- const child_process_1 = require("child_process");
62
- const fs = __importStar(require("fs/promises"));
63
- const path = __importStar(require("path"));
13
+ import { spawn } from 'child_process';
14
+ import * as fs from 'fs/promises';
15
+ import * as path from 'path';
64
16
  // Session management
65
17
  const sessions = new Map();
66
18
  const tmuxSessions = new Map();
@@ -75,7 +27,7 @@ function generateId() {
75
27
  /**
76
28
  * Create a new tmux session for a subagent
77
29
  */
78
- async function createSubagent(task, options = {}) {
30
+ export async function createSubagent(task, options = {}) {
79
31
  const id = generateId();
80
32
  const sessionId = `${SESSION_PREFIX}${id}`;
81
33
  const name = options.name || `subagent-${id.substring(0, 8)}`;
@@ -96,7 +48,7 @@ async function createSubagent(task, options = {}) {
96
48
  /**
97
49
  * Start a subagent in a tmux session
98
50
  */
99
- async function startSubagent(id, command, options = {}) {
51
+ export async function startSubagent(id, command, options = {}) {
100
52
  const subagent = sessions.get(id);
101
53
  if (!subagent) {
102
54
  return { subagentId: id, success: false, error: 'Subagent not found' };
@@ -109,7 +61,7 @@ async function startSubagent(id, command, options = {}) {
109
61
  await saveSubagent(subagent);
110
62
  return new Promise((resolve) => {
111
63
  // Create a detached tmux session running the command
112
- const tmuxCmd = (0, child_process_1.spawn)('tmux', [
64
+ const tmuxCmd = spawn('tmux', [
113
65
  'new-session',
114
66
  '-d',
115
67
  '-s',
@@ -189,7 +141,7 @@ async function startSubagent(id, command, options = {}) {
189
141
  /**
190
142
  * Delegate a task to a new subagent and start it
191
143
  */
192
- async function delegateTask(task, command, options = {}) {
144
+ export async function delegateTask(task, command, options = {}) {
193
145
  const subagent = await createSubagent(task, options);
194
146
  return startSubagent(subagent.id, command, options);
195
147
  }
@@ -198,7 +150,7 @@ async function delegateTask(task, command, options = {}) {
198
150
  */
199
151
  async function captureTmuxOutput(sessionId) {
200
152
  return new Promise((resolve, reject) => {
201
- const capture = (0, child_process_1.spawn)('tmux', ['capture-pane', '-t', sessionId, '-p']);
153
+ const capture = spawn('tmux', ['capture-pane', '-t', sessionId, '-p']);
202
154
  let output = '';
203
155
  capture.stdout.on('data', (data) => {
204
156
  output += data.toString();
@@ -212,13 +164,13 @@ async function captureTmuxOutput(sessionId) {
212
164
  /**
213
165
  * Send input to a running subagent
214
166
  */
215
- async function sendToSubagent(id, input) {
167
+ export async function sendToSubagent(id, input) {
216
168
  const subagent = sessions.get(id);
217
169
  if (!subagent) {
218
170
  throw new Error('Subagent not found');
219
171
  }
220
172
  return new Promise((resolve, reject) => {
221
- const tmux = (0, child_process_1.spawn)('tmux', ['send-keys', '-t', subagent.sessionId, input, 'Enter']);
173
+ const tmux = spawn('tmux', ['send-keys', '-t', subagent.sessionId, input, 'Enter']);
222
174
  tmux.on('error', reject);
223
175
  tmux.on('close', () => resolve());
224
176
  });
@@ -226,30 +178,30 @@ async function sendToSubagent(id, input) {
226
178
  /**
227
179
  * Get subagent status
228
180
  */
229
- function getSubagent(id) {
181
+ export function getSubagent(id) {
230
182
  return sessions.get(id);
231
183
  }
232
184
  /**
233
185
  * List all subagents
234
186
  */
235
- function listSubagents() {
187
+ export function listSubagents() {
236
188
  return Array.from(sessions.values());
237
189
  }
238
190
  /**
239
191
  * List running subagents
240
192
  */
241
- function listRunningSubagents() {
193
+ export function listRunningSubagents() {
242
194
  return Array.from(sessions.values()).filter((s) => s.status === 'running');
243
195
  }
244
196
  /**
245
197
  * Terminate a subagent
246
198
  */
247
- async function terminateSubagent(id) {
199
+ export async function terminateSubagent(id) {
248
200
  const subagent = sessions.get(id);
249
201
  if (!subagent)
250
202
  return;
251
203
  // Kill tmux session
252
- (0, child_process_1.spawn)('tmux', ['kill-session', '-t', subagent.sessionId]);
204
+ spawn('tmux', ['kill-session', '-t', subagent.sessionId]);
253
205
  const tmuxProcess = tmuxSessions.get(id);
254
206
  if (tmuxProcess) {
255
207
  tmuxProcess.kill();
@@ -276,7 +228,7 @@ async function saveSubagent(subagent) {
276
228
  /**
277
229
  * Load subagents from disk
278
230
  */
279
- async function loadSubagents() {
231
+ export async function loadSubagents() {
280
232
  try {
281
233
  await fs.mkdir(STATE_DIR, { recursive: true });
282
234
  const files = await fs.readdir(STATE_DIR);
@@ -296,7 +248,7 @@ async function loadSubagents() {
296
248
  /**
297
249
  * Get subagent statistics
298
250
  */
299
- function getStats() {
251
+ export function getStats() {
300
252
  const all = Array.from(sessions.values());
301
253
  return {
302
254
  total: all.length,
@@ -308,7 +260,7 @@ function getStats() {
308
260
  /**
309
261
  * Clean up terminated subagents
310
262
  */
311
- async function cleanupSubagents() {
263
+ export async function cleanupSubagents() {
312
264
  const terminated = Array.from(sessions.values()).filter((s) => s.status === 'terminated' || s.status === 'completed' || s.status === 'failed');
313
265
  for (const subagent of terminated) {
314
266
  try {
@@ -326,7 +278,7 @@ async function cleanupSubagents() {
326
278
  /**
327
279
  * Execute a task in parallel using multiple subagents
328
280
  */
329
- async function parallelDelegate(tasks, commandFactory, options = {}) {
281
+ export async function parallelDelegate(tasks, commandFactory, options = {}) {
330
282
  const promises = tasks.map((task) => delegateTask(task, commandFactory(task), options));
331
283
  return Promise.all(promises);
332
284
  }
@@ -334,7 +286,7 @@ async function parallelDelegate(tasks, commandFactory, options = {}) {
334
286
  * Split a long-form task across multiple subagents
335
287
  * (e.g., writing and researching simultaneously)
336
288
  */
337
- async function splitTask(mainTask, subtasks, commandFactory, options = {}) {
289
+ export async function splitTask(mainTask, subtasks, commandFactory, options = {}) {
338
290
  const results = new Map();
339
291
  // Create all subagents
340
292
  const subagents = await Promise.all(subtasks.map((st) => createSubagent(`${mainTask}: ${st}`, options)));
@@ -349,4 +301,3 @@ async function splitTask(mainTask, subtasks, commandFactory, options = {}) {
349
301
  }
350
302
  return results;
351
303
  }
352
- //# sourceMappingURL=index.js.map
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /**
3
2
  * AdaptiveHeartbeat - 动态心跳策略
4
3
  *
5
4
  * 基于活跃度、信息素密度等因子动态调整心跳间隔
6
5
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.AdaptiveHeartbeat = void 0;
9
- const types_js_1 = require("./types.js");
10
- class AdaptiveHeartbeat {
6
+ import { DEFAULT_ADAPTIVE_CONFIG, } from './types.js';
7
+ export class AdaptiveHeartbeat {
11
8
  config;
12
9
  lastActivityTime = Date.now();
13
10
  activityHistory = [];
@@ -16,7 +13,7 @@ class AdaptiveHeartbeat {
16
13
  discoveryBoost = 0;
17
14
  activityTimer = null;
18
15
  constructor(config) {
19
- this.config = { ...types_js_1.DEFAULT_ADAPTIVE_CONFIG, ...config };
16
+ this.config = { ...DEFAULT_ADAPTIVE_CONFIG, ...config };
20
17
  this.startActivityTracking();
21
18
  }
22
19
  /**
@@ -102,5 +99,3 @@ class AdaptiveHeartbeat {
102
99
  }
103
100
  }
104
101
  }
105
- exports.AdaptiveHeartbeat = AdaptiveHeartbeat;
106
- //# sourceMappingURL=AdaptiveHeartbeat.js.map
@@ -1,50 +1,14 @@
1
- "use strict";
2
1
  /**
3
2
  * PheromoneEngine - 信息素管理引擎
4
3
  *
5
4
  * 模拟蚂蚁的信息素系统,用于引导智能体发现和路由决策
6
5
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.pheromoneEngine = exports.PheromoneEngine = exports.PheromoneType = void 0;
42
- const fs = __importStar(require("fs/promises"));
43
- const path = __importStar(require("path"));
44
- const types_js_1 = require("./types.js");
45
- Object.defineProperty(exports, "PheromoneType", { enumerable: true, get: function () { return types_js_1.PheromoneType; } });
6
+ import * as fs from 'fs/promises';
7
+ import * as path from 'path';
8
+ import { PheromoneType, DEFAULT_PHEROMONE_CONFIG, } from './types.js';
9
+ export { PheromoneType };
46
10
  const PHEROMONE_DB_PATH = path.join(process.env.HOME || '/tmp', '.bolloon', 'ant-colony', 'pheromones.json');
47
- class PheromoneEngine {
11
+ export class PheromoneEngine {
48
12
  trails = new Map();
49
13
  fields = new Map();
50
14
  evaporationTimer = null;
@@ -59,7 +23,7 @@ class PheromoneEngine {
59
23
  startEvaporation() {
60
24
  this.evaporationTimer = setInterval(() => {
61
25
  this.evaporate();
62
- }, types_js_1.DEFAULT_PHEROMONE_CONFIG.evaporationInterval);
26
+ }, DEFAULT_PHEROMONE_CONFIG.evaporationInterval);
63
27
  }
64
28
  startAutoSave() {
65
29
  this.saveTimer = setInterval(() => {
@@ -84,7 +48,7 @@ class PheromoneEngine {
84
48
  sourceDid,
85
49
  targetDid,
86
50
  strength: newStrength,
87
- decayRate: types_js_1.DEFAULT_PHEROMONE_CONFIG.decayRate,
51
+ decayRate: DEFAULT_PHEROMONE_CONFIG.decayRate,
88
52
  createdAt: existing?.createdAt || Date.now(),
89
53
  lastUpdate: Date.now(),
90
54
  capability: options?.capability,
@@ -119,7 +83,7 @@ class PheromoneEngine {
119
83
  return [];
120
84
  const candidates = [];
121
85
  for (const trail of this.trails.values()) {
122
- if (trail.type === types_js_1.PheromoneType.CAPABILITY &&
86
+ if (trail.type === PheromoneType.CAPABILITY &&
123
87
  trail.capability?.includes(capability)) {
124
88
  const score = trail.strength * (trail.qualityScore || 0.5);
125
89
  candidates.push({ did: trail.targetDid, strength: score });
@@ -200,8 +164,8 @@ class PheromoneEngine {
200
164
  const ageHours = (now - trail.lastUpdate) / (1000 * 60 * 60);
201
165
  const decayFactor = Math.pow(1 - trail.decayRate, ageHours);
202
166
  trail.strength = trail.strength * decayFactor;
203
- if (trail.strength < types_js_1.DEFAULT_PHEROMONE_CONFIG.minStrength ||
204
- now - trail.createdAt > types_js_1.DEFAULT_PHEROMONE_CONFIG.maxTrailAge) {
167
+ if (trail.strength < DEFAULT_PHEROMONE_CONFIG.minStrength ||
168
+ now - trail.createdAt > DEFAULT_PHEROMONE_CONFIG.maxTrailAge) {
205
169
  toDelete.push(key);
206
170
  }
207
171
  else {
@@ -260,6 +224,4 @@ class PheromoneEngine {
260
224
  }
261
225
  }
262
226
  }
263
- exports.PheromoneEngine = PheromoneEngine;
264
- exports.pheromoneEngine = new PheromoneEngine();
265
- //# sourceMappingURL=PheromoneEngine.js.map
227
+ export const pheromoneEngine = new PheromoneEngine();
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Ant Colony Module - 蚁群心跳系统核心模块
3
+ */
4
+ export { PheromoneType, DEFAULT_PHEROMONE_CONFIG, DEFAULT_ADAPTIVE_CONFIG, } from './types.js';
5
+ export { PheromoneEngine, pheromoneEngine } from './PheromoneEngine.js';
6
+ export { AdaptiveHeartbeat } from './AdaptiveHeartbeat.js';
@@ -1,22 +1,19 @@
1
- "use strict";
2
1
  /**
3
2
  * Ant Colony Types - 信息素系统类型定义
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_ADAPTIVE_CONFIG = exports.DEFAULT_PHEROMONE_CONFIG = exports.PheromoneType = void 0;
7
- var PheromoneType;
4
+ export var PheromoneType;
8
5
  (function (PheromoneType) {
9
6
  PheromoneType["DISCOVERY"] = "discovery";
10
7
  PheromoneType["CAPABILITY"] = "capability";
11
- })(PheromoneType || (exports.PheromoneType = PheromoneType = {}));
12
- exports.DEFAULT_PHEROMONE_CONFIG = {
8
+ })(PheromoneType || (PheromoneType = {}));
9
+ export const DEFAULT_PHEROMONE_CONFIG = {
13
10
  decayRate: 0.05,
14
11
  evaporationInterval: 5 * 60 * 1000,
15
12
  maxTrailAge: 24 * 60 * 60 * 1000,
16
13
  minStrength: 0.05,
17
14
  maxStrength: 1.0,
18
15
  };
19
- exports.DEFAULT_ADAPTIVE_CONFIG = {
16
+ export const DEFAULT_ADAPTIVE_CONFIG = {
20
17
  minInterval: 10 * 1000,
21
18
  maxInterval: 120 * 1000,
22
19
  baseInterval: 30 * 1000,
@@ -25,4 +22,3 @@ exports.DEFAULT_ADAPTIVE_CONFIG = {
25
22
  pheromoneBoostFactor: 0.3,
26
23
  discoveryBoostFactor: 0.4,
27
24
  };
28
- //# sourceMappingURL=types.js.map