@bolloon/bolloon-agent 0.4.11 → 0.4.13
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/LICENSE +21 -0
- package/README.md +14 -8
- package/dist/agents/agent-registry.js +151 -0
- package/dist/agents/agent-reputation.js +54 -0
- package/dist/agents/agent-service-client.js +147 -0
- package/dist/agents/economic-policy.js +132 -0
- package/dist/agents/payment-approval.js +142 -0
- package/dist/agents/payment-gate.js +99 -0
- package/dist/agents/pi-sdk-tools.js +243 -0
- package/dist/agents/treasury-bridge.js +127 -0
- package/dist/index.js +42 -0
- package/dist/web/mobile.html +2 -0
- package/dist/web/mobile.js +38 -1
- package/dist/web/server.js +97 -0
- package/package.json +2 -1
package/dist/web/server.js
CHANGED
|
@@ -2785,6 +2785,92 @@ ${goalDesc}
|
|
|
2785
2785
|
res.status(400).json({ ok: false, severity: 'block', reason: e?.message ?? 'parse error' });
|
|
2786
2786
|
}
|
|
2787
2787
|
});
|
|
2788
|
+
// 2026-08-13 (Phase E1): Agent 服务 Registry — 发现层 (OrbitDB 去中心化 + 本地 fallback)
|
|
2789
|
+
app.get('/api/registry', async (_req, res) => {
|
|
2790
|
+
try {
|
|
2791
|
+
const { getAgentRegistry } = await import('../agents/agent-registry.js');
|
|
2792
|
+
const q = String(_req.query?.q || '').trim();
|
|
2793
|
+
const registry = getAgentRegistry();
|
|
2794
|
+
const services = q ? await registry.discover(q) : await registry.list();
|
|
2795
|
+
res.json({ services, count: services.length, ready: registry.ready });
|
|
2796
|
+
}
|
|
2797
|
+
catch (e) {
|
|
2798
|
+
res.status(500).json({ error: e?.message });
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2801
|
+
app.post('/api/registry/register', async (req, res) => {
|
|
2802
|
+
try {
|
|
2803
|
+
const { getAgentRegistry } = await import('../agents/agent-registry.js');
|
|
2804
|
+
const registry = getAgentRegistry();
|
|
2805
|
+
const r = await registry.register(req.body || {});
|
|
2806
|
+
if (!r.ok)
|
|
2807
|
+
return res.status(400).json({ error: r.error });
|
|
2808
|
+
res.json({ ok: true, registered: req.body?.agentId, ready: registry.ready });
|
|
2809
|
+
}
|
|
2810
|
+
catch (e) {
|
|
2811
|
+
res.status(500).json({ error: e?.message });
|
|
2812
|
+
}
|
|
2813
|
+
});
|
|
2814
|
+
// 2026-08-13: 人工支付审批 API — YAML 验证门 confirm 的支付请求
|
|
2815
|
+
app.get('/api/payments/pending', async (_req, res) => {
|
|
2816
|
+
try {
|
|
2817
|
+
const { getApprovalStore } = await import('../agents/payment-approval.js');
|
|
2818
|
+
const approvals = await getApprovalStore().pending();
|
|
2819
|
+
res.json({ approvals });
|
|
2820
|
+
}
|
|
2821
|
+
catch (e) {
|
|
2822
|
+
res.status(500).json({ error: e?.message });
|
|
2823
|
+
}
|
|
2824
|
+
});
|
|
2825
|
+
app.get('/api/payments', async (_req, res) => {
|
|
2826
|
+
try {
|
|
2827
|
+
const { getApprovalStore } = await import('../agents/payment-approval.js');
|
|
2828
|
+
const approvals = await getApprovalStore().list();
|
|
2829
|
+
res.json({ approvals });
|
|
2830
|
+
}
|
|
2831
|
+
catch (e) {
|
|
2832
|
+
res.status(500).json({ error: e?.message });
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2835
|
+
app.post('/api/payments/:id/approve', async (req, res) => {
|
|
2836
|
+
try {
|
|
2837
|
+
const { getApprovalStore, setApprovalExecutor } = await import('../agents/payment-approval.js');
|
|
2838
|
+
const store = getApprovalStore();
|
|
2839
|
+
// 批准后执行: 重试 serviceCall (带 retryPayload)
|
|
2840
|
+
setApprovalExecutor(async (approval) => {
|
|
2841
|
+
const payload = approval.retryPayload;
|
|
2842
|
+
if (!payload)
|
|
2843
|
+
return { ok: false, error: '无重试载荷' };
|
|
2844
|
+
const { serviceCall } = await import('../agents/agent-service-client.js');
|
|
2845
|
+
const r = await serviceCall({
|
|
2846
|
+
serviceName: payload.serviceName,
|
|
2847
|
+
args: payload.args,
|
|
2848
|
+
privateKey: payload.privateKey,
|
|
2849
|
+
maxPaymentAmount: payload.maxPaymentAmount,
|
|
2850
|
+
});
|
|
2851
|
+
return { ok: r.success, result: r.output, error: r.error };
|
|
2852
|
+
});
|
|
2853
|
+
const r = await store.approve(String(req.params.id));
|
|
2854
|
+
if (!r.ok)
|
|
2855
|
+
return res.status(400).json({ error: r.error });
|
|
2856
|
+
res.json({ ok: true, approval: r.approval });
|
|
2857
|
+
}
|
|
2858
|
+
catch (e) {
|
|
2859
|
+
res.status(500).json({ error: e?.message });
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
app.post('/api/payments/:id/reject', async (req, res) => {
|
|
2863
|
+
try {
|
|
2864
|
+
const { getApprovalStore } = await import('../agents/payment-approval.js');
|
|
2865
|
+
const r = await getApprovalStore().reject(String(req.params.id));
|
|
2866
|
+
if (!r.ok)
|
|
2867
|
+
return res.status(400).json({ error: r.error });
|
|
2868
|
+
res.json({ ok: true, approval: r.approval });
|
|
2869
|
+
}
|
|
2870
|
+
catch (e) {
|
|
2871
|
+
res.status(500).json({ error: e?.message });
|
|
2872
|
+
}
|
|
2873
|
+
});
|
|
2788
2874
|
// 2026-08-12: MCP 工具列表 (MCP 前端支持 — 手机端/桌面 UI 展示可用 MCP 工具)
|
|
2789
2875
|
app.get('/api/mcp/tools', async (_req, res) => {
|
|
2790
2876
|
try {
|
|
@@ -2818,6 +2904,17 @@ ${goalDesc}
|
|
|
2818
2904
|
console.warn('[a2ui] 广播注入失败 (非致命):', e?.message?.slice(0, 120));
|
|
2819
2905
|
}
|
|
2820
2906
|
})();
|
|
2907
|
+
// 2026-08-13 (Phase E1): 预热 Agent 服务 Registry (OrbitDB 去中心化)
|
|
2908
|
+
(async () => {
|
|
2909
|
+
try {
|
|
2910
|
+
const { warmAgentRegistry } = await import('../agents/agent-registry.js');
|
|
2911
|
+
const ok = await warmAgentRegistry();
|
|
2912
|
+
console.log(`[agent-registry] OrbitDB 服务注册表 ${ok ? '已启用' : '未启用 (回退本地)'}`);
|
|
2913
|
+
}
|
|
2914
|
+
catch (e) {
|
|
2915
|
+
console.warn('[agent-registry] 预热失败 (非致命):', e?.message?.slice(0, 120));
|
|
2916
|
+
}
|
|
2917
|
+
})();
|
|
2821
2918
|
app.get('/api/health', (_req, res) => {
|
|
2822
2919
|
res.json(healthCheck(getPackageVersion()));
|
|
2823
2920
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
|
|
6
6
|
"main": "dist/cli-entry.js",
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"helia": "^7.1.3",
|
|
102
102
|
"ink": "^7.1.1",
|
|
103
103
|
"ink-text-input": "^6.0.0",
|
|
104
|
+
"js-yaml": "^5.2.3",
|
|
104
105
|
"libp2p": "^3.3.8",
|
|
105
106
|
"mammoth": "^1.12.1",
|
|
106
107
|
"pdf-parse": "^2.4.5",
|