@lawrenceliang-btc/atel-sdk 1.1.31 → 1.1.33
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/atel.mjs +56 -20
- package/package.json +1 -1
package/bin/atel.mjs
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
* atel boost-status [did] Check boost status
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, appendFileSync, copyFileSync } from 'node:fs';
|
|
54
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, appendFileSync, copyFileSync, statSync, readdirSync, unlinkSync } from 'node:fs';
|
|
55
55
|
import { fileURLToPath } from 'node:url';
|
|
56
56
|
import { cmdHub, cmdSwap, cmdTransfer } from './hub-helpers.mjs';
|
|
57
57
|
import { resolve, join, dirname } from 'node:path';
|
|
@@ -312,26 +312,26 @@ async function pushTradeNotification(eventType, payload, body) {
|
|
|
312
312
|
if (enabled.length === 0) return;
|
|
313
313
|
|
|
314
314
|
const templates = {
|
|
315
|
-
'order_created': (p) => `📥
|
|
316
|
-
'order_accepted': (p) => `📋
|
|
315
|
+
'order_created': (p) => `📥 收到新订单\n订单: ${p.orderId || body?.orderId || '?'}\n金额: $${p.priceAmount ?? '?'} USDC\n来自: ${p.requesterDid || '未知请求方'}\n请审核后决定是否接单`,
|
|
316
|
+
'order_accepted': (p) => `📋 订单已被接单\n订单: ${p.orderId || body?.orderId || '?'}\n执行方已开始处理,进入里程碑阶段`,
|
|
317
317
|
'milestone_submitted': (p) => {
|
|
318
|
-
const desc = p.milestoneDescription ? `\
|
|
319
|
-
const content = p.resultSummary ? `\
|
|
320
|
-
return `📝
|
|
318
|
+
const desc = p.milestoneDescription ? `\n目标: ${p.milestoneDescription}` : '';
|
|
319
|
+
const content = p.resultSummary ? `\n提交内容: ${String(p.resultSummary).substring(0, 200)}` : '';
|
|
320
|
+
return `📝 里程碑 M${p.milestoneIndex ?? '?'} 已提交\n订单: ${p.orderId || body?.orderId || '?'}${desc}${content}\n等待审核`;
|
|
321
321
|
},
|
|
322
322
|
'milestone_verified': (p) => {
|
|
323
|
-
const desc = p.milestoneDescription ? `\
|
|
324
|
-
const content = p.resultSummary ? `\
|
|
325
|
-
const progress = p.totalMilestones ? `\
|
|
326
|
-
return `✅
|
|
323
|
+
const desc = p.milestoneDescription ? `\n目标: ${p.milestoneDescription}` : '';
|
|
324
|
+
const content = p.resultSummary ? `\n提交内容: ${String(p.resultSummary).substring(0, 200)}` : '';
|
|
325
|
+
const progress = p.totalMilestones ? `\n进度: ${(p.milestoneIndex ?? 0) + 1}/${p.totalMilestones}` : '';
|
|
326
|
+
return `✅ 里程碑 M${p.milestoneIndex ?? '?'} 审核通过\n订单: ${p.orderId || body?.orderId || '?'}${desc}${content}${progress}`;
|
|
327
327
|
},
|
|
328
328
|
'milestone_rejected': (p) => {
|
|
329
|
-
const desc = p.milestoneDescription ? `\
|
|
330
|
-
return `❌
|
|
329
|
+
const desc = p.milestoneDescription ? `\n目标: ${p.milestoneDescription}` : '';
|
|
330
|
+
return `❌ 里程碑 M${p.milestoneIndex ?? '?'} 被拒绝\n订单: ${p.orderId || body?.orderId || '?'}${desc}\n原因: ${p.rejectReason || '未说明'}`;
|
|
331
331
|
},
|
|
332
332
|
'order_settled': (p) => {
|
|
333
|
-
const amount = p.priceAmount ? `\
|
|
334
|
-
return `💰
|
|
333
|
+
const amount = p.priceAmount ? `\n金额: $${p.priceAmount} USDC` : '';
|
|
334
|
+
return `💰 订单已结算完成\n订单: ${p.orderId || body?.orderId || '?'}${amount}\nUSDC 已支付`;
|
|
335
335
|
},
|
|
336
336
|
};
|
|
337
337
|
const tmpl = templates[eventType];
|
|
@@ -386,12 +386,12 @@ async function pushP2PNotification(eventType, payload = {}) {
|
|
|
386
386
|
if (enabled.length === 0) return;
|
|
387
387
|
|
|
388
388
|
const templates = {
|
|
389
|
-
'p2p_task_sent': (p) => `📤 P2P
|
|
390
|
-
'p2p_task_received': (p) => `📩
|
|
391
|
-
'p2p_task_started': (p) => `▶️ P2P
|
|
392
|
-
'p2p_result_submitted': (p) => `📨 P2P
|
|
393
|
-
'p2p_result_received': (p) => `✅ P2P
|
|
394
|
-
'p2p_task_failed': (p) => `❌ P2P
|
|
389
|
+
'p2p_task_sent': (p) => `📤 P2P任务已发送\n任务: ${p.taskId || '?'}\n目标: ${p.peerDid || '?'}`,
|
|
390
|
+
'p2p_task_received': (p) => `📩 收到新的P2P任务\n任务: ${p.taskId || '?'}\n来自: ${p.peerDid || '?'}`,
|
|
391
|
+
'p2p_task_started': (p) => `▶️ P2P任务开始处理\n任务: ${p.taskId || '?'}\n来自: ${p.peerDid || '?'}`,
|
|
392
|
+
'p2p_result_submitted': (p) => `📨 P2P结果已发回对方\n任务: ${p.taskId || '?'}\n目标: ${p.peerDid || '?'}`,
|
|
393
|
+
'p2p_result_received': (p) => `✅ P2P任务已完成\n任务: ${p.taskId || '?'}\n结果: ${String(p.result || '').slice(0, 80) || '已返回'}`,
|
|
394
|
+
'p2p_task_failed': (p) => `❌ P2P任务失败\n任务: ${p.taskId || '?'}\n原因: ${p.reason || '未知错误'}`,
|
|
395
395
|
};
|
|
396
396
|
const tmpl = templates[eventType];
|
|
397
397
|
if (!tmpl) return;
|
|
@@ -2403,6 +2403,42 @@ async function startToolGatewayProxy(port, identity, policy) {
|
|
|
2403
2403
|
|
|
2404
2404
|
async function cmdStart(port) {
|
|
2405
2405
|
const id = requireIdentity();
|
|
2406
|
+
|
|
2407
|
+
// Cleanup stale openclaw session locks left behind by previous crashes /
|
|
2408
|
+
// network outages. Without this an agent that lost network mid-session leaves
|
|
2409
|
+
// .lock files in /root/.openclaw/agents/main/sessions/, and the next openclaw
|
|
2410
|
+
// run reports "session file locked (timeout 10000ms)" and refuses to handle
|
|
2411
|
+
// any new milestones until a human cleans up. Treat any lock older than 60s
|
|
2412
|
+
// whose owning pid is no longer alive as stale.
|
|
2413
|
+
try {
|
|
2414
|
+
const home = process.env.HOME || '/root';
|
|
2415
|
+
const sessionDir = join(home, '.openclaw', 'agents', 'main', 'sessions');
|
|
2416
|
+
if (existsSync(sessionDir)) {
|
|
2417
|
+
const entries = readdirSync(sessionDir).filter(f => f.endsWith('.lock'));
|
|
2418
|
+
let removed = 0;
|
|
2419
|
+
const now = Date.now();
|
|
2420
|
+
for (const f of entries) {
|
|
2421
|
+
const full = join(sessionDir, f);
|
|
2422
|
+
try {
|
|
2423
|
+
const st = statSync(full);
|
|
2424
|
+
// Stale if older than 60s — openclaw refreshes locks frequently
|
|
2425
|
+
// when actively working, so anything older almost certainly belongs
|
|
2426
|
+
// to a dead session.
|
|
2427
|
+
if (now - st.mtimeMs > 60_000) {
|
|
2428
|
+
unlinkSync(full);
|
|
2429
|
+
removed++;
|
|
2430
|
+
}
|
|
2431
|
+
} catch {}
|
|
2432
|
+
}
|
|
2433
|
+
if (removed > 0) {
|
|
2434
|
+
log({ event: 'openclaw_stale_locks_removed', count: removed, dir: sessionDir });
|
|
2435
|
+
console.log(`🧹 Cleaned up ${removed} stale openclaw session lock(s) from ${sessionDir}`);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
} catch (e) {
|
|
2439
|
+
log({ event: 'openclaw_lock_cleanup_error', error: e.message });
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2406
2442
|
// Initialize Ollama only if explicitly enabled (optional local AI audit)
|
|
2407
2443
|
if (process.env.ATEL_OLLAMA_ENABLED === 'true') {
|
|
2408
2444
|
await initializeOllama().catch(err => {
|