@seasonkoh/webaz 0.1.26 → 0.1.28

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 (99) hide show
  1. package/LICENSE +2 -2
  2. package/NOTICE +24 -3
  3. package/README.md +74 -330
  4. package/README.zh-CN.md +419 -0
  5. package/dist/layer0-foundation/L0-2-state-machine/genuine-sale.js +21 -0
  6. package/dist/layer0-foundation/L0-5-manifest/manifest.js +8 -3
  7. package/dist/layer1-agent/L1-1-mcp-server/auth.js +13 -1
  8. package/dist/layer1-agent/L1-1-mcp-server/network-mode.js +69 -0
  9. package/dist/layer1-agent/L1-1-mcp-server/server.js +270 -82
  10. package/dist/layer2-business/L2-9-contribution/admin-coordination-ingestion-engine.js +181 -0
  11. package/dist/layer2-business/L2-9-contribution/admin-coordination-resolver.js +114 -0
  12. package/dist/layer2-business/L2-9-contribution/admin-coordination-store.js +251 -0
  13. package/dist/layer2-business/L2-9-contribution/admin-operator-claim-workflow.js +390 -0
  14. package/dist/layer2-business/L2-9-contribution/build-task-agent-metadata-store.js +24 -0
  15. package/dist/layer2-business/L2-9-contribution/build-task-participation.js +6 -2
  16. package/dist/layer2-business/L2-9-contribution/build-task-quota.js +337 -0
  17. package/dist/layer2-business/L2-9-contribution/build-task-read.js +25 -2
  18. package/dist/layer2-business/L2-9-contribution/build-tasks-engine.js +57 -7
  19. package/dist/layer2-business/L2-9-contribution/canonical-contribution-target.js +1 -1
  20. package/dist/layer2-business/L2-9-contribution/contribution-facts-read.js +66 -0
  21. package/dist/layer2-business/L2-9-contribution/task-proposal-draft.js +187 -18
  22. package/dist/layer2-business/L2-9-contribution/task-proposal-store.js +29 -4
  23. package/dist/ledger.js +1 -1
  24. package/dist/pwa/admin-audit.js +38 -0
  25. package/dist/pwa/anti-abuse-thresholds.js +135 -0
  26. package/dist/pwa/cf-origin-guard.js +33 -0
  27. package/dist/pwa/contract-fingerprint.js +1 -0
  28. package/dist/pwa/data/onboarding-cases.js +2 -2
  29. package/dist/pwa/data/onboarding-quiz.js +1 -1
  30. package/dist/pwa/economic-participation.js +2 -2
  31. package/dist/pwa/integration-contract.js +46 -4
  32. package/dist/pwa/internal/pv-settlement.js +12 -0
  33. package/dist/pwa/internal/wallet-signer.js +26 -0
  34. package/dist/pwa/public/app-account.js +977 -0
  35. package/dist/pwa/public/app-admin.js +608 -0
  36. package/dist/pwa/public/app-agents.js +63 -0
  37. package/dist/pwa/public/app-ai.js +2162 -0
  38. package/dist/pwa/public/app-contribution.js +836 -0
  39. package/dist/pwa/public/app-discover.js +1296 -0
  40. package/dist/pwa/public/app-listings.js +226 -0
  41. package/dist/pwa/public/app-profile.js +1692 -0
  42. package/dist/pwa/public/app-seller.js +199 -0
  43. package/dist/pwa/public/app-shop.js +1145 -0
  44. package/dist/pwa/public/app.js +15075 -23960
  45. package/dist/pwa/public/i18n.js +31 -28
  46. package/dist/pwa/public/index.html +11 -1
  47. package/dist/pwa/public/openapi.json +4851 -2776
  48. package/dist/pwa/pv-kill-switch.js +31 -0
  49. package/dist/pwa/routes/admin-admins.js +48 -1
  50. package/dist/pwa/routes/admin-analytics.js +1 -10
  51. package/dist/pwa/routes/admin-atomic.js +4 -17
  52. package/dist/pwa/routes/admin-operator-claims.js +280 -0
  53. package/dist/pwa/routes/admin-reports.js +4 -26
  54. package/dist/pwa/routes/admin-tokenomics.js +2 -76
  55. package/dist/pwa/routes/admin-users-lifecycle.js +1 -14
  56. package/dist/pwa/routes/admin-users-query.js +23 -1
  57. package/dist/pwa/routes/admin-wallet-ops.js +1 -1
  58. package/dist/pwa/routes/agent-grants.js +255 -0
  59. package/dist/pwa/routes/auth-read.js +1 -5
  60. package/dist/pwa/routes/auth-register.js +3 -13
  61. package/dist/pwa/routes/build-task-quota.js +113 -0
  62. package/dist/pwa/routes/claim-verify.js +15 -11
  63. package/dist/pwa/routes/contribution-facts.js +18 -0
  64. package/dist/pwa/routes/dispute-cases.js +5 -4
  65. package/dist/pwa/routes/growth.js +3 -3
  66. package/dist/pwa/routes/orders-action.js +27 -10
  67. package/dist/pwa/routes/orders-create.js +1 -1
  68. package/dist/pwa/routes/products-meta.js +19 -6
  69. package/dist/pwa/routes/profile-placement.js +1 -1
  70. package/dist/pwa/routes/promoter.js +10 -29
  71. package/dist/pwa/routes/public-build-tasks.js +5 -1
  72. package/dist/pwa/routes/public-utils.js +9 -12
  73. package/dist/pwa/routes/referral.js +5 -26
  74. package/dist/pwa/routes/rewards-apply.js +3 -2
  75. package/dist/pwa/routes/share-redirects.js +1 -1
  76. package/dist/pwa/routes/shareables-interactions.js +2 -1
  77. package/dist/pwa/routes/task-proposals.js +85 -9
  78. package/dist/pwa/routes/users-public.js +1 -4
  79. package/dist/pwa/routes/wallet-read.js +2 -14
  80. package/dist/pwa/routes/webauthn.js +7 -2
  81. package/dist/pwa/server-schema.js +9 -0
  82. package/dist/pwa/server.js +319 -2034
  83. package/dist/runtime/agent-grant-scopes.js +128 -0
  84. package/dist/runtime/agent-grant-verifier.js +67 -0
  85. package/dist/runtime/agent-pairing.js +60 -0
  86. package/dist/runtime/apply-webaz-runtime-schema.js +15 -0
  87. package/dist/runtime/webaz-schema-helpers.js +1848 -0
  88. package/dist/settlement-math.js +3 -3
  89. package/dist/version.js +6 -4
  90. package/package.json +43 -8
  91. package/dist/index.js +0 -182
  92. package/dist/pwa/public/docs/ECONOMIC-MODEL.md +0 -287
  93. package/dist/pwa/public/docs/INTEGRATOR.md +0 -67
  94. package/dist/pwa/public/docs/META-RULES-FULL.md +0 -543
  95. package/dist/test-dispute.js +0 -153
  96. package/dist/test-manifest.js +0 -61
  97. package/dist/test-mcp-tools.js +0 -135
  98. package/dist/test-reputation.js +0 -116
  99. package/dist/test-skill-market.js +0 -101
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { SOFTWARE_VERSION, CONTRACT_VERSION } from '../version.js';
7
7
  const BASE = 'https://webaz.xyz';
