@bolloon/bolloon-agent 0.1.37 → 0.1.39

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 (31) hide show
  1. package/dist/agents/constraint-layer.js +1 -2
  2. package/package.json +1 -1
  3. package/scripts/auto-evolve-oneshot.sh +155 -0
  4. package/scripts/auto-evolve-snapshot.sh +136 -0
  5. package/scripts/build-cli.js +216 -0
  6. package/scripts/detect-schema-changes.sh +48 -0
  7. package/scripts/postinstall.js +153 -0
  8. package/dist/bollharness-integration/llm/pi-ai.js +0 -397
  9. package/dist/bollharness-integration/pi-ecosystem-colony/index.js +0 -365
  10. package/dist/bollharness-integration/pi-ecosystem-goals/index.js +0 -458
  11. package/dist/bollharness-integration/pi-ecosystem-judgment/decision.js +0 -300
  12. package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.js +0 -291
  13. package/dist/bollharness-integration/pi-ecosystem-judgment/index.js +0 -445
  14. package/dist/bollharness-integration/pi-ecosystem-mcp/index.js +0 -331
  15. package/dist/bollharness-integration/pi-ecosystem-subagents/index.js +0 -303
  16. package/dist/constraints/commands.js +0 -100
  17. package/dist/constraints/permissions.js +0 -37
  18. package/dist/constraints/runtime.js +0 -135
  19. package/dist/constraints/session.js +0 -48
  20. package/dist/constraints/system-init.js +0 -51
  21. package/dist/constraints/tools.js +0 -104
  22. package/dist/llm/minimax-provider.js +0 -46
  23. package/dist/llm/minimax.js +0 -45
  24. package/dist/pi-ecosystem-colony/index.js +0 -365
  25. package/dist/runtime/context/minimax-prompt.js +0 -178
  26. package/dist/runtime/context/sys-prompt.js +0 -1
  27. package/dist/social/ant-colony/AdaptiveHeartbeat.js +0 -101
  28. package/dist/social/ant-colony/PheromoneEngine.js +0 -227
  29. package/dist/social/ant-colony/index.js +0 -6
  30. package/dist/social/ant-colony/types.js +0 -24
  31. package/dist/utils/double.js +0 -6
