@seasonkoh/webaz 0.1.15 → 0.1.16

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/LICENSE CHANGED
@@ -16,7 +16,7 @@ Business Source License 1.1
16
16
  Change License: MIT
17
17
 
18
18
  For information about alternative licensing arrangements for the
19
- Licensed Work, please contact seasons.agents@gmail.com.
19
+ Licensed Work, please contact licensing@webaz.xyz.
20
20
  License text copyright © 2024 MariaDB plc, All Rights Reserved. “Business Source License” is a trademark of MariaDB plc.
21
21
 
22
22
  Terms
package/NOTICE ADDED
@@ -0,0 +1,58 @@
1
+ WebAZ — Licensing Notice
2
+ =========================
3
+
4
+ Copyright (c) 2026 seasonsagents-art and WebAZ contributors
5
+
6
+
7
+ Current License (since 2026-05-18)
8
+ ----------------------------------
9
+
10
+ Business Source License 1.1 (BUSL-1.1).
11
+ See LICENSE for full terms.
12
+
13
+ Licensor: seasonsagents-art
14
+ Licensed Work: WebAZ — Agent-native decentralized commerce protocol
15
+ Additional Use Grant: You may make production use of the Licensed Work,
16
+ provided that your use does not include offering the
17
+ Licensed Work to third parties as a hosted or managed
18
+ service that is substantially similar to, or competes
19
+ with, the WebAZ commerce protocol service operated by
20
+ the Licensor.
21
+ Change Date: 2030-05-18
22
+ Change License: MIT
23
+
24
+ On the Change Date the Licensed Work automatically converts to the
25
+ Change License (MIT) for all purposes.
26
+
27
+
28
+ Historical Licensing
29
+ --------------------
30
+
31
+ All versions and git commits published BEFORE 2026-05-18 were released under
32
+ the MIT License. That grant is irrevocable. Copies, forks, and derivatives
33
+ made from those earlier versions remain MIT-licensed in perpetuity.
34
+
35
+ The license change applies only to commits and releases dated on or after
36
+ 2026-05-18.
37
+
38
+
39
+ Third-Party Components
40
+ ----------------------
41
+
42
+ This software incorporates third-party open-source libraries listed in
43
+ package.json. Each is governed by its own license; see the respective
44
+ package's LICENSE file for terms.
45
+
46
+
47
+ Trademarks
48
+ ----------
49
+
50
+ "WebAZ" and the WebAZ logo are trademarks of seasonsagents-art. The license
51
+ does not grant any trademark rights.
52
+
53
+
54
+ Questions
55
+ ---------
56
+
57
+ For licensing questions, including commercial license inquiries that fall
58
+ outside the Additional Use Grant above, contact: licensing@webaz.xyz
package/README.md CHANGED
@@ -6,7 +6,12 @@
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@seasonkoh/webaz.svg)](https://www.npmjs.com/package/@seasonkoh/webaz)
8
8
  [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-active-blue)](https://registry.modelcontextprotocol.io/v0/servers?search=webaz)
9
- [![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-orange.svg)](LICENSE) [![Change Date: 2030-05-18](https://img.shields.io/badge/Change%20Date-2030--05--18-blue.svg)](NOTICE)
9
+ [![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-orange.svg)](LICENSE) [![Change Date: 2030-05-18](https://img.shields.io/badge/Change%20Date-2030--05--18-blue.svg)](NOTICE) ![Status: Pre-launch](https://img.shields.io/badge/Status-Pre--launch-yellow.svg)
10
+
11
+ > 🚧 **Pre-launch · 预发布阶段** — v1.0 公示中(起算 2026-05-31)· 0 真用户 · verifier + arbitrator 全为 fixture · 经济模型未结算 · 不建议生产使用。
12
+ > 🚧 **Pre-launch stage** — v1.0 public-notice period (started 2026-05-31) · 0 real users · verifier + arbitrator are fixtures · economic model un-settled · **not for production use**.
13
+ >
14
+ > 详见 / Details: [`docs/CHARTER.md`](docs/CHARTER.md) · [`docs/META-RULES-FULL.md`](docs/META-RULES-FULL.md) · [`docs/ECONOMIC-MODEL.md`](docs/ECONOMIC-MODEL.md) · [`/api/protocol-status`](https://webaz.xyz/api/protocol-status)
10
15
 
11
16
  让 AI Agent 成为去中心化商业协议的原生参与者。卖家零额外工作量接入新渠道,买家通过 Agent 自动购物,人类与 AI 在同一协议上平等参与。
12
17
 
@@ -315,3 +320,21 @@ npm run test-manifest# 测试协议 Manifest
315
320
  - [ ] 评价系统(结构化 1-5 星,反哺声誉)
316
321
  - [ ] 证据上传通道(争议附图)
317
322
  - [ ] 治理 DAO
323
+
324
+ ---
325
+
326
+ ## 联系 / Contact
327
+
328
+ | 用途 / Purpose | Email | 详情 / Details |
329
+ |---|---|---|
330
+ | 通用咨询 / General inquiries | `contact@webaz.xyz` | — |
331
+ | 安全漏洞 / Security vulnerabilities | `security@webaz.xyz` | [SECURITY.md](SECURITY.md) — 强烈优先用 [GitHub Security Advisory](https://github.com/seasonsagents-art/webaz/security/advisories) / Strongly prefer Advisory |
332
+ | 行为准则举报 / Code of Conduct reports | `conduct@webaz.xyz` | [docs/CODE_OF_CONDUCT.md](docs/CODE_OF_CONDUCT.md) §7 |
333
+ | BSL 商业授权 / Commercial licensing | `licensing@webaz.xyz` | [LICENSE](LICENSE) / [NOTICE](NOTICE) |
334
+
335
+ > 📬 上述均为 Cloudflare Email Routing forwarding alias;phase A solo 阶段统一转发到创始人个人邮箱,响应水平为**个人级**(非企业 SLA);phase B+ 形成 maintainer 群后会切到团队 triage(无需改文档)。
336
+ > 📬 All addresses are Cloudflare Email Routing forwarding aliases; in phase A solo, they route to the founder's personal inbox with **personal-level response** (not enterprise SLA); phase B+ will switch to maintainer team triage (no doc change needed).
337
+
338
+ **Bug 报告 / 功能想法 / RFC**:走 [GitHub Issues](https://github.com/seasonsagents-art/webaz/issues) 或 [Discussions](https://github.com/seasonsagents-art/webaz/discussions);PR 流程见 [CONTRIBUTING.md](CONTRIBUTING.md)。
339
+
340
+ **Bug reports / feature ideas / RFCs**: please use [GitHub Issues](https://github.com/seasonsagents-art/webaz/issues) or [Discussions](https://github.com/seasonsagents-art/webaz/discussions); PR workflow per [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -27,7 +27,9 @@ import { requireAuth } from './auth.js';
27
27
  import { createHash, randomBytes } from 'node:crypto';
28
28
  const SERVER_VERSION = '0.1.8';
29
29
  const TELEMETRY_URL = process.env.WEBAZ_TELEMETRY_URL ?? 'https://webaz.xyz/api/mcp-telemetry';
30
- const TELEMETRY_ENABLED = (process.env.WEBAZ_TELEMETRY ?? 'on').toLowerCase() !== 'off';
30
+ // 2026-06-01: phase A pre-launch 默认 OFF(opt-in) W8 public launch 时翻回 default ON + 加 README 披露段
31
+ // Phase A pre-launch: telemetry default OFF (opt-in). Flip to default ON at W8 launch + add README disclosure section.
32
+ const TELEMETRY_ENABLED = (process.env.WEBAZ_TELEMETRY ?? 'off').toLowerCase() === 'on';
31
33
  // ─── 初始化 ──────────────────────────────────────────────────
32
34
  const db = initDatabase();
33
35
  initSystemUser(db);
@@ -537,6 +539,13 @@ Actions:
537
539
  Agents should poll this periodically to check for pending order events.
538
540
  Every status change (new order / ship / dispute / etc.) notifies relevant participants.
539
541
 
542
+ ⚠️ Scope: 此工具只查 L2-6 system notifications。不含 / Does NOT include:
543
+ - chat unread(私信)→ 用 webaz_chat action=list
544
+ - announcements unread(管理员公告)→ 暂无 MCP 工具(PWA #me/announcements)
545
+ - feedback replies unread(用户反馈回复)→ 暂无 MCP 工具
546
+ PWA 顶部红点是 4 项合计;此工具仅返回第 1 项 → 数字可能 < PWA 显示。
547
+ PWA top badge aggregates all 4; this returns only 1 → may be < PWA shows.
548
+
540
549
  ──
541
550
  中文:查通知 — agent 定期调用检查待处理事件(新订单/发货/争议等会通知所有相关方)。`,
542
551
  inputSchema: {
@@ -944,7 +953,14 @@ Returns the action result.`,
944
953
 
945
954
  USE THIS when user asks "what's popular/being bought near me / 我附近 / 同城" — geo-aggregated
946
955
  view, no specific keyword. NOT for "find product X" — use webaz_search. NOT for "items shippable
947
- to my address" — use webaz_search ship_to filter.`,
956
+ to my address" — use webaz_search ship_to filter.
957
+
958
+ ⚠️ MCP query 需要先 set_location(否则返回 has_location: false 提示)。
959
+ PWA #nearby 有【全网 / 同城 / 周边 / 14 公里】 4 档 fallback,无 location 也能看全网视图 —
960
+ 这是设计性差异(MCP agent 应明示要 location,PWA UI 友好降级)。
961
+ ⚠️ MCP query needs set_location first (else returns has_location: false).
962
+ PWA #nearby has 4-tier fallback (national/city/around/14km) showing global view without location —
963
+ by design (MCP demands location; PWA degrades gracefully).`,
948
964
  inputSchema: {
949
965
  type: 'object',
950
966
  properties: {
@@ -104,7 +104,11 @@ async function persistApiKey(key) {
104
104
  await idbSet('webaz_key_set_at', Date.now())
105
105
  // 申请 persistent storage(iOS Safari / Chrome / Firefox 都支持)
106
106
  // iOS 仍可能拒(取决于使用频率/收藏状态),但申请总好过不申请
107
- try { await navigator.storage?.persist?.() } catch {}
107
+ // 2026-06-01 fix(BUG-PWA-NEW): fire-and-forget,不 await
108
+ // 背景:permission prompt 在某些浏览器状态下 pending 不 resolve(自动化测试 / 部分 first-visit
109
+ // 场景),会卡死整个 doLogin 流程 → 后续 navigateIntended 永不执行 → 登录后 UI 不刷新
110
+ // 修复:不阻塞登录流程,允许 persist 在后台慢慢拿
111
+ try { navigator.storage?.persist?.()?.catch(() => {}) } catch {}
108
112
  }
109
113
 
110
114
  // 当前域是否拿到了 persistent storage(iOS 7-day eviction 免疫指示)
@@ -439,6 +443,25 @@ async function apiWithStatus(method, path, body) {
439
443
  async function bootAuth() {
440
444
  if (state.authBooted) return
441
445
  state.authBooted = true
446
+ // 2026-06-01 fix(BUG-PWA-NEW safety net): boot 后任意 await 卡住,2.5s 后兜底强制重渲
447
+ // 背景:首次访问可能有多个 await 路径(initShareCtx / /me / IDB recovery 等)隐性 hang;
448
+ // 此 net 不解决 root cause,只确保 UI 不永驻 "正在恢复登录" skeleton
449
+ // P1 (2026-06-01): 加 recency guard 防 race — 若 route 在最近 1s 内已 fire(说明合法
450
+ // render 进行中,skeleton 是 in-flight fetch 的临时状态),跳过 safety net 防双 render
451
+ setTimeout(() => {
452
+ try {
453
+ const app = document.getElementById('app')
454
+ if (!app) return
455
+ if (!app.innerHTML.includes('正在恢复登录')) return
456
+ if (Date.now() - _lastRouteRanAt < 1000) {
457
+ console.info('[boot] skeleton 仍在但 route 刚 fire — 让合法 render 完成,跳过 safety net')
458
+ return
459
+ }
460
+ if (typeof window._routeForceRefresh !== 'function') return
461
+ console.warn('[boot] skeleton 仍在 + 无近期 route,强制 route refresh')
462
+ window._routeForceRefresh()
463
+ } catch {}
464
+ }, 2500)
442
465
 
443
466
  // Wave G-5 + audit P1-4: 启动时尽早拉 rate(anon 也拉),不阻塞登录恢复
444
467
  fetch('/api/wallet/rate').then(r => r.json()).then(r => {
@@ -452,8 +475,11 @@ async function bootAuth() {
452
475
  }).catch(() => {})
453
476
 
454
477
  // 桌面图标启动(standalone)+ Persistent Storage Permission(Chromium / 部分 Safari 支持)
478
+ // 2026-06-01 fix: fire-and-forget — 同 persistApiKey(L107),boot 路径也不阻塞
479
+ // 权限弹窗 pending 在某些场景(自动化/incognito/首次)会卡死整个 boot → 永驻"正在恢复登录"
480
+ // 不 await — 让 boot 立刻往下走,permission 后台慢慢拿
455
481
  if (navigator.storage?.persist) {
456
- try { await navigator.storage.persist() } catch {}
482
+ try { navigator.storage.persist().catch(() => {}) } catch {}
457
483
  }
458
484
 
459
485
  // 若 state.apiKey 为空(首次同步读 localStorage 没拿到,可能被 iOS 清了),从 IDB 恢复
@@ -479,10 +505,12 @@ async function bootAuth() {
479
505
  // 转发流程曾出现 3 次连调),导致 async render 之间无 mutex → race condition。
480
506
  // 用 last-hash 比较即可:相同 hash 跳过 render,async 中间态不被覆盖。
481
507
  let _lastRouteHash = null
508
+ let _lastRouteRanAt = 0 // 2026-06-01 P1: 给 safety net 用,防 hashchange+safety-net 双 render race
482
509
  function route(force) {
483
510
  const raw = location.hash.slice(1) || '/'
484
511
  if (!force && raw === _lastRouteHash) return // 防重复
485
512
  _lastRouteHash = raw
513
+ _lastRouteRanAt = Date.now() // P1: 标记 route 实际触发(early-return 后才记)
486
514
  // 剥离 query string:支持 #shares?product=xxx&source=order 模式
487
515
  const [pathPart, queryPart] = raw.split('?')
488
516
  state._urlQuery = queryPart ? Object.fromEntries(new URLSearchParams(queryPart)) : {}
@@ -5202,10 +5230,10 @@ function renderWelcome(app) {
5202
5230
  <div>© 2026 webaz</div>
5203
5231
  <div>${T('开放协议 · Agent 原生 · DAO 治理', 'Open Protocol · Agent-Native · DAO Governance')}</div>
5204
5232
  <div style="margin-top:10px">
5205
- <a href="#">${T('完整元规则', 'Full Meta-Rules')}</a>
5206
- <a href="#">GitHub</a>
5233
+ <a href="https://github.com/seasonsagents-art/webaz/blob/main/docs/META-RULES-FULL.md" target="_blank" rel="noopener">${T('完整元规则', 'Full Meta-Rules')}</a>
5234
+ <a href="https://github.com/seasonsagents-art/webaz" target="_blank" rel="noopener">GitHub</a>
5207
5235
  <a href="#">${T('协议白皮书', 'Whitepaper')}</a>
5208
- <a href="#">${T('联系', 'Contact')}</a>
5236
+ <a href="mailto:contact@webaz.xyz">${T('联系', 'Contact')}</a>
5209
5237
  </div>
5210
5238
  </footer>
5211
5239
  </div>
@@ -10466,10 +10494,16 @@ async function maybeClaimPendingProductShare() {
10466
10494
  function navigateIntended(fallback) {
10467
10495
  const intended = sessionStorage.getItem('webaz_intended_hash')
10468
10496
  sessionStorage.removeItem('webaz_intended_hash')
10469
- if (intended && intended !== '#' && intended !== '') {
10470
- location.hash = intended
10471
- } else if (fallback) {
10472
- location.hash = fallback
10497
+ const target = (intended && intended !== '#' && intended !== '') ? intended : fallback
10498
+ if (!target) return
10499
+ // 2026-06-01 fix(BUG-PWA-NEW): 防御 hashchange 不触发
10500
+ // 如果 target hash current hash 相同(e.g. user 被引到 #login 时 intended_hash 为空,
10501
+ // fallback 又恰好等于 current hash),location.hash 赋值不会 fire hashchange → route()
10502
+ // 不执行 → UI 不刷新。改用 force refresh.
10503
+ if (location.hash === target) {
10504
+ if (typeof window._routeForceRefresh === 'function') window._routeForceRefresh()
10505
+ } else {
10506
+ location.hash = target
10473
10507
  }
10474
10508
  }
10475
10509
 
@@ -23384,7 +23418,10 @@ async function renderWallet(app) {
23384
23418
  app.innerHTML = shell(loading$(), 'wallet')
23385
23419
  const userRegion = state.user?.region || 'global'
23386
23420
  const [wallet, income, deposits, withdrawals, whitelistRes, trust, tokenomics, rateRes, regionPmRes] = await Promise.all([
23387
- GET('/wallet'),
23421
+ // 2026-06-01 fix(BUG-PWA-WALLET): 加 catch 防 #wallet 加载死循环
23422
+ // 原 GET('/wallet') 无 fallback,一旦该 endpoint 错(网络 / 401 / 后端 500),
23423
+ // 整个 Promise.all reject,renderWallet 早退,"加载中..." 永驻
23424
+ GET('/wallet').catch(() => ({ balance: 0, escrowed: 0, staked: 0, earned: 0, _error: true })),
23388
23425
  GET('/wallet/income').catch(() => null),
23389
23426
  GET('/wallet/deposits').catch(() => []),
23390
23427
  GET('/wallet/withdrawals').catch(() => []),
@@ -23394,6 +23431,19 @@ async function renderWallet(app) {
23394
23431
  GET('/wallet/rate').catch(() => null),
23395
23432
  GET('/payment-methods/for-region?region=' + encodeURIComponent(userRegion)).catch(() => ({ items: [] })),
23396
23433
  ])
23434
+ // 2026-06-01 fix(BUG-PWA-WALLET self-review): 若 /wallet 加载失败,显式错误页(避免静默显示 0 余额误导)
23435
+ if (wallet?._error) {
23436
+ app.innerHTML = shell(`
23437
+ <div class="card" style="margin:40px auto;max-width:420px;text-align:center;padding:32px">
23438
+ <div style="font-size:32px;margin-bottom:12px">⚠️</div>
23439
+ <h2 style="margin:0 0 8px;font-size:18px">${t('钱包数据加载失败')}</h2>
23440
+ <p style="color:#6b7280;font-size:14px;margin:0 0 20px">${t('请检查网络后重试,或退出重新登录。当前显示的不是您的真实余额。')}</p>
23441
+ <button class="btn btn-primary" onclick="renderWallet(document.getElementById('app'))">${t('重试')}</button>
23442
+ <button class="btn btn-ghost" style="margin-left:8px" onclick="navigate('#me')">${t('返回')}</button>
23443
+ </div>
23444
+ `, 'wallet')
23445
+ return
23446
+ }
23397
23447
  // 多链/多渠道支付方法(admin 配置 · 当前默认仅 USDC-Base 实现)
23398
23448
  const regionMethods = regionPmRes?.items || []
23399
23449
  // 去重 method_id(同方法 deposit/withdraw 两条会合并显示)
@@ -1662,6 +1662,8 @@ const _EN = {
1662
1662
  '正在恢复登录...': 'Restoring login...',
1663
1663
  '暂时无法连接': 'Connection unavailable',
1664
1664
  '已为你保留登录状态,请检查网络后重试': 'Your login is preserved — check your network and retry',
1665
+ '钱包数据加载失败': 'Failed to load wallet data',
1666
+ '请检查网络后重试,或退出重新登录。当前显示的不是您的真实余额。': 'Check your network and retry, or log out and back in. The numbers shown are NOT your real balance.',
1665
1667
  '请填写收款地址和金额': 'Enter both address and amount',
1666
1668
  '活跃会话': 'Active sessions',
1667
1669
  '一键全登出': 'Logout everywhere',
@@ -1045,14 +1045,7 @@ try {
1045
1045
  db.exec("CREATE INDEX IF NOT EXISTS idx_wl_user ON withdrawal_whitelist(user_id, revoked_at)");
1046
1046
  }
1047
1047
  catch { }
1048
- try {
1049
- db.exec("ALTER TABLE withdrawal_requests ADD COLUMN status_detail TEXT");
1050
- }
1051
- catch { }
1052
- try {
1053
- db.exec("ALTER TABLE withdrawal_requests ADD COLUMN email_confirmed_at TEXT");
1054
- }
1055
- catch { }
1048
+ // (withdrawal_requests status_detail / email_confirmed_at migrations moved to where the table is created — see ~L3782)
1056
1049
  // Wave G-1: 链上签名证明地址归属 → 免 24h 冷却
1057
1050
  try {
1058
1051
  db.exec("ALTER TABLE withdrawal_whitelist ADD COLUMN signature_verified_at TEXT");
@@ -4478,16 +4471,27 @@ function detectShareCommandFormat(text) {
4478
4471
  }
4479
4472
  db.exec(`
4480
4473
  CREATE TABLE IF NOT EXISTS withdrawal_requests (
4481
- id TEXT PRIMARY KEY,
4482
- user_id TEXT NOT NULL,
4483
- to_address TEXT NOT NULL,
4484
- amount REAL NOT NULL,
4485
- status TEXT DEFAULT 'pending',
4486
- created_at TEXT DEFAULT (datetime('now')),
4487
- processed_at TEXT,
4488
- tx_hash TEXT
4474
+ id TEXT PRIMARY KEY,
4475
+ user_id TEXT NOT NULL,
4476
+ to_address TEXT NOT NULL,
4477
+ amount REAL NOT NULL,
4478
+ status TEXT DEFAULT 'pending',
4479
+ status_detail TEXT,
4480
+ email_confirmed_at TEXT,
4481
+ created_at TEXT DEFAULT (datetime('now')),
4482
+ processed_at TEXT,
4483
+ tx_hash TEXT
4489
4484
  )
4490
4485
  `);
4486
+ // migrations for older DBs (idempotent — fail silently if column already exists)
4487
+ try {
4488
+ db.exec("ALTER TABLE withdrawal_requests ADD COLUMN status_detail TEXT");
4489
+ }
4490
+ catch { }
4491
+ try {
4492
+ db.exec("ALTER TABLE withdrawal_requests ADD COLUMN email_confirmed_at TEXT");
4493
+ }
4494
+ catch { }
4491
4495
  db.exec(`
4492
4496
  CREATE TABLE IF NOT EXISTS deposit_txns (
4493
4497
  tx_hash TEXT PRIMARY KEY,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seasonkoh/webaz",
3
- "version": "0.1.15",
4
- "description": "Agent-native decentralized commerce protocol. Humans and AI agents trade on the same protocol via MCP tools.",
3
+ "version": "0.1.16",
4
+ "description": "[PRE-LAUNCH] Agent-native decentralized commerce protocol. Humans and AI agents trade on the same protocol via MCP tools. ⚠️ Repository currently private until W8 public launch — GitHub links may return 404. See https://webaz.xyz for status.",
5
5
  "main": "dist/mcp.js",
6
6
  "bin": {
7
7
  "webaz": "dist/mcp.js"
@@ -40,7 +40,9 @@
40
40
  "type": "module",
41
41
  "files": [
42
42
  "dist/",
43
- "README.md"
43
+ "README.md",
44
+ "LICENSE",
45
+ "NOTICE"
44
46
  ],
45
47
  "dependencies": {
46
48
  "@anthropic-ai/sdk": "^0.95.2",
@@ -62,6 +64,6 @@
62
64
  "typescript": "^6.0.3"
63
65
  },
64
66
  "engines": {
65
- "node": ">=18"
67
+ "node": ">=22"
66
68
  }
67
69
  }