@lawrenceliang-btc/atel-sdk 1.1.15 → 1.1.17
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 +26 -1
- package/package.json +1 -1
package/bin/atel.mjs
CHANGED
|
@@ -3086,7 +3086,8 @@ ${callbackFailed}
|
|
|
3086
3086
|
function sanitizeHookSessionId(value) {
|
|
3087
3087
|
const raw = String(value || '').trim();
|
|
3088
3088
|
if (!raw) return `atel-hook-${Date.now()}`;
|
|
3089
|
-
|
|
3089
|
+
// Replace colons with dashes — openclaw rejects colons in session IDs
|
|
3090
|
+
const cleaned = raw.replace(/:/g, '-').replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
3090
3091
|
return (cleaned || `atel-hook-${Date.now()}`).slice(0, 120);
|
|
3091
3092
|
}
|
|
3092
3093
|
|
|
@@ -3678,6 +3679,26 @@ ${callbackFailed}
|
|
|
3678
3679
|
return;
|
|
3679
3680
|
}
|
|
3680
3681
|
if (localAction.ok && !localAction.skipped) {
|
|
3682
|
+
// Guard: if agent hook already submitted via its own shell command during execution,
|
|
3683
|
+
// the milestone status will have changed. Re-check before double-submitting.
|
|
3684
|
+
if (['milestone_rejected', 'milestone_verified', 'milestone_plan_confirmed'].includes(hookEvent)) {
|
|
3685
|
+
const guardCmd = localAction.action?.command;
|
|
3686
|
+
if (Array.isArray(guardCmd) && guardCmd[0] === 'atel' && guardCmd[1] === 'milestone-submit' && guardCmd[2]) {
|
|
3687
|
+
try {
|
|
3688
|
+
const guardResp = await fetch(`${PLATFORM_URL}/trade/v1/order/${guardCmd[2]}/milestones`, { signal: AbortSignal.timeout(8000) });
|
|
3689
|
+
if (guardResp.ok) {
|
|
3690
|
+
const guardState = await guardResp.json();
|
|
3691
|
+
const guardIdx = Number.parseInt(String(guardCmd[3]), 10);
|
|
3692
|
+
const guardMs = Array.isArray(guardState?.milestones) ? guardState.milestones.find(m => m.index === guardIdx) : null;
|
|
3693
|
+
if (guardMs && guardMs.status === 'submitted') {
|
|
3694
|
+
log({ event: 'agent_cmd_done', eventType: hookEvent, mode: 'already_submitted_by_agent', dedupeKey: hookKey });
|
|
3695
|
+
finishHook();
|
|
3696
|
+
return;
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
} catch {}
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3681
3702
|
executeRecommendedActionDirect(hookEvent, localAction.action, hookCwd || process.cwd(), hookKey)
|
|
3682
3703
|
.then((execResult) => {
|
|
3683
3704
|
if (execResult.ok) {
|
|
@@ -5768,6 +5789,10 @@ async function cmdTradeTask(capability, description) {
|
|
|
5768
5789
|
|
|
5769
5790
|
async function cmdOrder(executorDid, capType, price) {
|
|
5770
5791
|
if (!executorDid || !capType || !price) { console.error('Usage: atel order <executorDid> <capabilityType> <price> [--desc "task description"]'); process.exit(1); }
|
|
5792
|
+
// Resolve @alias to full DID
|
|
5793
|
+
if (executorDid.startsWith('@')) {
|
|
5794
|
+
try { executorDid = resolveDID(executorDid); } catch (e) { console.error(e.message); process.exit(1); }
|
|
5795
|
+
}
|
|
5771
5796
|
const description = rawArgs.find((a, i) => rawArgs[i-1] === '--desc') || '';
|
|
5772
5797
|
const id = requireIdentity();
|
|
5773
5798
|
|