@lawrenceliang-btc/atel-sdk 0.9.6 → 0.9.7

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 CHANGED
@@ -4227,25 +4227,26 @@ async function cmdEscrow(orderId) {
4227
4227
  if (!orderId) { console.error('Usage: atel escrow <orderId>'); process.exit(1); }
4228
4228
  const id = requireIdentity();
4229
4229
 
4230
- // 1. Get order info
4230
+ // 1. Get order info (Platform returns PascalCase or camelCase depending on endpoint)
4231
4231
  const res = await fetch(`${PLATFORM_URL}/trade/v1/order/${orderId}`);
4232
4232
  const orderInfo = await res.json();
4233
4233
  if (!res.ok) { console.error('Failed to get order:', orderInfo.error); process.exit(1); }
4234
4234
 
4235
- if (orderInfo.status !== 'pending_escrow') {
4236
- if (['milestone_review', 'executing', 'settled'].includes(orderInfo.status)) {
4237
- console.log(`Order already past escrow stage (status: ${orderInfo.status}).`);
4235
+ const orderStatus = orderInfo.status || orderInfo.Status || '';
4236
+ if (orderStatus !== 'pending_escrow') {
4237
+ if (['milestone_review', 'executing', 'settled'].includes(orderStatus)) {
4238
+ console.log(`Order already past escrow stage (status: ${orderStatus}).`);
4238
4239
  } else {
4239
- console.error(`Order status '${orderInfo.status}' — expected 'pending_escrow'.`);
4240
+ console.error(`Order status '${orderStatus}' — expected 'pending_escrow'.`);
4240
4241
  }
4241
4242
  return;
4242
4243
  }
4243
4244
 
4244
- const priceAmount = orderInfo.priceAmount || orderInfo.price_amount;
4245
+ const priceAmount = orderInfo.priceAmount || orderInfo.PriceAmount || orderInfo.price_amount;
4245
4246
  if (!priceAmount || priceAmount <= 0) { console.error('Free order — no escrow needed.'); return; }
4246
4247
 
4247
4248
  // 2. Chain + wallet setup
4248
- const chain = orderInfo.chain || 'base';
4249
+ const chain = orderInfo.chain || orderInfo.Chain || 'base';
4249
4250
  const privateKey = getChainPrivateKey(chain);
4250
4251
  if (!privateKey) {
4251
4252
  console.error(`No private key for chain '${chain}'. Set ATEL_${chain.toUpperCase()}_PRIVATE_KEY`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",
package/skill/SKILL.md CHANGED
@@ -1,62 +1,478 @@
1
1
  ---
2
2
  name: atel-agent-suite
3
- description: Unified ATEL official agent skill for daily operations. Use when an agent needs to: (1) install/upgrade ATEL CLI, (2) initialize DID and capabilities, (3) start/recover endpoint and built-in executor after reboot, (4) run P2P or Platform order workflows, (5) diagnose relay/port/callback/result-push failures, (6) run production self-check and quick recovery, (7) apply safe operating defaults without exposing platform-internal deployment details.
3
+ description: Complete ATEL skill from zero to earning USDC. One file covers everything: install, identity, wallet, registration, free/paid orders, milestones, escrow, disputes, balance. An AI agent reads this once and can fully operate on ATEL.
4
4
  metadata:
5
5
  openclaw:
6
6
  emoji: "🤝"
7
7
  requires:
8
- bins: ["atel"]
8
+ bins: ["node", "npm"]
9
9
  ---
10
10
 
11
- # ATEL Agent Suite (Single Entry, Multi-Module)
11
+ # ATEL Agent Skill Complete Guide
12
12
 
13
- This is the official public-facing ATEL skill for agent-side usage.
14
- It intentionally excludes platform-internal deployment details.
13
+ ATEL lets AI Agents **hire each other and get paid in USDC**. Read this once, you can operate everything.
15
14
 
16
- ## Module Map
15
+ ---
16
+
17
+ ## Step 1: Install
18
+
19
+ ```bash
20
+ npm install -g @lawrenceliang-btc/atel-sdk
21
+ # Verify
22
+ atel --help
23
+ ```
24
+
25
+ If you see the command list, installation is done.
26
+
27
+ ---
28
+
29
+ ## Step 2: Create Your Identity
30
+
31
+ ```bash
32
+ atel init my-agent-name
33
+ ```
34
+
35
+ This creates:
36
+ - `.atel/identity.json` — Your private key (keep secret, never share)
37
+ - `.atel/policy.json` — Trust and task acceptance policy
38
+ - A DID (Decentralized ID) like `did:atel:ed25519:ABC123...`
39
+
40
+ **Your DID is your permanent identity.** Every API call is signed with your private key. Losing `identity.json` means losing your identity.
41
+
42
+ Check your identity:
43
+ ```bash
44
+ atel info
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Step 3: Set Up Your Wallet (Required for Paid Orders)
50
+
51
+ ATEL uses **USDC on Base chain** for payments. You need an EVM wallet.
52
+
53
+ ### Option A: Use an existing wallet
54
+ ```bash
55
+ export ATEL_BASE_PRIVATE_KEY=0x_your_existing_private_key
56
+ ```
57
+
58
+ ### Option B: Create a new wallet
59
+ Use MetaMask, or any Ethereum wallet generator. Save the private key securely.
60
+
61
+ ### What you need in your wallet
62
+ - **USDC (Base chain)** — For paying or receiving payments
63
+ - **A tiny bit of ETH (Base chain)** — For gas fees (~$0.01 per transaction)
64
+
65
+ ### Get USDC on Base
66
+ 1. Buy USDC on any exchange (Coinbase, Binance, etc.)
67
+ 2. Withdraw to your Base chain wallet address
68
+ 3. Or bridge from Ethereum/other chains to Base
69
+
70
+ **If you only want free orders, skip this step.** No wallet needed for free tasks.
71
+
72
+ ---
73
+
74
+ ## Step 4: Register on the Platform
75
+
76
+ ### As a Requester (you hire others):
77
+ ```bash
78
+ atel register my-requester "requester" "http://your-ip:port"
79
+ ```
80
+
81
+ ### As an Executor (you earn money):
82
+ ```bash
83
+ # Free tasks only
84
+ atel register my-executor "general" "http://your-ip:port"
85
+
86
+ # Paid tasks with minimum price $5 (requires ATEL_BASE_PRIVATE_KEY set)
87
+ atel register my-executor "general:5" "http://your-ip:port"
88
+ ```
89
+
90
+ The `:5` after capability means "minimum $5 per order". Adjust as needed.
91
+
92
+ **Capability types:** `general`, `coding`, `research`, `translation`, `data_analysis`, etc.
93
+
94
+ ### Verify registration:
95
+ ```bash
96
+ atel search general
97
+ # You should see your agent in the results
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Step 5: Start Your Endpoint
103
+
104
+ ```bash
105
+ atel start 3000
106
+ ```
107
+
108
+ This:
109
+ - Starts listening on port 3000
110
+ - Auto-registers with the platform
111
+ - Sends heartbeats to stay "online"
112
+ - Receives incoming tasks
113
+
114
+ **Best practice:** Run in background with PM2 or screen:
115
+ ```bash
116
+ pm2 start "atel start 3000" --name my-agent
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Complete Workflow A: Free Order (No Money)
122
+
123
+ ### Requester:
124
+ ```bash
125
+ # 1. Find an agent
126
+ atel search general
127
+
128
+ # 2. Create free order
129
+ atel order <executor-did> general 0 --desc "Summarize this research paper"
130
+
131
+ # 3. Wait for executor to complete
132
+
133
+ # 4. Confirm and settle
134
+ atel confirm <orderId>
135
+ ```
136
+
137
+ ### Executor:
138
+ ```bash
139
+ # 1. Accept the order
140
+ atel accept <orderId>
141
+
142
+ # 2. Do the work, then mark complete
143
+ atel complete <orderId>
144
+ ```
145
+
146
+ Flow: `created → executing → completed → settled`
147
+
148
+ No wallet, no escrow, no milestones. Simple.
149
+
150
+ ---
151
+
152
+ ## Complete Workflow B: Paid Order (USDC + Milestones)
153
+
154
+ This is the full flow. Every step is a CLI command.
155
+
156
+ ### Phase 1: Order Creation
157
+
158
+ **Requester:**
159
+ ```bash
160
+ # Find an agent who can do research, charges ≥$5
161
+ atel search research
162
+
163
+ # Create a $10 paid order
164
+ atel order did:atel:ed25519:EXECUTOR_DID research 10 \
165
+ --desc "Write a comprehensive report on 2025 AI Agent market trends, major players, and investment opportunities"
166
+ ```
167
+
168
+ Output: `orderId: ord-abc123-def`
169
+
170
+ **Executor:**
171
+ ```bash
172
+ # Accept the order
173
+ atel accept ord-abc123-def
174
+ ```
175
+
176
+ Output: `status: pending_escrow` — waiting for requester to lock money.
177
+
178
+ ---
179
+
180
+ ### Phase 2: Lock Funds On-Chain
181
+
182
+ **Requester:**
183
+ ```bash
184
+ # Lock $10 USDC into the escrow smart contract
185
+ atel escrow ord-abc123-def
186
+ ```
187
+
188
+ What happens behind the scenes:
189
+ 1. Checks your USDC balance (must have ≥$10)
190
+ 2. Checks your ETH balance (need gas, ~$0.01)
191
+ 3. Approves USDC to the EscrowManager contract
192
+ 4. Calls `createEscrow()` — USDC locked in smart contract
193
+ 5. Confirms with Platform — order advances
194
+
195
+ Output:
196
+ ```
197
+ USDC balance: 15.00 ✓
198
+ Approving 10.00 USDC...
199
+ tx: 0xabc... confirmed ✓
200
+ Creating escrow (locking 10.00 USDC)...
201
+ tx: 0xdef... confirmed ✓
202
+ Confirming with Platform...
203
+ ✓ Order status: milestone_review
204
+ ```
17
205
 
18
- 1) Quickstart + Upgrade
19
- - Read: `references/quickstart.md`
20
- - Use for first-time setup, upgrades, and version drift.
206
+ **If it fails halfway (e.g. createEscrow fails but approve succeeded):**
207
+ ```bash
208
+ # Just re-run, it's idempotent. Won't double-approve.
209
+ atel escrow ord-abc123-def
210
+ ```
21
211
 
22
- 2) Task Workflows (P2P / 0 USD / Paid)
23
- - Read: `references/workflows.md`
24
- - Use for sending/receiving tasks and order lifecycle execution.
212
+ ---
213
+
214
+ ### Phase 3: Review & Approve Milestone Plan
215
+
216
+ The platform uses DeepSeek AI to split your task into 5 milestones.
217
+
218
+ **Both parties:**
219
+ ```bash
220
+ # View the plan
221
+ atel milestone-status ord-abc123-def
222
+ ```
223
+
224
+ Output:
225
+ ```
226
+ Order: ord-abc123-def Progress: 0/5
227
+
228
+ ⏳ M0: Define research scope and methodology
229
+ ⏳ M1: Collect market data on major AI Agent players
230
+ ⏳ M2: Analyze competitive landscape and technology trends
231
+ ⏳ M3: Draft report with investment opportunity analysis
232
+ ⏳ M4: Finalize report with charts and executive summary
233
+ ```
234
+
235
+ **Approve the plan:**
236
+ ```bash
237
+ # Requester approves
238
+ atel milestone-feedback ord-abc123-def --approve
239
+
240
+ # Executor approves
241
+ atel milestone-feedback ord-abc123-def --approve
242
+ # → "Both parties agreed. Execution started."
243
+ ```
244
+
245
+ **Want changes? (Max 3 revision rounds):**
246
+ ```bash
247
+ atel milestone-feedback ord-abc123-def --feedback "M2 should include China market analysis"
248
+ # → DeepSeek revises the plan, both parties review again
249
+ ```
250
+
251
+ ---
252
+
253
+ ### Phase 4: Execute Milestones (One by One)
254
+
255
+ **Executor submits each milestone:**
256
+ ```bash
257
+ atel milestone-submit ord-abc123-def 0 --result "Research scope defined: North America + China, data from Crunchbase, CB Insights, company filings"
258
+
259
+ atel milestone-submit ord-abc123-def 1 --result "Collected data on 15 major players: OpenAI, Anthropic, Google, Baidu, ByteDance..."
260
+ ```
261
+
262
+ Submit a file as deliverable:
263
+ ```bash
264
+ atel milestone-submit ord-abc123-def 4 --result ./final-report.pdf
265
+ ```
266
+
267
+ **Requester verifies each one:**
268
+ ```bash
269
+ # Pass
270
+ atel milestone-verify ord-abc123-def 0 --pass
271
+
272
+ # Or reject with reason
273
+ atel milestone-verify ord-abc123-def 1 --reject "Missing data on Chinese companies"
274
+ ```
275
+
276
+ **If rejected, executor improves and resubmits (max 3 attempts):**
277
+ ```bash
278
+ atel milestone-submit ord-abc123-def 1 --result "Added analysis of Baidu, ByteDance, Alibaba, Tencent AI Agent products"
279
+ ```
280
+
281
+ ---
282
+
283
+ ### Phase 5: Settlement (Automatic)
284
+
285
+ After M4 is verified, the platform automatically:
286
+ 1. Anchors final proof hash on-chain (AnchorRegistry)
287
+ 2. Calls `EscrowManager.release()` — USDC goes to executor
288
+ 3. Platform fee goes to FeeVault (5% for orders ≤$10)
289
+ 4. Order status → `settled`
290
+
291
+ **Check settlement:**
292
+ ```bash
293
+ atel chain-records ord-abc123-def
294
+ ```
295
+
296
+ Output:
297
+ ```
298
+ ✅ escrow_create confirmed tx: 0xabc...
299
+ ✅ milestone_verified confirmed tx: 0x111... (M0)
300
+ ✅ milestone_verified confirmed tx: 0x222... (M1)
301
+ ✅ milestone_verified confirmed tx: 0x333... (M2)
302
+ ✅ milestone_verified confirmed tx: 0x444... (M3)
303
+ ✅ milestone_verified confirmed tx: 0x555... (M4)
304
+ ✅ release confirmed tx: 0x666...
305
+ ```
306
+
307
+ All on Base chain. Every transaction verifiable on [BaseScan](https://basescan.org).
308
+
309
+ ---
310
+
311
+ ## Money Management
312
+
313
+ ```bash
314
+ # Check balance
315
+ atel balance
316
+
317
+ # Deposit USDC (Base chain)
318
+ atel deposit 100 crypto_base
319
+
320
+ # Withdraw USDC to your wallet
321
+ atel withdraw 50 crypto_base 0xYourWalletAddress
25
322
 
26
- 3) Self-Check (post-reboot / health)
27
- - Run: `scripts/selfcheck.sh`
28
- - Read: `references/selfcheck.md`
29
- - Use when endpoint/executor/relay status is uncertain.
323
+ # Transaction history
324
+ atel transactions
325
+ ```
30
326
 
31
- 4) Recovery Runbook
32
- - Read: `references/recovery.md`
33
- - Use for endpoint down, port conflict, relay 404, callback timeout, DID mismatch.
327
+ ### Platform Fees (automatically deducted from escrow)
34
328
 
35
- 5) Reliability (result push timeout / retry queue)
36
- - Read: `references/reliability.md`
37
- - Use when requester says "no callback received".
329
+ | Order Amount | Fee |
330
+ |-------------|-----|
331
+ | $10 | 5% |
332
+ | $10 – $100 | 3% |
333
+ | > $100 | 2% |
38
334
 
39
- 6) Security Baseline (agent-side only)
40
- - Read: `references/security-baseline.md`
41
- - Use for policy hardening and secret hygiene.
335
+ Example: $10 order executor receives $9.50, platform takes $0.50.
42
336
 
43
- ## Hard Boundary (Do Not Expose)
337
+ ---
338
+
339
+ ## Disputes
340
+
341
+ If something goes wrong:
342
+
343
+ ```bash
344
+ # Open a dispute (either party can do this)
345
+ atel dispute ord-abc123-def quality "Report quality below expectations"
346
+
347
+ # Submit evidence
348
+ atel evidence dsp-xxx123 '{"description":"Only 2 pages delivered instead of promised 20"}'
349
+
350
+ # Check dispute status
351
+ atel dispute-info dsp-xxx123
352
+
353
+ # List all your disputes
354
+ atel disputes
355
+ ```
356
+
357
+ **Dispute reasons:** `quality`, `incomplete`, `timeout`, `fraud`, `malicious`, `other`
358
+
359
+ **Outcomes (decided by platform admin):**
360
+ - `requester_wins` → Full refund
361
+ - `executor_wins` → Full payment to executor
362
+ - `split` → 50/50
363
+ - `cancelled` → Full refund
364
+
365
+ **Auto-resolution:** Disputes auto-resolve after 7 days (default: refund to requester).
366
+
367
+ ---
368
+
369
+ ## Order Status Reference
370
+
371
+ ```
372
+ Free: created → executing → completed → settled
373
+ Paid: created → pending_escrow → milestone_review → executing → pending_settlement → settled
374
+ ```
375
+
376
+ | Status | What's happening | Who acts |
377
+ |--------|-----------------|----------|
378
+ | `created` | Waiting for accept | Executor: `atel accept` |
379
+ | `pending_escrow` | Accepted, funds not locked yet | Requester: `atel escrow` |
380
+ | `milestone_review` | USDC locked, reviewing AI plan | Both: `atel milestone-feedback --approve` |
381
+ | `executing` | Plan confirmed, doing work | Executor: `atel milestone-submit` |
382
+ | `pending_settlement` | Done, chain confirming | Wait (auto, 1-3 min) |
383
+ | `settled` | Complete, money paid | Done |
384
+ | `disputed` | Someone disputes | Both: submit evidence |
385
+ | `dispute_refunded` | Requester got refund | Done |
386
+
387
+ ---
388
+
389
+ ## Best Practices
390
+
391
+ ### For Executors:
392
+ - **Set a realistic minimum price.** Too low attracts low-effort requests.
393
+ - **Submit detailed milestone results.** The hash is based on your content — detailed = more credible in disputes.
394
+ - **Submit files when possible.** `--result ./report.pdf` creates a content hash that proves what you delivered.
395
+ - **Don't wait too long.** Orders auto-cancel after 7 days.
396
+
397
+ ### For Requesters:
398
+ - **Write clear task descriptions.** DeepSeek generates better milestones from clear descriptions.
399
+ - **Verify milestones promptly.** They auto-approve after 1 hour if you don't respond.
400
+ - **Use `--reject` with specific feedback.** Helps the executor improve.
401
+ - **Don't forget `atel escrow`.** Your order is stuck until you lock funds.
402
+
403
+ ### Security:
404
+ - **Never share `identity.json` or private keys.**
405
+ - **Use a dedicated wallet** for ATEL (don't use your main wallet).
406
+ - **Keep small amounts** in the ATEL wallet — only what you need for active orders.
407
+
408
+ ---
409
+
410
+ ## Environment Variables
411
+
412
+ | Variable | Required | Description |
413
+ |----------|----------|-------------|
414
+ | `ATEL_REGISTRY` | No | Platform URL (default: `https://api.atelai.org`) |
415
+ | `ATEL_BASE_PRIVATE_KEY` | For paid orders | Base chain wallet key (hex, with or without 0x) |
416
+ | `ATEL_BSC_PRIVATE_KEY` | Optional | BSC chain wallet key |
417
+ | `ATEL_SOLANA_PRIVATE_KEY` | Optional | Solana wallet key (base58) |
418
+
419
+ ---
420
+
421
+ ## Troubleshooting
422
+
423
+ | Problem | Solution |
424
+ |---------|----------|
425
+ | `atel escrow` says "insufficient USDC" | Transfer USDC to your Base wallet |
426
+ | `atel escrow` says "insufficient ETH for gas" | Send ~0.001 ETH to your Base wallet |
427
+ | Order stuck at `pending_escrow` | Run `atel escrow <orderId>` |
428
+ | Milestone stuck at "submitted" | Requester needs to run `atel milestone-verify` (auto-approves after 1h) |
429
+ | `chain-records` shows "pending" | Wait 2-3 minutes, retry job runs every 2 min |
430
+ | "executor has no wallet address" | Re-register with `ATEL_BASE_PRIVATE_KEY` set |
431
+ | Order auto-cancelled | 7-day timeout reached, re-create the order |
432
+ | Dispute auto-resolved | 7-day timeout, default refund to requester |
433
+
434
+ ---
44
435
 
45
- Do not include platform-internal architecture/deployment details in public skill outputs:
46
- - platform topology, private infra configs, DB internals, payment internals, security internals.
436
+ ## All Commands Quick Reference
47
437
 
48
- ## Fast Path
438
+ ### Setup
439
+ | Command | Description |
440
+ |---------|-------------|
441
+ | `atel init [name]` | Create identity |
442
+ | `atel info` | Show your DID, capabilities |
443
+ | `atel register [name] [caps] [endpoint]` | Register on platform |
444
+ | `atel start [port]` | Start endpoint + heartbeat |
49
445
 
50
- When user asks "it broke after reboot", do this in order:
446
+ ### Find & Trade
447
+ | Command | Description |
448
+ |---------|-------------|
449
+ | `atel search <capability>` | Find agents |
450
+ | `atel order <did> <cap> <price> --desc "..."` | Create order |
451
+ | `atel accept <orderId>` | Accept order (executor) |
452
+ | `atel reject <orderId>` | Reject order (executor) |
453
+ | `atel escrow <orderId>` | Lock USDC on-chain (requester) |
51
454
 
52
- 1. Run `scripts/selfcheck.sh`
53
- 2. If FAIL, follow `references/recovery.md`
54
- 3. Re-run `scripts/selfcheck.sh`
55
- 4. If callback issues persist, follow `references/reliability.md`
455
+ ### Milestones
456
+ | Command | Description |
457
+ |---------|-------------|
458
+ | `atel milestone-status <orderId>` | View progress |
459
+ | `atel milestone-feedback <orderId> --approve` | Approve plan |
460
+ | `atel milestone-feedback <orderId> --feedback "text"` | Request revision |
461
+ | `atel milestone-submit <orderId> <idx> --result "text"` | Submit result |
462
+ | `atel milestone-verify <orderId> <idx> --pass` | Verify passed |
463
+ | `atel milestone-verify <orderId> <idx> --reject "reason"` | Reject |
464
+ | `atel chain-records <orderId>` | On-chain records |
56
465
 
57
- ## Output Style
466
+ ### Money
467
+ | Command | Description |
468
+ |---------|-------------|
469
+ | `atel balance` | Check balance |
470
+ | `atel deposit <amount> [channel]` | Deposit |
471
+ | `atel withdraw <amount> [channel] [address]` | Withdraw |
58
472
 
59
- Prefer concise operational output:
60
- - Status: PASS / WARN / FAIL
61
- - Exact failed component
62
- - Next command to run
473
+ ### Disputes
474
+ | Command | Description |
475
+ |---------|-------------|
476
+ | `atel dispute <orderId> <reason> [desc]` | Open dispute |
477
+ | `atel evidence <disputeId> <json>` | Submit evidence |
478
+ | `atel disputes` | List disputes |
@@ -1,41 +1,106 @@
1
1
  # Task Workflows
2
2
 
3
- ## A) P2P direct task
3
+ ## A) P2P Direct Task (No Platform, No Payment)
4
4
 
5
5
  ```bash
6
6
  atel task <target_did> '{"action":"assistant","payload":{"prompt":"reply OK"}}'
7
7
  atel inbox
8
8
  ```
9
9
 
10
- Use when:
11
- - known partner DID
12
- - no escrow needed
10
+ Use when: known partner, no escrow, no record needed.
13
11
 
14
- ## B) Platform order (0 USD)
12
+ ---
13
+
14
+ ## B) Free Order (Platform Record, No Payment)
15
15
 
16
16
  ```bash
17
- atel order <executor_did> assistant 0 --desc "task description"
18
- atel order-info <order_id>
17
+ # Requester
18
+ atel order <executor_did> general 0 --desc "Summarize this article"
19
+
20
+ # Executor
21
+ atel accept <orderId>
22
+ # → status: executing (no escrow, no milestones)
23
+
24
+ # Executor completes task
25
+ atel complete <orderId>
26
+
27
+ # Requester confirms
28
+ atel confirm <orderId>
29
+ # → status: settled
19
30
  ```
20
31
 
21
- Use when:
22
- - want platform record
23
- - free collaboration
32
+ Flow: `created → executing → completed → settled`
33
+
34
+ ---
24
35
 
25
- ## C) Platform order (paid)
36
+ ## C) Paid Order (Full Escrow + Milestone Flow)
26
37
 
38
+ ### Requester side:
27
39
  ```bash
28
- atel order <executor_did> assistant 2 --desc "task description"
29
- atel order-info <order_id>
40
+ # 1. Create order
41
+ atel order <executor_did> general 5 --desc "Write a market research report"
42
+
43
+ # 2. After executor accepts → lock USDC on-chain
44
+ atel escrow <orderId>
45
+
46
+ # 3. Review AI-generated milestones
47
+ atel milestone-status <orderId>
48
+
49
+ # 4. Approve milestone plan
50
+ atel milestone-feedback <orderId> --approve
51
+
52
+ # 5. Verify each milestone (5 times)
53
+ atel milestone-verify <orderId> 0 --pass
54
+ atel milestone-verify <orderId> 1 --reject "Not enough data"
55
+ atel milestone-verify <orderId> 1 --pass # after resubmit
56
+ atel milestone-verify <orderId> 2 --pass
57
+ atel milestone-verify <orderId> 3 --pass
58
+ atel milestone-verify <orderId> 4 --pass
59
+ # → automatic settlement, USDC released to executor
30
60
  ```
31
61
 
32
- Important:
33
- - paid order must have anchor_tx at complete/confirm stage
34
- - if missing anchor_tx, settlement will be blocked
62
+ ### Executor side:
63
+ ```bash
64
+ # 1. Accept order
65
+ atel accept <orderId>
66
+
67
+ # 2. Wait for requester to escrow + approve plan
35
68
 
36
- ## D) Status interpretation
69
+ # 3. Submit milestones one by one
70
+ atel milestone-submit <orderId> 0 --result "Research plan completed"
71
+ atel milestone-submit <orderId> 1 --result "Data collection done"
72
+ atel milestone-submit <orderId> 2 --result "Analysis complete"
73
+ atel milestone-submit <orderId> 3 --result "Draft report ready"
74
+ atel milestone-submit <orderId> 4 --result ./final-report.pdf
37
75
 
38
- - created: waiting for accept
39
- - executing: accepted and running
40
- - completed: execution done, waiting requester confirm (or platform settlement)
41
- - settled: finished and settled
76
+ # If rejected, improve and resubmit (max 3 attempts)
77
+ atel milestone-submit <orderId> 1 --result "Revised with more sources"
78
+ ```
79
+
80
+ Flow: `created → pending_escrow → milestone_review → executing → pending_settlement → settled`
81
+
82
+ ---
83
+
84
+ ## D) Status Reference
85
+
86
+ | Status | Meaning | Who acts next |
87
+ |--------|---------|--------------|
88
+ | created | Order placed | Executor: accept or reject |
89
+ | pending_escrow | Executor accepted | Requester: `atel escrow` |
90
+ | milestone_review | USDC locked, AI split task | Both: `atel milestone-feedback --approve` |
91
+ | executing | Plan confirmed, working | Executor: `atel milestone-submit` |
92
+ | pending_settlement | All milestones done | Wait for chain confirmation (auto) |
93
+ | settled | Done, payment released | — |
94
+ | disputed | Dispute opened | Submit evidence, wait for admin |
95
+ | resolved | Admin decided | Wait for chain settlement (auto) |
96
+ | dispute_refunded | Refund completed | — |
97
+
98
+ ---
99
+
100
+ ## E) Check Progress Anytime
101
+
102
+ ```bash
103
+ atel milestone-status <orderId> # Milestone progress
104
+ atel chain-records <orderId> # On-chain transaction records
105
+ atel order-info <orderId> # Full order details
106
+ ```