8
- const GH = 'https://github.com/seasonsagents-art/webaz/blob/main';
8
+ const GH = 'https://github.com/webaz-protocol/webaz/blob/main';
9
9
  // 集成必需文档(规则 + onboarding)由协议自身 serve —— 外部 agent 必须能读到它被约束的规则,
10
10
  // 不能指向私有 repo 的 GitHub 链接(对外 404)。RFC/审计是 provenance,留 GH(随 repo 公开解锁)。
11
11
  const DOCS = `${BASE}/docs`;
@@ -15,8 +15,49 @@ export function buildIntegrationContract() {
15
15
  contract_version: CONTRACT_VERSION,
16
16
  software_version: SOFTWARE_VERSION,
17
17
  thesis: 'WebAZ is agent-native: you integrate by your agent reading this machine-readable contract and self-integrating — we do NOT build a bespoke API/auth/webhook layer per integrator. The protocol provides rules + semantics + boundaries + accountability + eventing + verifiability + settlement. See docs/RFC-011.',
18
- // 源码仓库 launch 前私有 —— 公开声明,防"自称开源但 GitHub 404"被读成 vaporware。
19
- source_status: 'The source repo (github.com/seasonsagents-art/webaz) is PRIVATE until the W8 public launch, so GitHub links in these surfaces may return 404 until then — they open at launch, not a dead project. The full machine-readable spec is ALREADY public via these /.well-known/* surfaces; an agent never needs the repo to integrate or verify.',
18
+ // 源码仓库已公开(github.com/webaz-protocol/webaz);机器可读 spec 也在 /.well-known/*。
19
+ source_status: 'The source repo (github.com/webaz-protocol/webaz) is public (open source). The full machine-readable spec is also available via these /.well-known/* surfaces; an agent never needs the repo to integrate or verify.',
20
+ // 60 秒冷启动 —— 一个从没见过 WebAZ、没有登录态、没有内部上下文的陌生 agent,一次 fetch 就能自我定位:
21
+ // 这是什么 / 从哪开始 / 匿名能做什么 / 鉴权才能做什么 / 安全的第一步 / 怎么提建议参与共建。离散字段(非散文)便于解析。
22
+ // 贡献边界(RFC-017)前置声明:建议 ≠ 贡献事实 ≠ 奖励,避免任何经济/兑现承诺暗示。
23
+ agent_quickstart: {
24
+ what_is_webaz: 'An agent-native, open commerce protocol: humans and AI agents transact on the same state-machine-governed protocol — and can also help build the protocol itself. Pre-launch: simulated test currency, no real money settles yet.',
25
+ canonical_start_url: `${BASE}/.well-known/webaz-integration.json`,
26
+ read_this_first: [`${BASE}/.well-known/webaz-integration.json (this document)`, `${DOCS}/INTEGRATOR.md`],
27
+ public_readonly_entrypoints: [
28
+ `${BASE}/.well-known/webaz-protocol.json`,
29
+ `${BASE}/.well-known/webaz-capabilities.json`,
30
+ `${BASE}/.well-known/webaz-entities.json`,
31
+ `${BASE}/.well-known/webaz-goals.json`,
32
+ `${BASE}/api/protocol-status`,
33
+ `${BASE}/api/agent/changes`,
34
+ `${BASE}/api/public/build-tasks`,
35
+ ],
36
+ anonymous_allowed_actions: [
37
+ 'read every /.well-known/* surface + public GET endpoints (no credential)',
38
+ 'browse the live catalog at /#discover',
39
+ 'discover open build tasks — GET /api/public/build-tasks (MCP: webaz_contribute action=list_open)',
40
+ 'submit a build/improvement suggestion — POST /api/public/task-proposals (MCP: webaz_contribute action=suggest); no key required',
41
+ ],
42
+ authenticated_required_actions: [
43
+ 'any write / transact (register, order, list, fulfil, dispute)',
44
+ 'claim or submit a build task (MCP: webaz_contribute action=claim / submit)',
45
+ 'track your own suggestions (MCP: webaz_contribute action=my_suggestions)',
46
+ ],
47
+ how_to_authenticate: `An api_key requires a REAL HUMAN to register (invite + Passkey) at ${BASE}/#welcome — agents CANNOT self-register; this is the accountability root. Browsing and reading need no key.`,
48
+ safe_next_actions: [
49
+ '1. Read this contract + INTEGRATOR.md to learn the boundaries (anonymous vs. authenticated).',
50
+ '2. Browse anonymously: the catalog (/#discover) and the well-known surfaces above.',
51
+ '3. To improve the protocol: discover open tasks or submit a suggestion — both keyless (see proposal_flow).',
52
+ '4. To transact: have your accountable human get an invite + api_key, then declare scope (§③).',
53
+ ],
54
+ proposal_flow: {
55
+ discover: 'GET /api/public/build-tasks (or MCP webaz_contribute action=list_open) — open, public, no key.',
56
+ suggest: 'POST /api/public/task-proposals (or MCP webaz_contribute action=suggest) — anonymous OK; lands in the maintainer review inbox.',
57
+ after_submit: 'A human maintainer reviews. A suggestion never auto-publishes to the task board and is never auto-accepted; conversion to a formal task is manual.',
58
+ },
59
+ contribution_boundary: 'A suggestion is a proposal in the maintainer review inbox — NOT a contribution fact, NOT formal participation, and NOT any economic or redemption right. Recorded contribution is facts / evidence / attribution only (RFC-017); it confers no payment and no entitlement.',
60
+ },
20
61
  // 外部 agent 的第一道问题:"我怎么从匿名读升到能写?" —— 入口必须自答(不依赖 GitHub)。
21
62
  access: {
22
63
  browse_first: 'No account needed to START: browse the live catalog at https://webaz.xyz/#discover and read every well-known surface below anonymously. Try before you commit.',
@@ -60,8 +101,9 @@ export function buildIntegrationContract() {
60
101
  enters_core_test: 'A capability enters the protocol (vs integrator self-solving) iff ALL: ≥N independent integrators need it × needs cross-party trust/verification × cannot be reconstructed from already-exposed data.',
61
102
  iron_rule: 'arbitrate / vote / agent_revoke / delete_passkey / large withdraw require a live WebAuthn ceremony regardless of declared scope.',
62
103
  references: {
104
+ // RFC-011 is the public formalization of the agent-native integration audit; the audit doc itself is
105
+ // an internal artifact (not in the public tree), so it is not advertised as a reference here.
63
106
  rfc_011: `${GH}/docs/rfcs/RFC-011-agent-native-integration-contract.md`,
64
- audit: `${GH}/docs/AGENT-NATIVE-INTEGRATION-AUDIT.md`,
65
107
  manifest: `${BASE}/.well-known/webaz-protocol.json`,
66
108
  },
67
109
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Excised stub factory. Accepts the same deps as the original engine (so the call site is unchanged) but
3
+ * returns no-op functions. Deps are intentionally unused.
4
+ */
5
+ export function createPvSettlementEngine(_deps) {
6
+ return {
7
+ // 匹配结算已切除:不匹配、不产生 Score、不动 PV 腿。永远返回 0。
8
+ runBinarySettlement: () => 0,
9
+ // 兑付已切除:永远 disabled,从不发放。
10
+ executeSafeSettlementCron: () => ({ periodId: '', status: 'disabled' }),
11
+ };
12
+ }
@@ -0,0 +1,26 @@
1
+ import { privateKeyToAccount, privateKeyToAddress } from 'viem/accounts';
2
+ import { createHmac } from 'node:crypto';
3
+ /** Seed string for the hot-wallet role (also the issuer role today — see Phase 0.5). */
4
+ export const HOT_WALLET_SEED = 'platform-hot-wallet';
5
+ /**
6
+ * In-process signer derived from a single master seed (current production behavior; dev/testnet).
7
+ * `privKey(role) = 0x<HMAC-SHA256(masterSeed, role)>` — byte-for-byte identical to the legacy
8
+ * `derivePrivKey` in server.ts, so addresses / signatures do not change.
9
+ *
10
+ * Phase 1+ will provide `createKmsSigner(...)` / `createSafeSigner(...)` implementing the same
11
+ * interface, selected via the `HOT_WALLET_SIGNER` env var.
12
+ */
13
+ export function createLocalSeedSigner(masterSeed) {
14
+ const privKey = (role) => `0x${createHmac('sha256', masterSeed).update(role).digest('hex')}`;
15
+ // Issuer currently shares the hot-wallet key (unchanged address). Phase 0.5 points it at a
16
+ // dedicated key + dual-key credential verification; do NOT change this seed before that.
17
+ const ISSUER_SEED = HOT_WALLET_SEED;
18
+ return {
19
+ hotAccount: () => privateKeyToAccount(privKey(HOT_WALLET_SEED)),
20
+ hotAddress: () => privateKeyToAddress(privKey(HOT_WALLET_SEED)),
21
+ depositAccount: (userId) => privateKeyToAccount(privKey(userId)),
22
+ depositAddress: (userId) => privateKeyToAddress(privKey(userId)),
23
+ issuerSignMessage: (message) => privateKeyToAccount(privKey(ISSUER_SEED)).signMessage({ message }),
24
+ issuerAddress: () => privateKeyToAddress(privKey(ISSUER_SEED)),
25
+ };
26
+ }