@bolloon/bolloon-agent 0.4.26 → 0.4.27

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.
@@ -2949,6 +2949,88 @@ ${goalDesc}
2949
2949
  }
2950
2950
  });
2951
2951
  // 2026-09-16: 运行记录 (持久化 harness) — 当前 + 历史 agent 运行。跨重载可读。
2952
+ // 2026-09-18: 智能体工具执行轨迹 + 本机 P2P 信息 (与小工具/名片交换用, 结构化)
2953
+ // 2026-09-18 (Phase 4): 交易审计 — 里程碑 / 争议 / 责任 / 事件链 一眼可查
2954
+ app.get('/api/x402/transactions', async (_req, res) => {
2955
+ try {
2956
+ const { listTransactions } = await import('../agents/x402/transaction-store.js');
2957
+ const { aggregateMilestones } = await import('../agents/x402/milestone-settlement.js');
2958
+ const txs = await listTransactions();
2959
+ res.json({
2960
+ count: txs.length,
2961
+ transactions: txs.map((t) => ({
2962
+ transactionId: t.transactionId, status: t.status, settlementFact: t.settlementFact,
2963
+ itemId: t.itemId, amount: t.amount, currency: t.currency, network: t.network,
2964
+ paymentMode: t.paymentMode, chainSettled: t.chainSettled === true, txHash: t.txHash,
2965
+ milestones: t.milestones?.length ? aggregateMilestones(t.milestones) : null,
2966
+ disputed: !!t.dispute, disputeResolved: t.dispute?.resolution?.decision || null,
2967
+ responsibility: t.responsibility?.type || null,
2968
+ partial: t.settlementFact === 'partially_settled',
2969
+ })),
2970
+ });
2971
+ }
2972
+ catch (err) {
2973
+ res.status(500).json({ error: String(err?.message || err).slice(0, 200) });
2974
+ }
2975
+ });
2976
+ app.get('/api/x402/transactions/:id', async (req, res) => {
2977
+ try {
2978
+ const { readTransaction, replayTransaction } = await import('../agents/x402/transaction-store.js');
2979
+ const { aggregateMilestones, milestoneGoalEligibility } = await import('../agents/x402/milestone-settlement.js');
2980
+ const rec = await readTransaction(req.params.id);
2981
+ if (!rec)
2982
+ return res.status(404).json({ error: '交易不存在' });
2983
+ res.json({
2984
+ transaction: rec,
2985
+ milestones: rec.milestones?.length ? { list: rec.milestones, aggregate: aggregateMilestones(rec.milestones) } : null,
2986
+ dispute: rec.dispute || null,
2987
+ responsibility: rec.responsibility || null,
2988
+ goalEligibility: milestoneGoalEligibility(rec, { executionOk: rec.execution?.ok === true, goalCriteriaHit: rec.goalCriteriaMet === true }),
2989
+ replay: await replayTransaction(req.params.id),
2990
+ });
2991
+ }
2992
+ catch (err) {
2993
+ res.status(500).json({ error: String(err?.message || err).slice(0, 200) });
2994
+ }
2995
+ });
2996
+ app.get('/api/trace', async (req, res) => {
2997
+ try {
2998
+ const { listRuns } = await import('../agents/run-store.js');
2999
+ const { runToTraceJson } = await import('../agents/trace-export.js');
3000
+ const runs = await listRuns({ limit: Number(req.query.limit) || 20 });
3001
+ res.json({ runs: runs.map((r) => runToTraceJson(r)) });
3002
+ }
3003
+ catch (err) {
3004
+ res.status(500).json({ error: String(err?.message || err).slice(0, 200) });
3005
+ }
3006
+ });
3007
+ app.get('/api/trace/:runId', async (req, res) => {
3008
+ try {
3009
+ const { readRun } = await import('../agents/run-store.js');
3010
+ const { runToTraceText, runToTraceJson } = await import('../agents/trace-export.js');
3011
+ const run = await readRun(req.params.runId);
3012
+ if (!run)
3013
+ return res.status(404).json({ error: 'run 不存在' });
3014
+ if (String(req.query.format || 'json') === 'text') {
3015
+ res.type('text/plain; charset=utf-8').send(runToTraceText(run));
3016
+ return;
3017
+ }
3018
+ res.json(runToTraceJson(run));
3019
+ }
3020
+ catch (err) {
3021
+ res.status(500).json({ error: String(err?.message || err).slice(0, 200) });
3022
+ }
3023
+ });
3024
+ app.get('/api/p2p/info', async (_req, res) => {
3025
+ try {
3026
+ const { getLocalP2pInfo, formatP2pInfoJson } = await import('../agents/p2p-info.js');
3027
+ const info = await getLocalP2pInfo();
3028
+ res.type('application/json').send(formatP2pInfoJson(info));
3029
+ }
3030
+ catch (err) {
3031
+ res.status(500).json({ error: String(err?.message || err).slice(0, 200) });
3032
+ }
3033
+ });
2952
3034
  // 2026-09-16 (2-F/2-H): 判据 (criteria) + 长期执行面板 API —— CLI/Web 读同一份 Goal 事实
2953
3035
  app.get('/api/goals/:id/criteria', async (req, res) => {
2954
3036
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolloon/bolloon-agent",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "type": "module",
5
5
  "description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
6
6
  "main": "dist/cli-entry.js",