1688-cli 0.1.0

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 (80) hide show
  1. package/AGENTS.md +118 -0
  2. package/README.md +48 -0
  3. package/dist/auth/cookies.js +31 -0
  4. package/dist/auth/cookies.js.map +1 -0
  5. package/dist/auth/verify.js +25 -0
  6. package/dist/auth/verify.js.map +1 -0
  7. package/dist/cli.js +373 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/commands/cart-add.js +199 -0
  10. package/dist/commands/cart-add.js.map +1 -0
  11. package/dist/commands/cart-list.js +168 -0
  12. package/dist/commands/cart-list.js.map +1 -0
  13. package/dist/commands/cart-remove.js +119 -0
  14. package/dist/commands/cart-remove.js.map +1 -0
  15. package/dist/commands/checkout-confirm.js +407 -0
  16. package/dist/commands/checkout-confirm.js.map +1 -0
  17. package/dist/commands/checkout-prepare.js +244 -0
  18. package/dist/commands/checkout-prepare.js.map +1 -0
  19. package/dist/commands/doctor.js +246 -0
  20. package/dist/commands/doctor.js.map +1 -0
  21. package/dist/commands/image-search.js +210 -0
  22. package/dist/commands/image-search.js.map +1 -0
  23. package/dist/commands/login.js +209 -0
  24. package/dist/commands/login.js.map +1 -0
  25. package/dist/commands/logout.js +59 -0
  26. package/dist/commands/logout.js.map +1 -0
  27. package/dist/commands/offer.js +185 -0
  28. package/dist/commands/offer.js.map +1 -0
  29. package/dist/commands/order-get.js +76 -0
  30. package/dist/commands/order-get.js.map +1 -0
  31. package/dist/commands/order-list.js +176 -0
  32. package/dist/commands/order-list.js.map +1 -0
  33. package/dist/commands/order-logistics.js +152 -0
  34. package/dist/commands/order-logistics.js.map +1 -0
  35. package/dist/commands/search.js +250 -0
  36. package/dist/commands/search.js.map +1 -0
  37. package/dist/commands/seller-chat.js +213 -0
  38. package/dist/commands/seller-chat.js.map +1 -0
  39. package/dist/commands/seller-inquire.js +110 -0
  40. package/dist/commands/seller-inquire.js.map +1 -0
  41. package/dist/commands/seller-lookup-ww.js +6 -0
  42. package/dist/commands/seller-lookup-ww.js.map +1 -0
  43. package/dist/commands/seller-messages.js +181 -0
  44. package/dist/commands/seller-messages.js.map +1 -0
  45. package/dist/commands/whoami.js +53 -0
  46. package/dist/commands/whoami.js.map +1 -0
  47. package/dist/commands/workflows.js +264 -0
  48. package/dist/commands/workflows.js.map +1 -0
  49. package/dist/daemon/client.js +75 -0
  50. package/dist/daemon/client.js.map +1 -0
  51. package/dist/daemon/manager.js +128 -0
  52. package/dist/daemon/manager.js.map +1 -0
  53. package/dist/daemon/protocol.js +5 -0
  54. package/dist/daemon/protocol.js.map +1 -0
  55. package/dist/daemon/server.js +197 -0
  56. package/dist/daemon/server.js.map +1 -0
  57. package/dist/daemon/throttle.js +17 -0
  58. package/dist/daemon/throttle.js.map +1 -0
  59. package/dist/io/errors.js +10 -0
  60. package/dist/io/errors.js.map +1 -0
  61. package/dist/io/output.js +17 -0
  62. package/dist/io/output.js.map +1 -0
  63. package/dist/io/prompt.js +17 -0
  64. package/dist/io/prompt.js.map +1 -0
  65. package/dist/session/context.js +91 -0
  66. package/dist/session/context.js.map +1 -0
  67. package/dist/session/dispatch.js +50 -0
  68. package/dist/session/dispatch.js.map +1 -0
  69. package/dist/session/lock.js +23 -0
  70. package/dist/session/lock.js.map +1 -0
  71. package/dist/session/paths.js +31 -0
  72. package/dist/session/paths.js.map +1 -0
  73. package/dist/session/shared.js +104 -0
  74. package/dist/session/shared.js.map +1 -0
  75. package/dist/session/state.js +27 -0
  76. package/dist/session/state.js.map +1 -0
  77. package/dist/util/time.js +17 -0
  78. package/dist/util/time.js.map +1 -0
  79. package/package.json +44 -0
  80. package/scripts/postinstall.mjs +49 -0