@@ -1,227 +0,0 @@
1
- /**
2
- * PheromoneEngine - 信息素管理引擎
3
- *
4
- * 模拟蚂蚁的信息素系统,用于引导智能体发现和路由决策
5
- */
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 };
10
- const PHEROMONE_DB_PATH = path.join(process.env.HOME || '/tmp', '.bolloon', 'ant-colony', 'pheromones.json');
11
- export class PheromoneEngine {
12
- trails = new Map();
13
- fields = new Map();
14
- evaporationTimer = null;
15
- saveTimer = null;
16
- dirty = false;
17
- async initialize() {
18
- await fs.mkdir(path.dirname(PHEROMONE_DB_PATH), { recursive: true });
19
- await this.load();
20
- this.startEvaporation();
21
- this.startAutoSave();
22
- }
23
- startEvaporation() {
24
- this.evaporationTimer = setInterval(() => {
25
- this.evaporate();
26
- }, DEFAULT_PHEROMONE_CONFIG.evaporationInterval);
27
- }
28
- startAutoSave() {
29
- this.saveTimer = setInterval(() => {
30
- if (this.dirty) {
31
- this.save().catch(console.error);
32
- this.dirty = false;
33
- }
34
- }, 30000);
35
- }
36
- /**
37
- * 放置信息素
38
- */
39
- async deposit(type, sourceDid, targetDid, strength = 0.5, options) {
40
- const key = this.getTrailKey(type, sourceDid, targetDid);
41
- const existing = this.trails.get(key);
42
- const newStrength = existing
43
- ? Math.min(1, existing.strength + strength * 0.3)
44
- : Math.min(1, strength);
45
- const trail = {
46
- id: key,
47
- type,
48
- sourceDid,
49
- targetDid,
50
- strength: newStrength,
51
- decayRate: DEFAULT_PHEROMONE_CONFIG.decayRate,
52
- createdAt: existing?.createdAt || Date.now(),
53
- lastUpdate: Date.now(),
54
- capability: options?.capability,
55
- qualityScore: options?.qualityScore,
56
- };
57
- this.trails.set(key, trail);
58
- this.dirty = true;
59
- if (options?.capability) {
60
- this.updateField(type, targetDid, options.capability);
61
- }
62
- }
63
- /**
64
- * 读取某方向的信息素强度
65
- */
66
- getStrength(type, targetDid) {
67
- let totalStrength = 0;
68
- let count = 0;
69
- for (const trail of this.trails.values()) {
70
- if (trail.type === type && trail.targetDid === targetDid) {
71
- totalStrength += trail.strength;
72
- count++;
73
- }
74
- }
75
- return count > 0 ? totalStrength / count : 0;
76
- }
77
- /**
78
- * 查询特定能力的最佳节点
79
- */
80
- queryByCapability(capability, limit = 5) {
81
- const field = this.fields.get(capability);
82
- if (!field)
83
- return [];
84
- const candidates = [];
85
- for (const trail of this.trails.values()) {
86
- if (trail.type === PheromoneType.CAPABILITY &&
87
- trail.capability?.includes(capability)) {
88
- const score = trail.strength * (trail.qualityScore || 0.5);
89
- candidates.push({ did: trail.targetDid, strength: score });
90
- }
91
- }
92
- candidates.sort((a, b) => b.strength - a.strength);
93
- return candidates.slice(0, limit).map((c) => c.did);
94
- }
95
- /**
96
- * 获取到达某节点的最佳下一跳
97
- */
98
- getNextHop(targetDid, excludeDids = []) {
99
- let bestHop = null;
100
- let bestStrength = 0;
101
- for (const trail of this.trails.values()) {
102
- if (trail.targetDid === targetDid && trail.strength > bestStrength) {
103
- if (!excludeDids.includes(trail.sourceDid)) {
104
- bestHop = trail.sourceDid;
105
- bestStrength = trail.strength;
106
- }
107
- }
108
- }
109
- return bestHop;
110
- }
111
- /**
112
- * 获取所有已知节点及其信息素强度
113
- */
114
- getAllNodeStrengths() {
115
- const result = new Map();
116
- for (const trail of this.trails.values()) {
117
- const current = result.get(trail.targetDid) || 0;
118
- result.set(trail.targetDid, Math.max(current, trail.strength));
119
- }
120
- return result;
121
- }
122
- /**
123
- * 获取信息素统计
124
- */
125
- getStats() {
126
- let totalStrength = 0;
127
- for (const trail of this.trails.values()) {
128
- totalStrength += trail.strength;
129
- }
130
- return {
131
- totalTrails: this.trails.size,
132
- avgStrength: this.trails.size > 0 ? totalStrength / this.trails.size : 0,
133
- capabilityCount: this.fields.size,
134
- };
135
- }
136
- getTrailKey(type, source, target) {
137
- return `${type}:${source}:${target}`;
138
- }
139
- updateField(type, targetDid, capability) {
140
- if (!capability)
141
- return;
142
- for (const cap of capability) {
143
- let field = this.fields.get(cap);
144
- if (!field) {
145
- field = {
146
- capability: cap,
147
- avgStrength: 0,
148
- nodeCount: 0,
149
- lastUpdate: Date.now(),
150
- };
151
- this.fields.set(cap, field);
152
- }
153
- const trails = Array.from(this.trails.values()).filter((t) => t.type === type && t.capability?.includes(cap));
154
- field.avgStrength =
155
- trails.reduce((sum, t) => sum + t.strength, 0) / (trails.length || 1);
156
- field.nodeCount = new Set(trails.map((t) => t.targetDid)).size;
157
- field.lastUpdate = Date.now();
158
- }
159
- }
160
- evaporate() {
161
- const now = Date.now();
162
- const toDelete = [];
163
- for (const [key, trail] of this.trails.entries()) {
164
- const ageHours = (now - trail.lastUpdate) / (1000 * 60 * 60);
165
- const decayFactor = Math.pow(1 - trail.decayRate, ageHours);
166
- trail.strength = trail.strength * decayFactor;
167
- if (trail.strength < DEFAULT_PHEROMONE_CONFIG.minStrength ||
168
- now - trail.createdAt > DEFAULT_PHEROMONE_CONFIG.maxTrailAge) {
169
- toDelete.push(key);
170
- }
171
- else {
172
- trail.lastUpdate = now;
173
- }
174
- }
175
- for (const key of toDelete) {
176
- this.trails.delete(key);
177
- }
178
- if (toDelete.length > 0) {
179
- this.dirty = true;
180
- this.save().catch(console.error);
181
- }
182
- }
183
- async save() {
184
- try {
185
- const data = {
186
- trails: Array.from(this.trails.values()),
187
- fields: Array.from(this.fields.entries()),
188
- };
189
- await fs.writeFile(PHEROMONE_DB_PATH, JSON.stringify(data, null, 2));
190
- }
191
- catch (e) {
192
- console.warn('[PheromoneEngine] Save failed:', e);
193
- }
194
- }
195
- async load() {
196
- try {
197
- const data = await fs.readFile(PHEROMONE_DB_PATH, 'utf-8');
198
- const parsed = JSON.parse(data);
199
- this.trails.clear();
200
- for (const t of parsed.trails || []) {
201
- this.trails.set(t.id, t);
202
- }
203
- this.fields.clear();
204
- for (const [cap, field] of parsed.fields || []) {
205
- this.fields.set(cap, field);
206
- }
207
- console.log(`[PheromoneEngine] Loaded ${this.trails.size} trails, ${this.fields.size} fields`);
208
- }
209
- catch {
210
- console.log('[PheromoneEngine] No existing pheromone data, starting fresh');
211
- }
212
- }
213
- shutdown() {
214
- if (this.evaporationTimer) {
215
- clearInterval(this.evaporationTimer);
216
- }
217
- if (this.saveTimer) {
218
- clearInterval(this.saveTimer);
219
- }
220
- if (this.dirty) {
221
- this.save()
222
- .then(() => console.log('[PheromoneEngine] Saved on shutdown'))
223
- .catch(console.error);
224
- }
225
- }
226
- }
227
- export const pheromoneEngine = new PheromoneEngine();
@@ -1,6 +0,0 @@
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,24 +0,0 @@
1
- /**
2
- * Ant Colony Types - 信息素系统类型定义
3
- */
4
- export var PheromoneType;
5
- (function (PheromoneType) {
6
- PheromoneType["DISCOVERY"] = "discovery";
7
- PheromoneType["CAPABILITY"] = "capability";
8
- })(PheromoneType || (PheromoneType = {}));
9
- export const DEFAULT_PHEROMONE_CONFIG = {
10
- decayRate: 0.05,
11
- evaporationInterval: 5 * 60 * 1000,
12
- maxTrailAge: 24 * 60 * 60 * 1000,
13
- minStrength: 0.05,
14
- maxStrength: 1.0,
15
- };
16
- export const DEFAULT_ADAPTIVE_CONFIG = {
17
- minInterval: 10 * 1000,
18
- maxInterval: 120 * 1000,
19
- baseInterval: 30 * 1000,
20
- lowActivityThreshold: 0.5,
21
- highActivityThreshold: 5,
22
- pheromoneBoostFactor: 0.3,
23
- discoveryBoostFactor: 0.4,
24
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * double.ts — 阶段 D loop 验证 (故意坏)
3
- */
4
- export function double(n) {
5
- return n * 2; // 修复: 正确实现 double
6
- }