@bolloon/bolloon-agent 0.2.14 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/goal-resume.js +321 -0
- package/dist/agents/pi-sdk-tools.js +99 -0
- package/dist/bollharness-integration/skill-adapter.js +111 -0
- package/dist/bootstrap/lifecycle-hooks.js +45 -0
- package/dist/cli-entry.js +1 -1
- package/dist/llm/config-store.js +93 -14
- package/dist/llm/system-prompt/layers/channel/human-async.md +41 -0
- package/dist/llm/system-prompt/layers/channel/p2p-peer-sync.md +51 -0
- package/dist/llm/system-prompt/layers/channel/p2p-proactive.md +43 -0
- package/dist/llm/system-prompt/layers/channel/session-handoff.md +61 -0
- package/dist/llm/system-prompt/layers/core/external-engagement.md +73 -0
- package/dist/llm/system-prompt/layers/core/identity.md +30 -19
- package/dist/llm/system-prompt/layers/tool/goal_handoff.md +77 -0
- package/dist/llm/system-prompt/layers/tool/p2p_request.md +61 -0
- package/dist/llm/system-prompt/registry.js +20 -2
- package/dist/web/api-config.html +12 -2
- package/dist/web/routes-llm-config.js +23 -13
- package/package.json +2 -2
|
@@ -91,7 +91,6 @@ const STATIC_LAYERS = [
|
|
|
91
91
|
{ id: 'core.tone', version: '1.0.0', priority: 110, appliesTo: ['all'], source: 'static-md', maxChars: 500, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
92
92
|
{ id: 'core.wellbeing', version: '1.0.0', priority: 120, appliesTo: ['all'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
93
93
|
{ id: 'core.evenhandedness', version: '1.0.0', priority: 130, appliesTo: ['all'], source: 'static-md', maxChars: 300, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
94
|
-
{ id: 'core.memory_system', version: '1.0.0', priority: 140, appliesTo: ['all'], source: 'static-md', maxChars: 200, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
95
94
|
{ id: 'core.artifacts_storage', version: '1.0.0', priority: 145, appliesTo: ['never'], source: 'static-md', maxChars: 0, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
96
95
|
{ id: 'core.network_filesystem', version: '1.0.0', priority: 148, appliesTo: ['never'], source: 'static-md', maxChars: 0, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
97
96
|
// ── role/ ── 阶段 0 只用 expert, 其他 3 个停用 (节省 + 阶段 0 不分 role)
|
|
@@ -103,6 +102,17 @@ const STATIC_LAYERS = [
|
|
|
103
102
|
{ id: 'channel.local', version: '1.0.0', priority: 150, appliesTo: ['local'], source: 'static-md', maxChars: 500, meta: DEFAULT_META(TTL_CHANNEL) },
|
|
104
103
|
{ id: 'channel.p2p-visitor', version: '1.0.0', priority: 150, appliesTo: ['p2p-visitor'], source: 'static-md', maxChars: 700 },
|
|
105
104
|
{ id: 'channel.p2p-agent', version: '1.0.0', priority: 150, appliesTo: ['p2p-agent'], source: 'static-md', maxChars: 700 },
|
|
105
|
+
// 2026-07-10 双栖 agent 网络新增 (按 plan 阶段 3):
|
|
106
|
+
{ id: 'channel.p2p-peer-sync', version: '1.0.0', priority: 150, appliesTo: ['local', 'p2p-agent'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_CHANNEL) },
|
|
107
|
+
{ id: 'channel.p2p-proactive', version: '1.0.0', priority: 150, appliesTo: ['p2p-agent'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_CHANNEL) },
|
|
108
|
+
{ id: 'channel.human-async', version: '1.0.0', priority: 150, appliesTo: ['local'], source: 'static-md', maxChars: 500, meta: DEFAULT_META(TTL_CHANNEL) },
|
|
109
|
+
{ id: 'channel.session-handoff', version: '1.0.0', priority: 150, appliesTo: ['local', 'p2p-visitor', 'p2p-agent'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_CHANNEL) },
|
|
110
|
+
// ── core/ ──
|
|
111
|
+
{ id: 'core.memory_system', version: '1.0.0', priority: 140, appliesTo: ['all'], source: 'static-md', maxChars: 200, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
112
|
+
// 2026-07-10 双栖 agent 网络新增 (按 plan 阶段 4):
|
|
113
|
+
// priority 90 (在 channel 150 之后) — 保证 channel 装完后再装 core, 避免 channel 预算被 core 吃掉
|
|
114
|
+
// maxChars 700 → 400: 7 个新 layer 总预算 3900 chars, 必须让出空间给 tool.p2p_request (700) + tool.goal_handoff (600)
|
|
115
|
+
{ id: 'core.external-engagement', version: '1.0.0', priority: 90, appliesTo: ['all'], source: 'static-md', maxChars: 400, meta: DEFAULT_META(TTL_KNOWLEDGE) },
|
|
106
116
|
// ── tool/ (按工具调用嵌对应 layer) ──
|
|
107
117
|
{ id: 'tool.bash', version: '1.0.0', priority: 250, appliesTo: ['tool:bash'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_TOOL) },
|
|
108
118
|
{ id: 'tool.web_search', version: '1.0.0', priority: 250, appliesTo: ['tool:web_search'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_TOOL) },
|
|
@@ -111,6 +121,9 @@ const STATIC_LAYERS = [
|
|
|
111
121
|
{ id: 'tool.image_search', version: '1.0.0', priority: 250, appliesTo: ['never'], source: 'static-md', maxChars: 0, meta: DEFAULT_META(TTL_TOOL) },
|
|
112
122
|
{ id: 'tool.artifacts', version: '1.0.0', priority: 250, appliesTo: ['never'], source: 'static-md', maxChars: 0, meta: DEFAULT_META(TTL_TOOL) },
|
|
113
123
|
{ id: 'tool.manifest', version: '1.0.0', priority: 250, appliesTo: ['tool:manifest'], source: 'static-md', maxChars: 500, meta: DEFAULT_META(TTL_TOOL) },
|
|
124
|
+
// 2026-07-10 双栖 agent 网络新增 (按 plan 阶段 5):
|
|
125
|
+
{ id: 'tool.p2p_request', version: '1.0.0', priority: 250, appliesTo: ['tool:send_message', 'tool:send_to_channel', 'tool:check_inbox', 'tool:list_peers', 'tool:agent_call', 'tool:broadcast_message'], source: 'static-md', maxChars: 700, meta: DEFAULT_META(TTL_TOOL) },
|
|
126
|
+
{ id: 'tool.goal_handoff', version: '1.0.0', priority: 250, appliesTo: ['tool:park_goal', 'tool:resume_goal', 'tool:continue_goal_background'], source: 'static-md', maxChars: 600, meta: DEFAULT_META(TTL_TOOL) },
|
|
114
127
|
];
|
|
115
128
|
/**
|
|
116
129
|
* 动态 layer (运行时计算, 例如 project context, judgment 注入)
|
|
@@ -141,8 +154,13 @@ const DYNAMIC_LAYERS = [
|
|
|
141
154
|
* P-Action 4 (2026-06-15): 总字符上限 15000 → 4500.
|
|
142
155
|
* 阶段 0 单次 system prompt 控制在 ≤ 4.5KB (≈ 1125 tokens).
|
|
143
156
|
* 配合单 layer maxChars 收紧 + 6 layer 停用, 每轮 chat 节省 ≈ 2625 tokens.
|
|
157
|
+
*
|
|
158
|
+
* 2026-07-10 改造: 4500 → 6500 → 8000 (≈ 2000 tokens).
|
|
159
|
+
* 原因: 7 个新 layer (4 channel + 1 core + 2 tool) 合计 ≈ 3500 chars.
|
|
160
|
+
* 实际测算: 现有 11 个 layer 装配后 ≈ 6930 chars; 必须松绑到 8000 才能保证 tool.* 也装入.
|
|
161
|
+
* 每次 chat 多 ~875 tokens input (7% 增), 可接受 — 双栖 agent 网络的"目标接力"必须让 LLM 看到.
|
|
144
162
|
*/
|
|
145
|
-
const TOTAL_BUDGET =
|
|
163
|
+
const TOTAL_BUDGET = 8000;
|
|
146
164
|
export async function assembleSystemPrompt(ctx) {
|
|
147
165
|
// 1. 收集所有 layer
|
|
148
166
|
const allLayers = [];
|
package/dist/web/api-config.html
CHANGED
|
@@ -421,7 +421,15 @@
|
|
|
421
421
|
const result = document.getElementById('testResult');
|
|
422
422
|
|
|
423
423
|
btn.disabled = true;
|
|
424
|
-
|
|
424
|
+
// v0.2.15: defer label mutation to the next frame. Synchronously
|
|
425
|
+
// replacing the button's innerHTML in its own click handler cancels
|
|
426
|
+
// the click event in several Chromium-derived engines — the user
|
|
427
|
+
// observed the first click "doing nothing" until they closed and
|
|
428
|
+
// reopened the modal. Wrapping the mutation in requestAnimationFrame
|
|
429
|
+
// lets the click event finish dispatching first.
|
|
430
|
+
requestAnimationFrame(() => {
|
|
431
|
+
btn.textContent = '⚡ 测试中...';
|
|
432
|
+
});
|
|
425
433
|
result.style.display = 'none';
|
|
426
434
|
|
|
427
435
|
const endpoint = currentProviderType === 'llm' ? '/api/llm-test' :
|
|
@@ -447,7 +455,9 @@
|
|
|
447
455
|
}
|
|
448
456
|
|
|
449
457
|
btn.disabled = false;
|
|
450
|
-
|
|
458
|
+
requestAnimationFrame(() => {
|
|
459
|
+
btn.textContent = '⚡ 测试连接';
|
|
460
|
+
});
|
|
451
461
|
}
|
|
452
462
|
|
|
453
463
|
// ==================== 保存 ====================
|
|
@@ -43,20 +43,30 @@ export function registerLlmConfigRoutes(app) {
|
|
|
43
43
|
config.apiKey = currentConfig.apiKey;
|
|
44
44
|
}
|
|
45
45
|
await llmConfigStore.updateProvider(provider, config);
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
// v0.2.15: 当用户保存一个 LLM 配置为 enabled + 有 key 时,自动把它切为
|
|
47
|
+
// activeProvider 并 rebind runtime singleton。修原来的两个真问题:
|
|
48
|
+
// 1) frontend Save 从不调 /api/llm-provider,于是 activeProvider 一直
|
|
49
|
+
// 卡在 process 启动时的第一个值,新配置的 provider 永远不接管 chat
|
|
50
|
+
// 2) 即使用户手动 active,updateProvider 不替换 modelInstance(只有
|
|
51
|
+
// 当前 active 命中才 rebind),所以保存非 active 那个 provider 之后
|
|
52
|
+
// runtime 还是指向旧 provider + 旧 key
|
|
53
|
+
// 现在:用户每保存一个 enabled 的 LLM 配置,bolloon 立即把这个 provider
|
|
54
|
+
// 设成 active + 重新 init MinLLM/Pi SDK,让"配置 + 立刻能跑"成立。
|
|
55
|
+
// 用户想保持旧 active,可以显式调 /api/llm-provider 改回去。
|
|
56
|
+
const newConfig = await llmConfigStore.getProvider(provider);
|
|
57
|
+
const shouldAutoActivate = newConfig?.enabled === true &&
|
|
58
|
+
// 如果 provider 不需要 key (如 ollama) 或者已经给了真 key,才激活
|
|
59
|
+
(newConfig.apiKey || !newConfig.requiresApiKey);
|
|
60
|
+
if (shouldAutoActivate) {
|
|
61
|
+
await llmConfigStore.setActiveProvider(provider);
|
|
62
|
+
initMinimax({
|
|
63
|
+
provider: provider,
|
|
64
|
+
apiKey: newConfig.apiKey || undefined,
|
|
65
|
+
baseUrl: newConfig.baseUrl || undefined,
|
|
66
|
+
model: newConfig.model || undefined
|
|
67
|
+
});
|
|
58
68
|
}
|
|
59
|
-
res.json({ ok: true });
|
|
69
|
+
res.json({ ok: true, autoActivated: shouldAutoActivate });
|
|
60
70
|
}
|
|
61
71
|
catch (err) {
|
|
62
72
|
res.status(500).json({ error: err.message });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
|
|
6
6
|
"main": "dist/cli-entry.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"src/constraint-runtime"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@bolloon/bolloon-agent": "^0.2.
|
|
51
|
+
"@bolloon/bolloon-agent": "^0.2.15",
|
|
52
52
|
"@bolloon/constraint-runtime": "0.1.0",
|
|
53
53
|
"@capacitor/core": "^8.4.1",
|
|
54
54
|
"@capacitor/ios": "^8.4.1",
|