package/AGENTS.md ADDED
@@ -0,0 +1,118 @@
1
+ # 1688 — 1688 CLI for agents
2
+
3
+ When the user asks anything about 1688 sourcing, products, orders, or
4
+ logistics, use the `1688` CLI. It outputs JSON automatically when stdout
5
+ is piped, so `1688 <cmd> | jq` works.
6
+
7
+ ## Current commands (MVP)
8
+
9
+ ```
10
+ 1688 login Show QR code in the terminal; user scans with phone.
11
+ 1688 login --headed Use a real browser window instead (fallback).
12
+ 1688 login --force Re-login even if a session exists.
13
+ 1688 search <keyword> Search 1688 by keyword; --max N to limit.
14
+ 1688 search --headed Open window (use once to pass slider; cached for hours).
15
+ 1688 image-search <path> Search by image (.jpg/.png/.webp local file).
16
+ 1688 order list List buyer orders; --status, --page, --page-size flags.
17
+ 1688 order list --status waitbuyerreceive Filter to "awaiting delivery".
18
+ 1688 order get <orderId> Fetch one order by ID (scans recent pages; --max-scan-pages N).
19
+ 1688 order logistics <orderId> Shipping status + tracking number (mailNo, carrier, remark).
20
+ 1688 cart list List items in 1688 cart (采购车).
21
+ 1688 cart add <offerId> --sku <skuId> --qty N Add SKU to cart (~15s, UI replay).
22
+ 1688 cart remove <cartId> Remove one cart item (~12s, UI replay).
23
+ 1688 checkout prepare <cartId>... Preview total/address/items for checkout (NO order placement, ~12s).
24
+ 1688 checkout confirm <cartId>... PLACE order — TTY+prompt by default.
25
+ 1688 checkout confirm <cartId>... --agent Agent mode: no prompt, daemon-OK.
26
+ MUST be preceded by a `prepare` call shown to the user
27
+ AND explicit user authorization in the current turn.
28
+ 1688 offer <offerId> Full product detail: title, price range, SKUs (with stock), supplier, freight.
29
+ 1688 whoami Print current account, exit 3 if not logged in.
30
+ 1688 whoami --verify Also verify online (slower, ~3s).
31
+ 1688 logout Log out (prompts unless --yes).
32
+ 1688 logout --yes Skip confirmation.
33
+ 1688 doctor Diagnose environment + session state.
34
+ 1688 doctor --no-launch Skip the actual Chromium launch test (faster).
35
+
36
+ 1688 daemon start Start the background daemon (shared Chromium).
37
+ 1688 daemon stop Stop the daemon.
38
+ 1688 daemon status Show daemon state + stats.
39
+ 1688 serve Run daemon in the foreground.
40
+ ```
41
+
42
+ ## Daemon (recommended for agent use)
43
+
44
+ When the daemon is running, `search` and `whoami` route through it and share a
45
+ single Chromium context. Benefits:
46
+ - ~2-3 seconds saved per command (no Chrome cold start)
47
+ - Looks like one continuous human user to 1688 risk control
48
+ - Built-in inter-command throttle (1.2-3s jitter) keeps WAF score low
49
+
50
+ The agent should call `1688 daemon start` once at the beginning of a session
51
+ that involves multiple 1688 commands. The daemon auto-stops after 30 minutes
52
+ of inactivity.
53
+
54
+ `login`, `logout`, `doctor` stay inline; they require interactive UI or browser
55
+ windows. If the daemon is running and you need to `login --force`, stop the
56
+ daemon first.
57
+
58
+ ```
59
+ ```
60
+
61
+ ## Exit codes
62
+
63
+ | Code | Meaning |
64
+ |------|---------|
65
+ | 0 | Success |
66
+ | 2 | Bad invocation (missing flag, etc.) |
67
+ | 3 | Not logged in / session expired |
68
+ | 5 | Another 1688 command is running (lock busy) |
69
+ | 6 | Chromium not installed |
70
+ | 7 | Login wait timeout |
71
+ | 4 | Aliyun risk control (slider verification) — retry with `--headed` |
72
+ | 8 | Login finished but cookies missing |
73
+ | 9 | Network error |
74
+ | 130 | User canceled |
75
+
76
+ ## Status filter values (for `order list --status`)
77
+
78
+ | value | meaning |
79
+ |---|---|
80
+ | `all` | All orders |
81
+ | `waitbuyerpay` | 待付款 |
82
+ | `waitsellersend` | 待发货 |
83
+ | `waitbuyerreceive` | 待收货 |
84
+ | `success` | 已完成 |
85
+ | `cancel` | 已取消 |
86
+
87
+ ## Rules for the agent
88
+
89
+ - `1688 login` opens a window the user must interact with. Only run it
90
+ yourself if the user explicitly asks you to log in.
91
+ - `1688 logout` requires `--yes` in non-interactive mode. Do not pass
92
+ `--yes` without explicit user confirmation in the current turn.
93
+ - If a command returns exit 3, tell the user to run `1688 login`.
94
+ Do not loop or retry on your own.
95
+ - If a command returns exit 4 (risk control), tell the user to run the
96
+ same command once with `--headed` (they will need to drag a slider).
97
+ Do not retry the same command silently.
98
+ - **`1688 checkout confirm` requires a TTY by default**, OR `--agent` flag.
99
+ It places real orders (no payment yet, but commits to seller).
100
+
101
+ **Agent protocol for placing orders:**
102
+ 1. Run `1688 checkout prepare <cartIds>` first
103
+ 2. SHOW the user the full preview (total, items, address, seller)
104
+ 3. WAIT for the user's explicit "yes, place it" / "下单吧" in the current turn
105
+ 4. Only then run `1688 checkout confirm <cartIds> --agent`
106
+ 5. Report the final orderId / URL back to the user
107
+
108
+ NEVER run `--agent` without the prepare+approval cycle. NEVER infer authorization
109
+ from older messages — it must be explicit in the CURRENT turn.
110
+ - JSON output of `whoami`:
111
+ ```json
112
+ {"loggedIn": true, "memberId": "...", "nick": "...", "lastVerifiedAt": "..."}
113
+ {"loggedIn": false}
114
+ ```
115
+
116
+ ## Discovery
117
+
118
+ Run `1688 --help` and `1688 <command> --help` for the latest flags.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # 1688
2
+
3
+ 1688 CLI for humans, Codex, and Claude Code.
4
+
5
+ > MVP scope: `login` / `whoami` / `logout`. Search / image-search / cart /
6
+ > orders coming next.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm install
12
+ npx playwright install chromium # if postinstall didn't run
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```bash
18
+ pnpm dev login # first time: opens a window, scan QR
19
+ pnpm dev whoami # prints nick + memberId, exit 3 if not logged in
20
+ pnpm dev whoami --verify # additionally probes 1688 to detect stale cookies
21
+ pnpm dev logout # interactive confirm; --yes to skip
22
+ pnpm dev logout --yes | jq # JSON output (auto when piped)
23
+ ```
24
+
25
+ ## Design
26
+
27
+ - **Single persistent Chromium profile** at `~/.1688/profiles/default/`.
28
+ Cookies, localStorage, IndexedDB, and device fingerprint all live there.
29
+ - **State cache** at `~/.1688/state.json` (nick / memberId / timestamps).
30
+ Source of truth is always the cookies — state.json is just a cache.
31
+ - **One process at a time** via `proper-lockfile` on `~/.1688/.lock`.
32
+ - **JSON when piped**, human-readable on TTY. Force JSON via `BB1688_JSON=1`.
33
+
34
+ See [AGENTS.md](./AGENTS.md) for the agent contract.
35
+
36
+ ## Layout
37
+
38
+ ```
39
+ src/
40
+ cli.ts # argv → command dispatch
41
+ commands/ # login / whoami / logout
42
+ session/ # Playwright + lock + state.json + paths
43
+ auth/ # cookie parsing + online verification
44
+ io/ # output / prompt / errors (TTY vs pipe)
45
+ util/
46
+ tests/
47
+ scripts/postinstall.mjs # auto-installs Chromium on first npm install
48
+ ```
@@ -0,0 +1,31 @@
1
+ export function parseIdentity(cookies) {
2
+ const memberId = pick(cookies, 'unb', '.1688.com') ?? pick(cookies, 'unb', '.taobao.com');
3
+ if (!memberId)
4
+ return null;
5
+ const trackraw = pick(cookies, 'tracknick');
6
+ const nick = trackraw ? decodeTracknick(trackraw) : null;
7
+ return { memberId, nick };
8
+ }
9
+ function pick(cookies, name, domainSuffix) {
10
+ for (const c of cookies) {
11
+ if (c.name !== name)
12
+ continue;
13
+ if (domainSuffix && !c.domain.endsWith(domainSuffix))
14
+ continue;
15
+ return c.value;
16
+ }
17
+ return undefined;
18
+ }
19
+ export function decodeTracknick(raw) {
20
+ let s = raw;
21
+ try {
22
+ s = decodeURIComponent(s);
23
+ }
24
+ catch {
25
+ // malformed percent encoding — leave as-is
26
+ }
27
+ // Handle literal \uXXXX escapes that sometimes survive in cookie values
28
+ s = s.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
29
+ return s;
30
+ }
31
+ //# sourceMappingURL=cookies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/auth/cookies.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,aAAa,CAAC,OAAiB;IAC7C,MAAM,QAAQ,GACZ,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IAC3E,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,IAAI,CACX,OAAiB,EACjB,IAAY,EACZ,YAAqB;IAErB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI;YAAE,SAAS;QAC9B,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,SAAS;QAC/D,OAAO,CAAC,CAAC,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,IAAI,CAAC,GAAG,GAAG,CAAC;IACZ,IAAI,CAAC;QACH,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,2CAA2C;IAC7C,CAAC;IACD,wEAAwE;IACxE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,EAAE,CACvD,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CACvC,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,25 @@
1
+ const PROBE_URL = 'https://myalibaba.1688.com/';
2
+ export async function verifyOnline(ctx) {
3
+ const page = await ctx.newPage();
4
+ try {
5
+ const resp = await page.goto(PROBE_URL, {
6
+ waitUntil: 'domcontentloaded',
7
+ timeout: 15000,
8
+ });
9
+ const finalUrl = page.url();
10
+ if (/login\.1688\.com|login\.taobao\.com/.test(finalUrl))
11
+ return false;
12
+ if (!resp)
13
+ return false;
14
+ if (resp.status() >= 400)
15
+ return false;
16
+ return true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ finally {
22
+ await page.close().catch(() => { });
23
+ }
24
+ }
25
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/auth/verify.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAmB;IACpD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACtC,SAAS,EAAE,kBAAkB;YAC7B,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,qCAAqC,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO,KAAK,CAAC;QACvE,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG;YAAE,OAAO,KAAK,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,373 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { CliError } from './io/errors.js';
4
+ const program = new Command();
5
+ program
6
+ .name('1688')
7
+ .description('1688 CLI for humans, Codex, and Claude Code')
8
+ .version('0.1.0');
9
+ program
10
+ .command('login')
11
+ .description('Log in to 1688 by scanning a QR code (auto-starts daemon afterwards)')
12
+ .option('--force', 'Re-login even if a session already exists')
13
+ .option('--timeout <seconds>', 'Seconds to wait for QR scan', '300')
14
+ .option('--profile <name>', 'Profile name (default: default)')
15
+ .option('--headed', 'Open a real browser window instead of terminal QR')
16
+ .option('--no-daemon', 'Do not auto-start the daemon after login')
17
+ .action(async (opts) => {
18
+ const { run } = await import('./commands/login.js');
19
+ await run(opts);
20
+ });
21
+ program
22
+ .command('search')
23
+ .description('Search 1688 by keyword')
24
+ .argument('<keyword>', 'Keyword to search (use quotes for multi-word)')
25
+ .option('--max <n>', 'Maximum number of results', '20')
26
+ .option('--profile <name>', 'Profile name (default: default)')
27
+ .option('--headed', 'Open a browser window (use to pass slider verification)')
28
+ .action(async (keyword, opts) => {
29
+ const { run } = await import('./commands/search.js');
30
+ await run(keyword, opts);
31
+ });
32
+ program
33
+ .command('image-search')
34
+ .description('Search 1688 by image (local file or http(s) URL)')
35
+ .argument('<imagePathOrUrl>', 'Local file path OR http(s) image URL')
36
+ .option('--max <n>', 'Maximum number of results', '20')
37
+ .option('--profile <name>', 'Profile name (default: default)')
38
+ .option('--headed', 'Open a window (fallback for risk control)')
39
+ .action(async (imagePath, opts) => {
40
+ const { run } = await import('./commands/image-search.js');
41
+ await run({ ...opts, imagePath });
42
+ });
43
+ program
44
+ .command('offer')
45
+ .description('Show details of a single 1688 offer')
46
+ .argument('<offerId>', 'Offer ID (digits)')
47
+ .option('--profile <name>', 'Profile name (default: default)')
48
+ .option('--headed', 'Open a browser window (fallback for risk control)')
49
+ .action(async (offerId, opts) => {
50
+ const { run } = await import('./commands/offer.js');
51
+ await run({ ...opts, offerId });
52
+ });
53
+ const seller = program
54
+ .command('seller')
55
+ .description('Seller communication (旺旺 IM)');
56
+ seller
57
+ .command('inquire')
58
+ .description('Pre-sale inquiry: send a product link + question to seller (requires prior chat or --to)')
59
+ .argument('<offerId>', 'Offer ID (digits)')
60
+ .argument('<message>', 'Question to ask (≤ 400 chars)')
61
+ .option('--to <sellerLoginId>', 'Override seller lookup with explicit loginId')
62
+ .option('--profile <name>', 'Profile name (default: default)')
63
+ .option('--headed', 'Open a window (debug visibility)')
64
+ .action(async (offerId, message, opts) => {
65
+ const { run } = await import('./commands/seller-inquire.js');
66
+ await run({ ...opts, offerId, message });
67
+ });
68
+ seller
69
+ .command('messages')
70
+ .description('Read recent messages from a seller conversation')
71
+ .argument('<target>', 'orderId (digits) OR seller loginId/name')
72
+ .option('--limit <n>', 'Max messages to return (default 20, max 200)', '20')
73
+ .option('--since <iso>', 'Only show messages after this ISO timestamp (e.g. 2026-05-12T16:44:00+08:00)')
74
+ .option('--profile <name>', 'Profile name (default: default)')
75
+ .option('--headed', 'Open a window (debug visibility)')
76
+ .action(async (target, opts) => {
77
+ const { run } = await import('./commands/seller-messages.js');
78
+ await run({ ...opts, target });
79
+ });
80
+ seller
81
+ .command('chat')
82
+ .description('Send to seller. With orderId: sends order card link + message (use --no-card for follow-ups).')
83
+ .argument('<target>', 'orderId (digits) OR seller loginId/name')
84
+ .argument('<message>', 'Message to send (≤ 500 chars)')
85
+ .option('--no-card', 'Skip the order detail link card (for follow-up replies)')
86
+ .option('--prefix', 'Also prepend 【订单 XXX】 in message text')
87
+ .option('--profile <name>', 'Profile name (default: default)')
88
+ .option('--headed', 'Open a window (debug visibility)')
89
+ .action(async (target, message, opts) => {
90
+ const { run } = await import('./commands/seller-chat.js');
91
+ await run({ ...opts, target, message });
92
+ });
93
+ const checkout = program
94
+ .command('checkout')
95
+ .description('Checkout preview and confirmation (write operations)');
96
+ checkout
97
+ .command('confirm')
98
+ .description('Place an order for selected cart items. Default: TTY+prompt. --agent: no prompt, daemon-OK.')
99
+ .argument('<cartIds...>', 'cartIds to checkout (from `1688 cart list`)')
100
+ .option('-y, --yes', 'Skip y/N prompt (TTY still required)')
101
+ .option('--agent', 'Agent mode: no prompts, may run via daemon. Use ONLY after user reviewed prepare.')
102
+ .option('--profile <name>', 'Profile name (default: default)')
103
+ .action(async (cartIds, opts) => {
104
+ const { run } = await import('./commands/checkout-confirm.js');
105
+ await run({ ...opts, cartIds });
106
+ });
107
+ checkout
108
+ .command('prepare')
109
+ .description('Preview total/address/items for a checkout (does NOT place order)')
110
+ .argument('<cartIds...>', 'One or more cartIds from `1688 cart list`')
111
+ .option('--profile <name>', 'Profile name (default: default)')
112
+ .option('--headed', 'Open a window (debug visibility)')
113
+ .action(async (cartIds, opts) => {
114
+ const { run } = await import('./commands/checkout-prepare.js');
115
+ await run({ ...opts, cartIds });
116
+ });
117
+ const cart = program
118
+ .command('cart')
119
+ .description('1688 cart (采购车) operations');
120
+ cart
121
+ .command('add')
122
+ .description('Add one item to cart (UI replay, ~15s)')
123
+ .argument('<offerId>', 'Offer ID (digits)')
124
+ .requiredOption('--sku <skuId>', 'SKU ID (from `1688 offer <offerId>`)')
125
+ .option('--qty <n>', 'Quantity', '1')
126
+ .option('--profile <name>', 'Profile name (default: default)')
127
+ .option('--headed', 'Open a window (debug visibility)')
128
+ .action(async (offerId, opts) => {
129
+ const { run } = await import('./commands/cart-add.js');
130
+ await run({ ...opts, offerId });
131
+ });
132
+ cart
133
+ .command('remove')
134
+ .description('Remove one item from cart by cartId (UI replay, ~10s)')
135
+ .argument('<cartId>', 'Cart item ID (from `1688 cart list`)')
136
+ .option('--profile <name>', 'Profile name (default: default)')
137
+ .option('--headed', 'Open a window (debug visibility)')
138
+ .action(async (cartId, opts) => {
139
+ const { run } = await import('./commands/cart-remove.js');
140
+ await run({ ...opts, cartId });
141
+ });
142
+ cart
143
+ .command('list')
144
+ .description('List items in your cart')
145
+ .option('--profile <name>', 'Profile name (default: default)')
146
+ .option('--headed', 'Open a window (fallback for risk control)')
147
+ .action(async (opts) => {
148
+ const { run } = await import('./commands/cart-list.js');
149
+ await run(opts);
150
+ });
151
+ program
152
+ .command('shipped')
153
+ .description('Combined order detail + logistics for one orderId')
154
+ .argument('<orderId>', 'Order ID (digits)')
155
+ .option('--profile <name>', 'Profile name (default: default)')
156
+ .option('--headed', 'Open a window (fallback for risk control)')
157
+ .action(async (orderId, opts) => {
158
+ const { runShipped } = await import('./commands/workflows.js');
159
+ await runShipped({ ...opts, orderId });
160
+ });
161
+ program
162
+ .command('stuck')
163
+ .description('Orders paid but not shipped after N days (default 3)')
164
+ .option('--days <n>', 'Threshold in days', '3')
165
+ .option('--limit <n>', 'Max orders to return', '50')
166
+ .option('--profile <name>', 'Profile name (default: default)')
167
+ .option('--headed', 'Open a window (fallback for risk control)')
168
+ .action(async (opts) => {
169
+ const { runStuck } = await import('./commands/workflows.js');
170
+ await runStuck(opts);
171
+ });
172
+ program
173
+ .command('fake-shipped')
174
+ .description('Orders marked shipped but logistics frozen at 等待揽收 (likely 虚假发货)')
175
+ .option('--days <n>', 'Days threshold since shippedAt', '1')
176
+ .option('--max-pages <n>', 'Order list pages to scan (50/page)', '2')
177
+ .option('--max-check <n>', 'Max candidates to query logistics for', '20')
178
+ .option('--limit <n>', 'Max flagged orders to return', '50')
179
+ .option('--debug', 'Print logistics status/remark for each candidate')
180
+ .option('--profile <name>', 'Profile name (default: default)')
181
+ .option('--headed', 'Open a window (fallback for risk control)')
182
+ .action(async (opts) => {
183
+ const { runFakeShipped } = await import('./commands/workflows.js');
184
+ await runFakeShipped(opts);
185
+ });
186
+ program
187
+ .command('seller-history')
188
+ .description('All orders from a seller + avg shipping days + on-time rate')
189
+ .argument('<seller>', 'Seller loginId or company name (partial match OK)')
190
+ .option('--max-pages <n>', 'Max order list pages to scan (50/page)', '10')
191
+ .option('--profile <name>', 'Profile name (default: default)')
192
+ .option('--headed', 'Open a window (fallback for risk control)')
193
+ .action(async (seller, opts) => {
194
+ const { runSellerHistory } = await import('./commands/workflows.js');
195
+ await runSellerHistory({ ...opts, seller });
196
+ });
197
+ const order = program
198
+ .command('order')
199
+ .description('Buyer order operations');
200
+ order
201
+ .command('logistics')
202
+ .description('Show shipping status + tracking number for an order')
203
+ .argument('<orderId>', 'Order ID (digits)')
204
+ .option('--max-scan-pages <n>', 'Max list pages to scan (50/page)', '5')
205
+ .option('--status <s>', 'Narrow scan to one tradeStatus (waitbuyerreceive, waitsellersend, ...) — faster for heavy accounts')
206
+ .option('--profile <name>', 'Profile name (default: default)')
207
+ .option('--headed', 'Open a window (fallback for risk control)')
208
+ .action(async (orderId, opts) => {
209
+ const { run } = await import('./commands/order-logistics.js');
210
+ await run({ ...opts, orderId });
211
+ });
212
+ order
213
+ .command('get')
214
+ .description('Show one order by orderId (scans recent pages)')
215
+ .argument('<orderId>', 'Order ID (digits)')
216
+ .option('--max-scan-pages <n>', 'Max list pages to scan (50/page)', '5')
217
+ .option('--status <s>', 'Narrow scan to one tradeStatus (waitbuyerreceive, ...) — faster for heavy accounts')
218
+ .option('--profile <name>', 'Profile name (default: default)')
219
+ .option('--headed', 'Open a window (fallback for risk control)')
220
+ .action(async (orderId, opts) => {
221
+ const { run } = await import('./commands/order-get.js');
222
+ await run({ ...opts, orderId });
223
+ });
224
+ order
225
+ .command('list')
226
+ .description('List buyer orders')
227
+ .option('--status <s>', 'Filter: all | waitbuyerpay | waitsellersend | waitbuyerreceive | success | cancel', 'all')
228
+ .option('--page <n>', 'Page number', '1')
229
+ .option('--page-size <n>', 'Page size (max 50)', '10')
230
+ .option('--profile <name>', 'Profile name (default: default)')
231
+ .option('--headed', 'Open a window (fallback for risk control)')
232
+ .action(async (opts) => {
233
+ const { run } = await import('./commands/order-list.js');
234
+ await run(opts);
235
+ });
236
+ program
237
+ .command('whoami')
238
+ .description('Show the current logged-in account')
239
+ .option('--verify', 'Verify the session online (slower)')
240
+ .option('--profile <name>', 'Profile name (default: default)')
241
+ .action(async (opts) => {
242
+ const { run } = await import('./commands/whoami.js');
243
+ await run(opts);
244
+ });
245
+ program
246
+ .command('logout')
247
+ .description('Log out and clear local session')
248
+ .option('-y, --yes', 'Skip the confirmation prompt')
249
+ .option('--profile <name>', 'Profile name (default: default)')
250
+ .action(async (opts) => {
251
+ const { run } = await import('./commands/logout.js');
252
+ await run(opts);
253
+ });
254
+ program
255
+ .command('doctor')
256
+ .description('Check environment, profile, Chromium, and session')
257
+ .option('--no-launch', 'Skip the actual Chromium launch test (faster)')
258
+ .option('--profile <name>', 'Profile name (default: default)')
259
+ .action(async (opts) => {
260
+ const { run } = await import('./commands/doctor.js');
261
+ await run(opts);
262
+ });
263
+ program
264
+ .command('serve')
265
+ .description('Run the 1688 daemon in the foreground')
266
+ .option('--idle-timeout <minutes>', 'Idle timeout in minutes', '30')
267
+ .option('--no-prewarm', 'Skip pre-warming Chromium at startup')
268
+ .action(async (opts) => {
269
+ const { start } = await import('./daemon/server.js');
270
+ await start({
271
+ idleTimeoutMs: Math.max(1, parseInt(opts.idleTimeout, 10)) * 60_000,
272
+ prewarm: opts.prewarm !== false,
273
+ });
274
+ });
275
+ const daemon = program
276
+ .command('daemon')
277
+ .description('Manage the background 1688 daemon');
278
+ daemon
279
+ .command('start')
280
+ .description('Start the daemon as a background process')
281
+ .action(async () => {
282
+ const { start } = await import('./daemon/manager.js');
283
+ const { emit } = await import('./io/output.js');
284
+ const { pid } = await start();
285
+ emit({
286
+ human: () => process.stdout.write(`Daemon started (pid ${pid}).\n`),
287
+ data: { ok: true, pid },
288
+ });
289
+ });
290
+ daemon
291
+ .command('stop')
292
+ .description('Stop the running daemon')
293
+ .action(async () => {
294
+ const { stop } = await import('./daemon/manager.js');
295
+ const { emit } = await import('./io/output.js');
296
+ const { stopped } = await stop();
297
+ emit({
298
+ human: () => process.stdout.write(stopped ? 'Daemon stopped.\n' : 'Daemon was not running.\n'),
299
+ data: { ok: true, stopped },
300
+ });
301
+ });
302
+ daemon
303
+ .command('reload')
304
+ .description('Restart the daemon (stop + start) to pick up new code')
305
+ .action(async () => {
306
+ const fs = await import('node:fs/promises');
307
+ const { stop, start, status } = await import('./daemon/manager.js');
308
+ const { lockFile } = await import('./session/paths.js');
309
+ const { emit, info } = await import('./io/output.js');
310
+ const before = await status();
311
+ if (before.running) {
312
+ info('Stopping daemon...');
313
+ await stop();
314
+ }
315
+ // Force-clean stale lock — we own the lifecycle here, so this is safe.
316
+ // proper-lockfile sometimes leaves the `.lock.lock` dir behind if the daemon
317
+ // exits before its release callback runs to completion.
318
+ info('Cleaning stale lock...');
319
+ await fs.rm(lockFile() + '.lock', { recursive: true, force: true });
320
+ info('Starting daemon...');
321
+ const { pid } = await start();
322
+ emit({
323
+ human: () => process.stdout.write(`Daemon reloaded (pid ${pid}).\n`),
324
+ data: { ok: true, pid, wasRunning: before.running },
325
+ });
326
+ });
327
+ daemon
328
+ .command('status')
329
+ .description('Show daemon status')
330
+ .action(async () => {
331
+ const { status } = await import('./daemon/manager.js');
332
+ const { emit } = await import('./io/output.js');
333
+ const s = await status();
334
+ emit({
335
+ human: () => {
336
+ if (!s.running) {
337
+ process.stdout.write('Daemon: not running\n');
338
+ return;
339
+ }
340
+ process.stdout.write(`Daemon: running (pid ${s.pid})\n`);
341
+ if (s.reachable && s.stats && typeof s.stats === 'object') {
342
+ const st = s.stats;
343
+ process.stdout.write(` uptime: ${Math.round(st.uptimeMs / 1000)}s\n`);
344
+ process.stdout.write(` commands: ${st.commandCount}\n`);
345
+ if (st.lastRequestAt) {
346
+ process.stdout.write(` last request: ${st.lastRequestAt}\n`);
347
+ }
348
+ }
349
+ },
350
+ data: s,
351
+ });
352
+ });
353
+ try {
354
+ await program.parseAsync();
355
+ }
356
+ catch (e) {
357
+ if (e instanceof CliError) {
358
+ if (e.message)
359
+ process.stderr.write(`error: ${e.message}\n`);
360
+ process.exit(e.exitCode);
361
+ }
362
+ const err = e;
363
+ const msg = err?.message ?? String(e);
364
+ // Playwright surfaces these when the user closes the browser mid-flow.
365
+ if (/Target page, context or browser has been closed/i.test(msg) ||
366
+ /Browser closed|Target closed/i.test(msg)) {
367
+ process.stderr.write('error: Canceled (browser closed).\n');
368
+ process.exit(130);
369
+ }
370
+ process.stderr.write(`unexpected: ${err.stack ?? msg}\n`);
371
+ process.exit(1);
372
+ }
373
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,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