@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.
- package/bin/bolloon-cli.cjs +165 -0
- package/bin/bolloon-daemon.sh +207 -0
- package/bin/bolloon.cmd +11 -0
- package/dist/agents/constraint-layer.js +10 -15
- package/dist/agents/pi-sdk.js +433 -106
- package/dist/agents/protocol.js +82 -1
- package/dist/agents/subagent-manager.js +2 -2
- package/dist/agents/workflow-engine.js +15 -20
- package/dist/agents/workflow-pivot-loop.js +541 -0
- package/dist/bollharness/src/index.js +5 -0
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_api_types.js +45 -0
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +146 -0
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +135 -0
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +31 -0
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +34 -0
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +63 -0
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +41 -0
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_security.js +48 -0
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_versions.js +6 -0
- package/dist/bollharness/src/scripts/checks/finding.js +13 -0
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +20 -0
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +6 -0
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +8 -0
- package/dist/bollharness/src/scripts/context_router.js +67 -0
- package/dist/bollharness/src/scripts/deploy-guard.js +157 -0
- package/dist/bollharness/src/scripts/guard-feedback.js +192 -0
- package/dist/bollharness/src/scripts/guard_router.js +158 -0
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +6 -0
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +6 -0
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +6 -0
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +6 -0
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +92 -0
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +63 -0
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +6 -0
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +6 -0
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +73 -0
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +6 -0
- package/dist/bollharness/src/scripts/hooks/precompact.js +6 -0
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +6 -0
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +108 -0
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +6 -0
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +7 -0
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +157 -0
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +6 -0
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +10 -0
- package/dist/bollharness/src/scripts/install/install-trust-token.js +7 -0
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +9 -0
- package/dist/bollharness/src/scripts/install/phase2_auto.js +21 -0
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +6 -0
- package/dist/bollharness/src/scripts/install/tier_selector.js +7 -0
- package/dist/bollharness/src/scripts/install/transcript_miner.js +7 -0
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +10 -0
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +12 -0
- package/dist/bollharness/src/scripts/sanitize.js +6 -0
- package/dist/bollharness-integration/channel-judgment-engine.js +530 -0
- package/dist/bollharness-integration/context-chain-router.js +383 -0
- package/dist/bollharness-integration/context-router-judgment.js +13 -21
- package/dist/bollharness-integration/context-router.js +22 -64
- package/dist/bollharness-integration/gate-state-machine.js +14 -19
- package/dist/bollharness-integration/gate-transition-hooks.js +16 -61
- package/dist/bollharness-integration/guard-checker.js +21 -68
- package/dist/bollharness-integration/index.js +14 -124
- package/dist/bollharness-integration/integration.js +13 -20
- package/dist/bollharness-integration/llm-judgment-engine.js +569 -0
- package/dist/bollharness-integration/skill-adapter.js +18 -64
- package/dist/cli-entry.js +261 -0
- package/dist/constraint-runtime/src/commands.js +17 -7
- package/dist/constraint-runtime/src/constraint/budget.js +1 -6
- package/dist/constraint-runtime/src/constraint/permission.js +1 -6
- package/dist/constraint-runtime/src/models.js +1 -3
- package/dist/constraint-runtime/src/tools.js +17 -7
- package/dist/constraints/index.js +1 -7
- package/dist/documents/reader.js +8 -49
- package/dist/heartbeat/DaemonManager.js +242 -0
- package/dist/heartbeat/HealthMonitor.js +285 -0
- package/dist/heartbeat/StartupVerifier.js +205 -0
- package/dist/heartbeat/Watchdog.js +168 -0
- package/dist/heartbeat/index.js +84 -0
- package/dist/heartbeat/types.js +5 -0
- package/dist/index.js +381 -28
- package/dist/llm/config-store.js +31 -57
- package/dist/llm/llm-judgment-client.js +389 -0
- package/dist/llm/pi-ai.js +9 -52
- package/dist/network/agent-network.js +46 -90
- package/dist/network/hybrid-messenger.js +125 -0
- package/dist/network/iroh-bootstrap.js +38 -0
- package/dist/network/iroh-discovery.js +145 -0
- package/dist/network/iroh-integration.js +9 -16
- package/dist/network/iroh-transport.js +10 -48
- package/dist/network/p2p.js +23 -62
- package/dist/network/storage/adapters/json-adapter.js +4 -42
- package/dist/network/storage/index.js +147 -0
- package/dist/network/storage/types.js +14 -0
- package/dist/pi-ecosystem/index.js +233 -0
- package/dist/pi-ecosystem-colony/index.js +29 -90
- package/dist/pi-ecosystem-goals/index.js +20 -74
- package/dist/pi-ecosystem-judgment/decision.js +29 -47
- package/dist/pi-ecosystem-judgment/distillation.js +16 -29
- package/dist/pi-ecosystem-judgment/human-value-store.js +13 -60
- package/dist/pi-ecosystem-judgment/index.js +21 -74
- package/dist/pi-ecosystem-judgment/value-injection.js +26 -72
- package/dist/pi-ecosystem-mcp/index.js +24 -78
- package/dist/pi-ecosystem-subagents/index.js +20 -69
- package/dist/social/ant-colony/AdaptiveHeartbeat.js +3 -8
- package/dist/social/ant-colony/PheromoneEngine.js +11 -49
- package/dist/social/ant-colony/index.js +6 -0
- package/dist/social/ant-colony/types.js +4 -8
- package/dist/social/channels/ChannelManager.js +8 -46
- package/dist/social/channels/DiapChannelBridge.js +9 -47
- package/dist/social/channels/InterestMatcher.js +2 -7
- package/dist/social/channels/channel-agent-session.js +309 -0
- package/dist/social/channels/channel-heartbeat-agent.js +494 -0
- package/dist/social/channels/diap-doc-parser.js +204 -0
- package/dist/social/channels/harness-workflow-integrator.js +446 -0
- package/dist/social/channels/index.js +9 -0
- package/dist/social/channels/types.js +3 -7
- package/dist/social/global-shared-context.js +6 -47
- package/dist/social/heartbeat.js +29 -72
- package/dist/social/persona/enhanced-persona.js +299 -0
- package/dist/web/client.js +302 -136
- package/dist/web/components/p2p/index.js +159 -9
- package/dist/web/components/p2p/p2p-connection.js +136 -0
- package/dist/web/components/p2p/p2p-manager.js +24 -0
- package/dist/web/components/p2p/p2p-store-memory.js +1 -1
- package/dist/web/components/p2p/types.js +7 -0
- package/dist/web/index.html +5 -0
- package/dist/web/style.css +118 -0
- package/package.json +12 -6
- package/scripts/build-cli.js +206 -0
- package/scripts/postinstall.js +153 -0
- package/src/agents/pi-sdk.ts +347 -28
- package/src/agents/protocol.ts +95 -1
- package/src/agents/workflow-pivot-loop.ts +674 -0
- package/src/bollharness/CLAUDE.md +73 -0
- package/src/bollharness/README.md +143 -0
- package/src/bollharness/README.zh-CN.md +131 -0
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +57 -0
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +14 -0
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +17 -0
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +13 -0
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +18 -0
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +13 -0
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +15 -0
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +19 -0
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +11 -0
- package/src/bollharness/scripts/context-fragments/issue-first.md +8 -0
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +16 -0
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +108 -0
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +13 -0
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +15 -0
- package/src/bollharness/scripts/context-fragments/two-language.md +15 -0
- package/src/bollharness/scripts/context-fragments/version-sources.md +14 -0
- package/src/bollharness/scripts/hooks/stop-evaluator.md +83 -0
- package/src/bollharness/templates/scaffold/CLAUDE.md +89 -0
- package/src/cli-entry.ts +304 -0
- package/src/heartbeat/DaemonManager.ts +283 -0
- package/src/heartbeat/HealthMonitor.ts +316 -0
- package/src/heartbeat/StartupVerifier.ts +223 -0
- package/src/heartbeat/Watchdog.ts +198 -0
- package/src/heartbeat/index.ts +108 -0
- package/src/heartbeat/types.ts +82 -0
- package/src/llm/config-store.ts +23 -5
- package/src/network/iroh-transport.ts +3 -3
- package/src/web/client.js +302 -136
- package/src/web/components/p2p/P2PModal.tsx +91 -3
- package/src/web/components/p2p/index.ts +171 -9
- package/src/web/components/p2p/p2p-connection.ts +153 -1
- package/src/web/components/p2p/p2p-manager.ts +39 -1
- package/src/web/components/p2p/p2p-store-memory.ts +1 -1
- package/src/web/components/p2p/p2p-tools.ts +315 -0
- package/src/web/components/p2p/types.ts +58 -0
- package/src/web/design.md +99 -0
- package/src/web/index.html +5 -0
- package/src/web/server.ts +353 -36
- package/src/web/style.css +118 -0
- package/tsconfig.cli.json +16 -0
- package/tsconfig.electron.json +1 -1
- package/tsconfig.json +1 -2
- package/dist/web/server.js +0 -1647
- package/dist/web/server.js.map +0 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi Ecosystem Integration for Bolloon
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for Pi ecosystem packages integration.
|
|
5
|
+
*
|
|
6
|
+
* Installed packages:
|
|
7
|
+
* - oh-pi: Configuration management (API keys, model selection, extensions)
|
|
8
|
+
* - pi-mcp-adapter: MCP protocol bridge for tools
|
|
9
|
+
* - pi-goals: Persistent goal tracking and workflow orchestration
|
|
10
|
+
* - pi-subagents: Lightweight subagents based on tmux
|
|
11
|
+
* - pi-ecosystem-colony: Ant colony multi-agent collaboration
|
|
12
|
+
*
|
|
13
|
+
* Design philosophy:
|
|
14
|
+
* - Minimal primitives (read/write/edit/bash)
|
|
15
|
+
* - No Plan Mode - direct execution
|
|
16
|
+
* - No permission popups - use safe-guard extensions
|
|
17
|
+
* - No built-in todos - use pi-goals
|
|
18
|
+
* - White-box design - everything visible
|
|
19
|
+
*
|
|
20
|
+
* Token efficiency:
|
|
21
|
+
* - Claude Code: 5k-8k token/request overhead
|
|
22
|
+
* - Pi ecosystem: ~800 token/request
|
|
23
|
+
* - Result: 80-90% token cost savings
|
|
24
|
+
*/
|
|
25
|
+
import * as fs from 'fs/promises';
|
|
26
|
+
import * as path from 'path';
|
|
27
|
+
// Re-export all modules with correct paths
|
|
28
|
+
export { initializeMcpAdapter, discoverMcpServers, registerServer, registerTool, listTools, hasTool, getTool, executeTool, getToolCallLog, clearToolCallLog, startServer, stopServer, discoverTools, createTavilyTool, createAmapTool, getAdapterStatus, on as onMcpEvent, off as offMcpEvent, } from '../pi-ecosystem-mcp/index.js';
|
|
29
|
+
export { createGoal, createGoalQueue, getCurrentGoal, startCurrentGoal, completeCurrentGoal, failCurrentGoal, cutoffCurrentGoal, pauseCurrentGoal, checkBudget, getGoalStats, getQueueSummary, loadGoals, clearGoals, compactQueue, loadTemplates, createFromTemplate, nudgeCurrentGoal, } from '../pi-ecosystem-goals/index.js';
|
|
30
|
+
export { createSubagent, startSubagent, delegateTask, getSubagent, listSubagents, listRunningSubagents, terminateSubagent, getStats as getSubagentStats, parallelDelegate, splitTask, } from '../pi-ecosystem-subagents/index.js';
|
|
31
|
+
export { registerAnt, antScouting, antWorking, antReviewing, antComplete, antFail, antAbort, antTick, createTask, dispatchTask, recordResult, getAnt, listAnts, listAntsByRole, listAntsBySignal, getActiveAnts, getTask, listTasks, getSignalHistory, getColonyStatus, getColonyDump, persistColony, loadColony, onColonyEvent, offColonyEvent, } from '../pi-ecosystem-colony/index.js';
|
|
32
|
+
// Judgment exports
|
|
33
|
+
export { createJudgment, updateJudgmentConfidence, getAllJudgments, getJudgmentsByType, getJudgmentsForContext, getCombinedJudgments, calculateConfidence, buildValueFunction, getValueFunction, getJudgmentStats, loadFragmentJudgments, clearCache, } from '../pi-ecosystem-judgment/index.js';
|
|
34
|
+
// Distillation exports
|
|
35
|
+
export { initializeDistillation, detectTrigger, detectCorrection, isJudgmentSignal, addToTrajectory, detectTrajectoryPattern, distillInput, processFeedback, getTrajectoryStats, clearTrajectory, } from '../pi-ecosystem-judgment/distillation.js';
|
|
36
|
+
// Decision exports
|
|
37
|
+
export { setConfidenceThreshold, getConfidenceThreshold, setDefaultDecisionLevel, getDefaultDecisionLevel, evaluateDecision, submitDecisionResponse, isDecisionResponse, parseDecisionResponse, queryInternalAgents, processHumanFeedback, getPendingDecisions, getDecisionRequest, getDecisionStats, onDecisionEvent, offDecisionEvent, } from '../pi-ecosystem-judgment/decision.js';
|
|
38
|
+
const PI_ECOSYSTEM_DIR = path.join(process.env.HOME || '/tmp', '.bolloon', 'pi-ecosystem');
|
|
39
|
+
const CONFIG_FILE = path.join(PI_ECOSYSTEM_DIR, 'config.json');
|
|
40
|
+
/**
|
|
41
|
+
* Default Pi ecosystem configuration (mirrors oh-pi)
|
|
42
|
+
*/
|
|
43
|
+
const DEFAULT_CONFIG = {
|
|
44
|
+
model: process.env.MINIMAX_MODEL || 'MiniMax-M2.7',
|
|
45
|
+
extensions: [
|
|
46
|
+
'safe-guard',
|
|
47
|
+
'git-guard',
|
|
48
|
+
'auto-session',
|
|
49
|
+
'custom-footer',
|
|
50
|
+
'context7',
|
|
51
|
+
'web-search',
|
|
52
|
+
'git-workflow',
|
|
53
|
+
],
|
|
54
|
+
templates: [
|
|
55
|
+
'/review',
|
|
56
|
+
'/fix',
|
|
57
|
+
'/commit',
|
|
58
|
+
'/test',
|
|
59
|
+
'/plan',
|
|
60
|
+
'/debug',
|
|
61
|
+
'/refactor',
|
|
62
|
+
'/docs',
|
|
63
|
+
'/search',
|
|
64
|
+
'/colony',
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Initialize the Pi ecosystem (mirrors oh-pi setup)
|
|
69
|
+
*/
|
|
70
|
+
export async function initializePiEcosystem(config) {
|
|
71
|
+
await fs.mkdir(PI_ECOSYSTEM_DIR, { recursive: true });
|
|
72
|
+
let currentConfig = DEFAULT_CONFIG;
|
|
73
|
+
try {
|
|
74
|
+
const existing = await fs.readFile(CONFIG_FILE, 'utf-8');
|
|
75
|
+
currentConfig = { ...DEFAULT_CONFIG, ...JSON.parse(existing) };
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// No existing config
|
|
79
|
+
}
|
|
80
|
+
if (config) {
|
|
81
|
+
currentConfig = { ...currentConfig, ...config };
|
|
82
|
+
}
|
|
83
|
+
currentConfig.initializedAt = new Date().toISOString();
|
|
84
|
+
await fs.writeFile(CONFIG_FILE, JSON.stringify(currentConfig, null, 2));
|
|
85
|
+
console.log('[PiEcosystem] Initialized with config:', JSON.stringify(currentConfig, null, 2));
|
|
86
|
+
return currentConfig;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Load Pi ecosystem configuration
|
|
90
|
+
*/
|
|
91
|
+
export async function loadPiConfig() {
|
|
92
|
+
try {
|
|
93
|
+
const data = await fs.readFile(CONFIG_FILE, 'utf-8');
|
|
94
|
+
return JSON.parse(data);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if Pi ecosystem is initialized
|
|
102
|
+
*/
|
|
103
|
+
export async function isPiEcosystemInitialized() {
|
|
104
|
+
try {
|
|
105
|
+
await fs.access(CONFIG_FILE);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get combined Pi ecosystem status
|
|
114
|
+
*/
|
|
115
|
+
export async function getPiEcosystemStatus() {
|
|
116
|
+
const { getAdapterStatus } = await import('../pi-ecosystem-mcp/index.js');
|
|
117
|
+
const { getGoalStats } = await import('../pi-ecosystem-goals/index.js');
|
|
118
|
+
const { getStats } = await import('../pi-ecosystem-subagents/index.js');
|
|
119
|
+
const { getColonyStatus } = await import('../pi-ecosystem-colony/index.js');
|
|
120
|
+
const config = await loadPiConfig();
|
|
121
|
+
const mcpStatus = getAdapterStatus();
|
|
122
|
+
const goalStats = getGoalStats();
|
|
123
|
+
const subagentStats = getStats();
|
|
124
|
+
const colonyStatus = getColonyStatus();
|
|
125
|
+
return {
|
|
126
|
+
initialized: !!config?.initializedAt,
|
|
127
|
+
mcp: mcpStatus,
|
|
128
|
+
goals: goalStats,
|
|
129
|
+
subagents: subagentStats,
|
|
130
|
+
colony: colonyStatus,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Unified Pi ecosystem CLI-like interface
|
|
135
|
+
*/
|
|
136
|
+
export class PiEcosystem {
|
|
137
|
+
initialized = false;
|
|
138
|
+
async initialize(config) {
|
|
139
|
+
if (this.initialized)
|
|
140
|
+
return;
|
|
141
|
+
const [mcp, goals, subagents, colony] = await Promise.all([
|
|
142
|
+
import('../pi-ecosystem-mcp/index.js'),
|
|
143
|
+
import('../pi-ecosystem-goals/index.js'),
|
|
144
|
+
import('../pi-ecosystem-subagents/index.js'),
|
|
145
|
+
import('../pi-ecosystem-colony/index.js'),
|
|
146
|
+
]);
|
|
147
|
+
await mcp.initializeMcpAdapter();
|
|
148
|
+
await goals.loadGoals();
|
|
149
|
+
await subagents.loadSubagents();
|
|
150
|
+
await colony.loadColony();
|
|
151
|
+
await initializePiEcosystem(config);
|
|
152
|
+
this.initialized = true;
|
|
153
|
+
console.log('[PiEcosystem] Initialization complete');
|
|
154
|
+
}
|
|
155
|
+
async getStatus() {
|
|
156
|
+
return getPiEcosystemStatus();
|
|
157
|
+
}
|
|
158
|
+
async addMcpTool(config) {
|
|
159
|
+
const mcp = await import('../pi-ecosystem-mcp/index.js');
|
|
160
|
+
mcp.registerServer(config);
|
|
161
|
+
}
|
|
162
|
+
async listMcpTools() {
|
|
163
|
+
const mcp = await import('../pi-ecosystem-mcp/index.js');
|
|
164
|
+
return mcp.listTools().map(t => t.name);
|
|
165
|
+
}
|
|
166
|
+
async createGoal(objective, budget) {
|
|
167
|
+
const goals = await import('../pi-ecosystem-goals/index.js');
|
|
168
|
+
const goal = await goals.createGoal(objective, budget);
|
|
169
|
+
return goal.id;
|
|
170
|
+
}
|
|
171
|
+
async createGoalQueue(objectives) {
|
|
172
|
+
const goals = await import('../pi-ecosystem-goals/index.js');
|
|
173
|
+
const goalList = await goals.createGoalQueue(objectives);
|
|
174
|
+
return goalList.map(g => g.id);
|
|
175
|
+
}
|
|
176
|
+
async getCurrentGoal() {
|
|
177
|
+
const goals = await import('../pi-ecosystem-goals/index.js');
|
|
178
|
+
const goal = goals.getCurrentGoal();
|
|
179
|
+
return goal?.id || null;
|
|
180
|
+
}
|
|
181
|
+
async advanceGoal(result) {
|
|
182
|
+
const goals = await import('../pi-ecosystem-goals/index.js');
|
|
183
|
+
if (result) {
|
|
184
|
+
await goals.completeCurrentGoal(result);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await goals.completeCurrentGoal();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async delegateTask(task, command) {
|
|
191
|
+
const subagents = await import('../pi-ecosystem-subagents/index.js');
|
|
192
|
+
const result = await subagents.delegateTask(task, command);
|
|
193
|
+
return result.subagentId;
|
|
194
|
+
}
|
|
195
|
+
async listSubagents() {
|
|
196
|
+
const subagents = await import('../pi-ecosystem-subagents/index.js');
|
|
197
|
+
return subagents.listSubagents().map(s => s.id);
|
|
198
|
+
}
|
|
199
|
+
async registerAnt(name, role) {
|
|
200
|
+
const colony = await import('../pi-ecosystem-colony/index.js');
|
|
201
|
+
const ant = colony.registerAnt(name, role);
|
|
202
|
+
return ant.id;
|
|
203
|
+
}
|
|
204
|
+
async createColonyTask(description) {
|
|
205
|
+
const colony = await import('../pi-ecosystem-colony/index.js');
|
|
206
|
+
const task = colony.createTask(description);
|
|
207
|
+
return task.id;
|
|
208
|
+
}
|
|
209
|
+
async dispatchToColony(taskId, antIds) {
|
|
210
|
+
const colony = await import('../pi-ecosystem-colony/index.js');
|
|
211
|
+
colony.dispatchTask(taskId, antIds);
|
|
212
|
+
}
|
|
213
|
+
async persist() {
|
|
214
|
+
const colony = await import('../pi-ecosystem-colony/index.js');
|
|
215
|
+
await colony.persistColony();
|
|
216
|
+
}
|
|
217
|
+
async shutdown() {
|
|
218
|
+
await this.persist();
|
|
219
|
+
console.log('[PiEcosystem] Shutdown complete');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let piEcosystemInstance = null;
|
|
223
|
+
export function getPiEcosystem() {
|
|
224
|
+
if (!piEcosystemInstance) {
|
|
225
|
+
piEcosystemInstance = new PiEcosystem();
|
|
226
|
+
}
|
|
227
|
+
return piEcosystemInstance;
|
|
228
|
+
}
|
|
229
|
+
export async function ohMyPi(config) {
|
|
230
|
+
const ecosystem = getPiEcosystem();
|
|
231
|
+
await ecosystem.initialize(config);
|
|
232
|
+
return ecosystem;
|
|
233
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Pi Ant Colony Integration for Bolloon
|
|
4
3
|
*
|
|
@@ -13,75 +12,16 @@
|
|
|
13
12
|
* - Per-ant turn limits, cost tracking, concurrent scheduling
|
|
14
13
|
* - White-box design: no "what is it doing in the background" anxiety
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
-
}
|
|
22
|
-
Object.defineProperty(o, k2, desc);
|
|
23
|
-
}) : (function(o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
o[k2] = m[k];
|
|
26
|
-
}));
|
|
27
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
-
}) : function(o, v) {
|
|
30
|
-
o["default"] = v;
|
|
31
|
-
});
|
|
32
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
-
var ownKeys = function(o) {
|
|
34
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
-
var ar = [];
|
|
36
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
-
return ar;
|
|
38
|
-
};
|
|
39
|
-
return ownKeys(o);
|
|
40
|
-
};
|
|
41
|
-
return function (mod) {
|
|
42
|
-
if (mod && mod.__esModule) return mod;
|
|
43
|
-
var result = {};
|
|
44
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
-
__setModuleDefault(result, mod);
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
})();
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.registerAnt = registerAnt;
|
|
51
|
-
exports.antScouting = antScouting;
|
|
52
|
-
exports.antWorking = antWorking;
|
|
53
|
-
exports.antReviewing = antReviewing;
|
|
54
|
-
exports.antComplete = antComplete;
|
|
55
|
-
exports.antFail = antFail;
|
|
56
|
-
exports.antAbort = antAbort;
|
|
57
|
-
exports.antTick = antTick;
|
|
58
|
-
exports.createTask = createTask;
|
|
59
|
-
exports.dispatchTask = dispatchTask;
|
|
60
|
-
exports.recordResult = recordResult;
|
|
61
|
-
exports.getAnt = getAnt;
|
|
62
|
-
exports.listAnts = listAnts;
|
|
63
|
-
exports.listAntsByRole = listAntsByRole;
|
|
64
|
-
exports.listAntsBySignal = listAntsBySignal;
|
|
65
|
-
exports.getActiveAnts = getActiveAnts;
|
|
66
|
-
exports.getTask = getTask;
|
|
67
|
-
exports.listTasks = listTasks;
|
|
68
|
-
exports.getSignalHistory = getSignalHistory;
|
|
69
|
-
exports.getColonyStatus = getColonyStatus;
|
|
70
|
-
exports.onColonyEvent = onColonyEvent;
|
|
71
|
-
exports.offColonyEvent = offColonyEvent;
|
|
72
|
-
exports.getColonyDump = getColonyDump;
|
|
73
|
-
exports.persistColony = persistColony;
|
|
74
|
-
exports.loadColony = loadColony;
|
|
75
|
-
const events_1 = require("events");
|
|
76
|
-
const fs = __importStar(require("fs/promises"));
|
|
77
|
-
const path = __importStar(require("path"));
|
|
15
|
+
import { EventEmitter } from 'events';
|
|
16
|
+
import * as fs from 'fs/promises';
|
|
17
|
+
import * as path from 'path';
|
|
78
18
|
// Colony state
|
|
79
19
|
const ants = new Map();
|
|
80
20
|
const tasks = new Map();
|
|
81
21
|
const signalHistory = [];
|
|
82
22
|
const STATE_DIR = path.join(process.env.HOME || '/tmp', '.bolloon', 'colony');
|
|
83
23
|
// Event emitter
|
|
84
|
-
class ColonyEventEmitter extends
|
|
24
|
+
class ColonyEventEmitter extends EventEmitter {
|
|
85
25
|
}
|
|
86
26
|
const colonyEvents = new ColonyEventEmitter();
|
|
87
27
|
/**
|
|
@@ -93,7 +33,7 @@ function generateAntId() {
|
|
|
93
33
|
/**
|
|
94
34
|
* Register a new ant in the colony
|
|
95
35
|
*/
|
|
96
|
-
function registerAnt(name, role, maxTurns = 10, tokenBudget = 50000) {
|
|
36
|
+
export function registerAnt(name, role, maxTurns = 10, tokenBudget = 50000) {
|
|
97
37
|
const id = generateAntId();
|
|
98
38
|
const ant = {
|
|
99
39
|
id,
|
|
@@ -140,7 +80,7 @@ function emitSignal(antId, newSignal, details) {
|
|
|
140
80
|
/**
|
|
141
81
|
* Transition ant to SCOUTING
|
|
142
82
|
*/
|
|
143
|
-
function antScouting(antId, task) {
|
|
83
|
+
export function antScouting(antId, task) {
|
|
144
84
|
const ant = ants.get(antId);
|
|
145
85
|
if (!ant)
|
|
146
86
|
return;
|
|
@@ -151,7 +91,7 @@ function antScouting(antId, task) {
|
|
|
151
91
|
/**
|
|
152
92
|
* Transition ant to WORKING
|
|
153
93
|
*/
|
|
154
|
-
function antWorking(antId) {
|
|
94
|
+
export function antWorking(antId) {
|
|
155
95
|
const ant = ants.get(antId);
|
|
156
96
|
if (!ant)
|
|
157
97
|
return;
|
|
@@ -160,13 +100,13 @@ function antWorking(antId) {
|
|
|
160
100
|
/**
|
|
161
101
|
* Transition ant to REVIEWING
|
|
162
102
|
*/
|
|
163
|
-
function antReviewing(antId) {
|
|
103
|
+
export function antReviewing(antId) {
|
|
164
104
|
emitSignal(antId, 'REVIEWING');
|
|
165
105
|
}
|
|
166
106
|
/**
|
|
167
107
|
* Complete ant work
|
|
168
108
|
*/
|
|
169
|
-
function antComplete(antId, result) {
|
|
109
|
+
export function antComplete(antId, result) {
|
|
170
110
|
const ant = ants.get(antId);
|
|
171
111
|
if (!ant)
|
|
172
112
|
return;
|
|
@@ -177,7 +117,7 @@ function antComplete(antId, result) {
|
|
|
177
117
|
/**
|
|
178
118
|
* Fail ant work
|
|
179
119
|
*/
|
|
180
|
-
function antFail(antId, error) {
|
|
120
|
+
export function antFail(antId, error) {
|
|
181
121
|
const ant = ants.get(antId);
|
|
182
122
|
if (!ant)
|
|
183
123
|
return;
|
|
@@ -188,13 +128,13 @@ function antFail(antId, error) {
|
|
|
188
128
|
/**
|
|
189
129
|
* Abort ant work
|
|
190
130
|
*/
|
|
191
|
-
function antAbort(antId, reason) {
|
|
131
|
+
export function antAbort(antId, reason) {
|
|
192
132
|
emitSignal(antId, 'ABORTED', reason);
|
|
193
133
|
}
|
|
194
134
|
/**
|
|
195
135
|
* Increment turn count
|
|
196
136
|
*/
|
|
197
|
-
function antTick(antId, tokensUsed = 0) {
|
|
137
|
+
export function antTick(antId, tokensUsed = 0) {
|
|
198
138
|
const ant = ants.get(antId);
|
|
199
139
|
if (!ant)
|
|
200
140
|
return;
|
|
@@ -213,7 +153,7 @@ function antTick(antId, tokensUsed = 0) {
|
|
|
213
153
|
/**
|
|
214
154
|
* Create a colony task
|
|
215
155
|
*/
|
|
216
|
-
function createTask(description) {
|
|
156
|
+
export function createTask(description) {
|
|
217
157
|
const id = `task-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
218
158
|
const task = {
|
|
219
159
|
id,
|
|
@@ -230,7 +170,7 @@ function createTask(description) {
|
|
|
230
170
|
/**
|
|
231
171
|
* Dispatch task to ants
|
|
232
172
|
*/
|
|
233
|
-
function dispatchTask(taskId, antIds) {
|
|
173
|
+
export function dispatchTask(taskId, antIds) {
|
|
234
174
|
const task = tasks.get(taskId);
|
|
235
175
|
if (!task)
|
|
236
176
|
return;
|
|
@@ -248,7 +188,7 @@ function dispatchTask(taskId, antIds) {
|
|
|
248
188
|
/**
|
|
249
189
|
* Record ant result for a task
|
|
250
190
|
*/
|
|
251
|
-
function recordResult(taskId, antId, result) {
|
|
191
|
+
export function recordResult(taskId, antId, result) {
|
|
252
192
|
const task = tasks.get(taskId);
|
|
253
193
|
if (!task)
|
|
254
194
|
return;
|
|
@@ -266,55 +206,55 @@ function recordResult(taskId, antId, result) {
|
|
|
266
206
|
/**
|
|
267
207
|
* Get ant by ID
|
|
268
208
|
*/
|
|
269
|
-
function getAnt(antId) {
|
|
209
|
+
export function getAnt(antId) {
|
|
270
210
|
return ants.get(antId);
|
|
271
211
|
}
|
|
272
212
|
/**
|
|
273
213
|
* List all ants
|
|
274
214
|
*/
|
|
275
|
-
function listAnts() {
|
|
215
|
+
export function listAnts() {
|
|
276
216
|
return Array.from(ants.values());
|
|
277
217
|
}
|
|
278
218
|
/**
|
|
279
219
|
* List ants by role
|
|
280
220
|
*/
|
|
281
|
-
function listAntsByRole(role) {
|
|
221
|
+
export function listAntsByRole(role) {
|
|
282
222
|
return Array.from(ants.values()).filter((a) => a.role === role);
|
|
283
223
|
}
|
|
284
224
|
/**
|
|
285
225
|
* Get ants by signal state
|
|
286
226
|
*/
|
|
287
|
-
function listAntsBySignal(signal) {
|
|
227
|
+
export function listAntsBySignal(signal) {
|
|
288
228
|
return Array.from(ants.values()).filter((a) => a.signal === signal);
|
|
289
229
|
}
|
|
290
230
|
/**
|
|
291
231
|
* Get active ants (not complete/failed/aborted)
|
|
292
232
|
*/
|
|
293
|
-
function getActiveAnts() {
|
|
233
|
+
export function getActiveAnts() {
|
|
294
234
|
return Array.from(ants.values()).filter((a) => !['COMPLETE', 'FAILED', 'ABORTED'].includes(a.signal));
|
|
295
235
|
}
|
|
296
236
|
/**
|
|
297
237
|
* Get task by ID
|
|
298
238
|
*/
|
|
299
|
-
function getTask(taskId) {
|
|
239
|
+
export function getTask(taskId) {
|
|
300
240
|
return tasks.get(taskId);
|
|
301
241
|
}
|
|
302
242
|
/**
|
|
303
243
|
* List all tasks
|
|
304
244
|
*/
|
|
305
|
-
function listTasks() {
|
|
245
|
+
export function listTasks() {
|
|
306
246
|
return Array.from(tasks.values());
|
|
307
247
|
}
|
|
308
248
|
/**
|
|
309
249
|
* Get signal history
|
|
310
250
|
*/
|
|
311
|
-
function getSignalHistory() {
|
|
251
|
+
export function getSignalHistory() {
|
|
312
252
|
return [...signalHistory];
|
|
313
253
|
}
|
|
314
254
|
/**
|
|
315
255
|
* Get colony status
|
|
316
256
|
*/
|
|
317
|
-
function getColonyStatus() {
|
|
257
|
+
export function getColonyStatus() {
|
|
318
258
|
const antList = Array.from(ants.values());
|
|
319
259
|
const taskList = Array.from(tasks.values());
|
|
320
260
|
const signalDistribution = {
|
|
@@ -340,19 +280,19 @@ function getColonyStatus() {
|
|
|
340
280
|
/**
|
|
341
281
|
* Subscribe to colony events
|
|
342
282
|
*/
|
|
343
|
-
function onColonyEvent(event, callback) {
|
|
283
|
+
export function onColonyEvent(event, callback) {
|
|
344
284
|
colonyEvents.on(event, callback);
|
|
345
285
|
}
|
|
346
286
|
/**
|
|
347
287
|
* Unsubscribe from colony events
|
|
348
288
|
*/
|
|
349
|
-
function offColonyEvent(event, callback) {
|
|
289
|
+
export function offColonyEvent(event, callback) {
|
|
350
290
|
colonyEvents.off(event, callback);
|
|
351
291
|
}
|
|
352
292
|
/**
|
|
353
293
|
* Get formatted colony dump for debugging
|
|
354
294
|
*/
|
|
355
|
-
function getColonyDump() {
|
|
295
|
+
export function getColonyDump() {
|
|
356
296
|
const status = getColonyStatus();
|
|
357
297
|
const active = getActiveAnts();
|
|
358
298
|
let dump = '# Colony Status\n\n';
|
|
@@ -381,7 +321,7 @@ function getColonyDump() {
|
|
|
381
321
|
/**
|
|
382
322
|
* Persist colony state
|
|
383
323
|
*/
|
|
384
|
-
async function persistColony() {
|
|
324
|
+
export async function persistColony() {
|
|
385
325
|
try {
|
|
386
326
|
await fs.mkdir(STATE_DIR, { recursive: true });
|
|
387
327
|
const state = {
|
|
@@ -403,7 +343,7 @@ async function persistColony() {
|
|
|
403
343
|
/**
|
|
404
344
|
* Load colony state
|
|
405
345
|
*/
|
|
406
|
-
async function loadColony() {
|
|
346
|
+
export async function loadColony() {
|
|
407
347
|
try {
|
|
408
348
|
const data = await fs.readFile(path.join(STATE_DIR, 'colony.json'), 'utf-8');
|
|
409
349
|
const state = JSON.parse(data);
|
|
@@ -423,4 +363,3 @@ async function loadColony() {
|
|
|
423
363
|
// No persisted state
|
|
424
364
|
}
|
|
425
365
|
}
|
|
426
|
-
//# sourceMappingURL=index.js.map
|