@lawrenceliang-btc/atel-sdk 1.1.30 → 1.1.31

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 +65 -3
  2. package/package.json +1 -1
package/bin/atel.mjs CHANGED
@@ -3438,7 +3438,20 @@ Format:
3438
3438
  const orderId = order?.orderId;
3439
3439
  if (!orderId) continue;
3440
3440
  seenOrderIds.add(orderId);
3441
- await reconcileSingleTradeOrder(order);
3441
+ // The list endpoint returns a slim projection that omits
3442
+ // `description` / `taskRequest`. Re-fetch the full order so
3443
+ // reconcileSingleTradeOrder has the authoritative order
3444
+ // description — without it ORDER_CONTEXT.md / agent prompts
3445
+ // would be missing the original task and the LLM would
3446
+ // hallucinate a topic from the milestone title alone.
3447
+ let fullOrder = order;
3448
+ try {
3449
+ const fetched = await fetchOrderState(orderId);
3450
+ if (fetched) fullOrder = fetched;
3451
+ } catch (e) {
3452
+ log({ event: 'trade_reconcile_order_fetch_error', orderId, error: e.message });
3453
+ }
3454
+ await reconcileSingleTradeOrder(fullOrder);
3442
3455
  } catch (e) {
3443
3456
  log({ event: 'trade_reconcile_order_error', orderId: order?.orderId, status, error: e.message });
3444
3457
  }
@@ -3467,7 +3480,7 @@ Format:
3467
3480
  const event = body.eventType || body.event;
3468
3481
  const payload = body.payload || {};
3469
3482
  const eventId = body.eventId;
3470
- const prompt = body.prompt || payload.prompt;
3483
+ let prompt = body.prompt || payload.prompt;
3471
3484
  const recommendedActions = body.recommendedActions || payload.recommendedActions;
3472
3485
 
3473
3486
  if (!event) {
@@ -3520,7 +3533,7 @@ Format:
3520
3533
 
3521
3534
  const dedupeKey = body.dedupeKey || `${event}:${body.orderId || payload.orderId || ''}`;
3522
3535
  const orderIdForCwd = body.orderId || payload.orderId || '';
3523
- const workspace = getOrderWorkspace(orderIdForCwd, {
3536
+ let workspace = getOrderWorkspace(orderIdForCwd, {
3524
3537
  chain: payload.chain || body.chain || '',
3525
3538
  role: payload.executorDid === id.did ? 'executor' : (payload.requesterDid === id.did ? 'requester' : ''),
3526
3539
  status: payload.orderStatus || body.orderStatus || '',
@@ -3534,6 +3547,55 @@ Format:
3534
3547
  const hookCwd = workspace.dir;
3535
3548
  const atelCwd = getAtelWorkspaceRoot();
3536
3549
 
3550
+ // ── Verifier context enrichment for milestone_submitted ──
3551
+ // Platform-side prompt for milestone_submitted historically did not
3552
+ // include the original order description, so the verifier LLM had no
3553
+ // ground truth to compare against. We re-fetch the full order here so
3554
+ // ORDER_CONTEXT.md (the LLM's authoritative source file) and the
3555
+ // prompt both contain the original task. We do NOT impose rule
3556
+ // checklists — judgment belongs to the agent.
3557
+ if (event === 'milestone_submitted' && orderIdForCwd) {
3558
+ try {
3559
+ const fullOrder = await fetchOrderState(orderIdForCwd);
3560
+ const fullDesc = (fullOrder?.description
3561
+ || fullOrder?.Description
3562
+ || fullOrder?.taskRequest?.description
3563
+ || fullOrder?.TaskRequest?.description
3564
+ || '');
3565
+ if (fullDesc) {
3566
+ workspace = getOrderWorkspace(orderIdForCwd, {
3567
+ chain: fullOrder?.chain || fullOrder?.Chain || payload.chain || body.chain || '',
3568
+ role: 'requester',
3569
+ status: fullOrder?.status || fullOrder?.Status || 'executing',
3570
+ phase: 'waiting_requester_verification',
3571
+ currentMilestone: payload.milestoneIndex ?? '',
3572
+ milestoneTitle: payload.milestoneDescription || '',
3573
+ orderDescription: fullDesc,
3574
+ milestoneObjective: payload.milestoneDescription || '',
3575
+ resultSummary: payload.resultSummary || '',
3576
+ });
3577
+ // Only override the prompt if the platform-supplied one is missing
3578
+ // the original task — newer platform builds embed it directly.
3579
+ if (typeof prompt === 'string' && !prompt.includes(fullDesc)) {
3580
+ const mIdx = payload.milestoneIndex ?? 0;
3581
+ const mDesc = payload.milestoneDescription || '';
3582
+ const subSummary = payload.resultSummary || '';
3583
+ const submitCount = payload.submitCount || 1;
3584
+ prompt = `你是 ATEL 发单方 Agent,正在评审执行方对里程碑 M${mIdx} 的提交。\n\n`
3585
+ + `## 原任务\n${fullDesc}\n\n`
3586
+ + `## 当前里程碑\nM${mIdx}: ${mDesc}\n\n`
3587
+ + `## 执行方提交(第 ${submitCount}/3 次)\n${subSummary}\n\n`
3588
+ + `请基于你自己的判断,评估这次提交是否真实地完成了原任务在当前里程碑应有的部分。如果符合原任务的要求和意图,PASS;如果偏离原任务、违反原任务的约束、或没有真正交付要求的内容,REJECT。\n\n`
3589
+ + `通过:\ncd ~/atel-workspace && atel milestone-verify ${orderIdForCwd} ${mIdx} --pass\n\n`
3590
+ + `不通过(必须给出具体理由):\ncd ~/atel-workspace && atel milestone-verify ${orderIdForCwd} ${mIdx} --reject '具体原因'\n`;
3591
+ log({ event: 'verifier_prompt_overridden', orderId: orderIdForCwd, milestoneIndex: mIdx });
3592
+ }
3593
+ }
3594
+ } catch (e) {
3595
+ log({ event: 'verifier_prompt_override_error', orderId: orderIdForCwd, error: e.message });
3596
+ }
3597
+ }
3598
+
3537
3599
  // 3. Policy mode: auto-execute deterministic operations (not thinking/work)
3538
3600
  const currentPolicy = loadPolicy();
3539
3601
  if (currentPolicy.agentMode === 'policy') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "1.1.30",
3
+ "version": "1.1.31",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",