@lawrenceliang-btc/atel-sdk 1.1.16 → 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.
Files changed (2) hide show
  1. package/bin/atel.mjs +20 -0
  2. package/package.json +1 -1
package/bin/atel.mjs CHANGED
@@ -3679,6 +3679,26 @@ ${callbackFailed}
3679
3679
  return;
3680
3680
  }
3681
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
+ }
3682
3702
  executeRecommendedActionDirect(hookEvent, localAction.action, hookCwd || process.cwd(), hookKey)
3683
3703
  .then((execResult) => {
3684
3704
  if (execResult.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",