@envarai/envarpay 0.1.0-alpha.3 → 0.2.0-alpha.2

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 (60) hide show
  1. package/README.md +56 -146
  2. package/dist/commerce/buyer-store.d.ts +101 -0
  3. package/dist/commerce/buyer-store.js +168 -0
  4. package/dist/commerce/buyer.d.ts +132 -0
  5. package/dist/commerce/buyer.js +755 -0
  6. package/dist/commerce/card.d.ts +5 -0
  7. package/dist/commerce/card.js +29 -0
  8. package/dist/commerce/chain.d.ts +24 -0
  9. package/dist/commerce/chain.js +146 -0
  10. package/dist/commerce/cli.d.ts +2 -0
  11. package/dist/commerce/cli.js +274 -0
  12. package/dist/commerce/client-runtime.d.ts +8 -0
  13. package/dist/commerce/client-runtime.js +7 -0
  14. package/dist/commerce/config.d.ts +7 -0
  15. package/dist/commerce/config.js +182 -0
  16. package/dist/commerce/envar-runtime.d.ts +46 -0
  17. package/dist/commerce/envar-runtime.js +256 -0
  18. package/dist/commerce/envar.d.ts +126 -0
  19. package/dist/commerce/envar.js +647 -0
  20. package/dist/commerce/http.d.ts +2 -0
  21. package/dist/commerce/http.js +34 -0
  22. package/dist/commerce/index.d.ts +4 -0
  23. package/dist/commerce/index.js +4 -0
  24. package/dist/commerce/management.d.ts +14 -0
  25. package/dist/commerce/management.js +138 -0
  26. package/dist/commerce/mpp-client.d.ts +59 -0
  27. package/dist/commerce/mpp-client.js +24 -0
  28. package/dist/commerce/mpp-runtime.d.ts +3 -0
  29. package/dist/commerce/mpp-runtime.js +3 -0
  30. package/dist/commerce/mpp.d.ts +53 -0
  31. package/dist/commerce/mpp.js +163 -0
  32. package/dist/commerce/operations.d.ts +16 -0
  33. package/dist/commerce/operations.js +33 -0
  34. package/dist/commerce/peer-proxy.d.ts +44 -0
  35. package/dist/commerce/peer-proxy.js +673 -0
  36. package/dist/commerce/pricing.d.ts +12 -0
  37. package/dist/commerce/pricing.js +60 -0
  38. package/dist/commerce/runtime.d.ts +8 -0
  39. package/dist/commerce/runtime.js +8 -0
  40. package/dist/commerce/server.d.ts +59 -0
  41. package/dist/commerce/server.js +499 -0
  42. package/dist/commerce/store.d.ts +88 -0
  43. package/dist/commerce/store.js +473 -0
  44. package/dist/commerce/stripe-provider.d.ts +9 -0
  45. package/dist/commerce/stripe-provider.js +97 -0
  46. package/dist/commerce/types.d.ts +134 -0
  47. package/dist/commerce/types.js +8 -0
  48. package/dist/commerce/upstream.d.ts +6 -0
  49. package/dist/commerce/upstream.js +103 -0
  50. package/dist/commerce/vault.d.ts +8 -0
  51. package/dist/commerce/vault.js +55 -0
  52. package/dist/commerce/x402.d.ts +37 -0
  53. package/dist/commerce/x402.js +174 -0
  54. package/examples/buyer-policy.json +18 -0
  55. package/examples/envar-integration-policy.json +18 -0
  56. package/examples/seller.json +52 -0
  57. package/package.json +75 -10
  58. package/schemas/buyer-policy.schema.json +253 -0
  59. package/schemas/envarpay.config.schema.json +376 -0
  60. package/schemas/quote.schema.json +91 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "enabled": true,
3
+ "platformOrigin": "https://envar.ai",
4
+ "agentId": "54fe760a-4580-4258-9002-80f34c0d757a",
5
+ "runtimeAgentId": "hermes-researcher",
6
+ "acceptUpdates": true,
7
+ "allowedServices": ["research"],
8
+ "allowedUpstreamOrigins": ["http://hermes:9000"],
9
+ "allowedX402": [
10
+ {
11
+ "network": "eip155:84532",
12
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
13
+ "payTo": "0x2222222222222222222222222222222222222222",
14
+ "facilitatorOrigin": "https://facilitator.example"
15
+ }
16
+ ],
17
+ "allowedMppAccounts": ["seller-stripe"]
18
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "configVersion": 1,
3
+ "agent": {"id": "hermes-researcher", "name": "我的研究助手"},
4
+ "paymentProfiles": {
5
+ "base-usdc": {
6
+ "adapter": "x402", "scheme": "exact", "network": "eip155:84532",
7
+ "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
8
+ "payTo": "0x2222222222222222222222222222222222222222",
9
+ "facilitatorUrl": "https://facilitator.example"
10
+ },
11
+ "stripe-usd": {"adapter": "mpp", "method": "stripe", "intent": "charge", "currency": "usd", "accountRef": "seller-stripe"}
12
+ },
13
+ "services": [
14
+ {
15
+ "id": "research", "name": "竞品调研", "revision": 1,
16
+ "execution": {"type": "a2a", "cardUrl": "http://hermes:9000/research/agent-card.json"},
17
+ "contract": {
18
+ "inputSchema": {
19
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
20
+ "type": "object", "additionalProperties": false, "required": ["topic", "competitors"],
21
+ "properties": {
22
+ "topic": {"type": "string", "minLength": 1, "maxLength": 500},
23
+ "competitors": {"type": "array", "minItems": 1, "maxItems": 3, "uniqueItems": true, "items": {"type": "string", "minLength": 1, "maxLength": 120}}
24
+ }
25
+ },
26
+ "deliverables": ["report.md", "comparison.csv"], "targetDurationSeconds": 600, "includedRevisions": 0
27
+ },
28
+ "offers": [
29
+ {"id": "usdc-once", "pricing": {"kind": "fixed", "amount": "3000000"}, "collection": {"kind": "upfront"}, "paymentProfile": "base-usdc"},
30
+ {"id": "card-once", "pricing": {"kind": "fixed", "amount": "300"}, "collection": {"kind": "upfront"}, "paymentProfile": "stripe-usd"}
31
+ ]
32
+ },
33
+ {
34
+ "id": "summary-preview", "name": "免费试读", "revision": 1,
35
+ "execution": {"type": "a2a", "cardUrl": "http://hermes:9000/preview/agent-card.json"},
36
+ "contract": {
37
+ "inputSchema": {"type": "object", "additionalProperties": false, "required": ["text"], "properties": {"text": {"type": "string", "minLength": 1, "maxLength": 500}}},
38
+ "deliverables": ["summary.txt"], "targetDurationSeconds": 60, "includedRevisions": 0
39
+ },
40
+ "offers": [{"id": "free", "pricing": {"kind": "free"}, "collection": {"kind": "none"}}]
41
+ },
42
+ {
43
+ "id": "translation", "name": "文档翻译", "revision": 1,
44
+ "execution": {"type": "a2a", "cardUrl": "http://openclaw:9000/translate/agent-card.json"},
45
+ "contract": {
46
+ "inputSchema": {"type": "object", "additionalProperties": false, "required": ["documents"], "properties": {"documents": {"type": "array", "minItems": 1, "maxItems": 20, "items": {"type": "string", "minLength": 1, "maxLength": 10000}}}},
47
+ "deliverables": ["translations.json"], "targetDurationSeconds": 600, "includedRevisions": 0
48
+ },
49
+ "offers": [{"id": "per-document", "pricing": {"kind": "quantity", "unit": "document", "unitAmount": "100000", "quantity": {"pointer": "/documents", "measure": "count", "min": 1, "max": 20}}, "collection": {"kind": "upfront"}, "paymentProfile": "base-usdc"}]
50
+ }
51
+ ]
52
+ }
package/package.json CHANGED
@@ -1,15 +1,80 @@
1
1
  {
2
2
  "name": "@envarai/envarpay",
3
- "version": "0.1.0-alpha.3",
4
- "description": "Typed MCP client for an operator-configured EnvarPay wallet service",
3
+ "version": "0.2.0-alpha.2",
4
+ "description": "Independent A2A service commerce, budgeted buyers and x402/MPP payments",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "engines": { "node": ">=22.14.0" },
8
- "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
9
- "files": ["dist", "README.md", "LICENSE"],
10
- "repository": { "type": "git", "url": "git+https://github.com/EnvarAI/EnvarPay.git", "directory": "packages/typescript" },
11
- "publishConfig": { "access": "public", "tag": "next" },
12
- "scripts": { "build": "tsc", "test": "npm run build && node --test test/client.test.mjs", "prepack": "npm run build" },
13
- "dependencies": { "@modelcontextprotocol/sdk": "^1.31.0" },
14
- "devDependencies": { "typescript": "~5.9.3", "@types/node": "^22.0.0" }
7
+ "engines": {
8
+ "node": ">=22.14.0"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/commerce/index.d.ts",
13
+ "import": "./dist/commerce/index.js"
14
+ },
15
+ "./commerce": {
16
+ "types": "./dist/commerce/index.d.ts",
17
+ "import": "./dist/commerce/index.js"
18
+ },
19
+ "./commerce/server": {
20
+ "types": "./dist/commerce/runtime.d.ts",
21
+ "import": "./dist/commerce/runtime.js"
22
+ },
23
+ "./client": {
24
+ "types": "./dist/commerce/client-runtime.d.ts",
25
+ "import": "./dist/commerce/client-runtime.js"
26
+ },
27
+ "./server": {
28
+ "types": "./dist/commerce/runtime.d.ts",
29
+ "import": "./dist/commerce/runtime.js"
30
+ },
31
+ "./mpp": {
32
+ "types": "./dist/commerce/mpp-runtime.d.ts",
33
+ "import": "./dist/commerce/mpp-runtime.js"
34
+ },
35
+ "./envar": {
36
+ "types": "./dist/commerce/envar.d.ts",
37
+ "import": "./dist/commerce/envar.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE",
44
+ "schemas",
45
+ "examples"
46
+ ],
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/EnvarAI/EnvarPay.git",
50
+ "directory": "packages/typescript"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "tag": "next"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc",
58
+ "test": "npm run build && node --test test/*.test.mjs",
59
+ "prepack": "npm run build"
60
+ },
61
+ "dependencies": {
62
+ "@a2a-js/sdk": "1.2.1",
63
+ "@modelcontextprotocol/sdk": "^1.31.0",
64
+ "@x402/core": "2.24.0",
65
+ "@x402/evm": "2.24.0",
66
+ "@x402/extensions": "2.24.0",
67
+ "ajv": "8.20.0",
68
+ "ajv-formats": "3.0.1",
69
+ "canonicalize": "2.1.0",
70
+ "mppx": "0.13.1",
71
+ "viem": "2.57.1"
72
+ },
73
+ "devDependencies": {
74
+ "@types/node": "^22.0.0",
75
+ "typescript": "~5.9.3"
76
+ },
77
+ "bin": {
78
+ "envarpay": "dist/commerce/cli.js"
79
+ }
15
80
  }
@@ -0,0 +1,253 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:envarpay:buyer-policy:1",
4
+ "title": "Local buyer permission policy; not supplied by the seller",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "policyVersion",
9
+ "paymentsEnabled",
10
+ "approval",
11
+ "peers",
12
+ "budgets"
13
+ ],
14
+ "properties": {
15
+ "policyVersion": {
16
+ "const": 1
17
+ },
18
+ "paymentsEnabled": {
19
+ "type": "boolean"
20
+ },
21
+ "approval": {
22
+ "enum": [
23
+ "per_purchase",
24
+ "within_preapproved_limits"
25
+ ]
26
+ },
27
+ "peers": {
28
+ "type": "array",
29
+ "minItems": 1,
30
+ "items": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": [
34
+ "id",
35
+ "cardUrl",
36
+ "protocol",
37
+ "currency",
38
+ "recipient",
39
+ "maxPerPurchase"
40
+ ],
41
+ "properties": {
42
+ "id": {
43
+ "type": "string",
44
+ "pattern": "^[a-z][a-z0-9-]{0,63}$"
45
+ },
46
+ "cardUrl": {
47
+ "type": "string",
48
+ "format": "uri",
49
+ "pattern": "^https://"
50
+ },
51
+ "protocol": {
52
+ "enum": [
53
+ "x402",
54
+ "mpp",
55
+ "free"
56
+ ]
57
+ },
58
+ "currency": {
59
+ "type": [
60
+ "string",
61
+ "null"
62
+ ]
63
+ },
64
+ "recipient": {
65
+ "type": [
66
+ "string",
67
+ "null"
68
+ ]
69
+ },
70
+ "maxPerPurchase": {
71
+ "type": "string",
72
+ "pattern": "^(0|[1-9][0-9]{0,77})$"
73
+ },
74
+ "mode": {
75
+ "enum": [
76
+ "envarpay",
77
+ "standard-a2a"
78
+ ]
79
+ },
80
+ "endpoint": {
81
+ "type": "string",
82
+ "format": "uri",
83
+ "pattern": "^https://"
84
+ },
85
+ "authentication": {
86
+ "enum": [
87
+ "none",
88
+ "bearer"
89
+ ]
90
+ },
91
+ "localContract": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": [
95
+ "revision",
96
+ "offerId",
97
+ "inputSchema",
98
+ "amount",
99
+ "paidOnly"
100
+ ],
101
+ "properties": {
102
+ "revision": {
103
+ "type": "integer",
104
+ "minimum": 1,
105
+ "maximum": 9007199254740991
106
+ },
107
+ "offerId": {
108
+ "type": "string",
109
+ "pattern": "^[a-z][a-z0-9-]{0,63}$"
110
+ },
111
+ "inputSchema": {
112
+ "type": "object"
113
+ },
114
+ "amount": {
115
+ "$ref": "#/$defs/amount"
116
+ },
117
+ "paidOnly": {
118
+ "const": true
119
+ }
120
+ }
121
+ }
122
+ },
123
+ "allOf": [
124
+ {
125
+ "if": {
126
+ "properties": {
127
+ "protocol": {
128
+ "const": "free"
129
+ }
130
+ }
131
+ },
132
+ "then": {
133
+ "properties": {
134
+ "currency": {
135
+ "const": null
136
+ },
137
+ "recipient": {
138
+ "const": null
139
+ },
140
+ "maxPerPurchase": {
141
+ "const": "0"
142
+ }
143
+ }
144
+ },
145
+ "else": {
146
+ "properties": {
147
+ "currency": {
148
+ "type": "string",
149
+ "minLength": 1
150
+ },
151
+ "recipient": {
152
+ "type": "string",
153
+ "minLength": 1
154
+ },
155
+ "maxPerPurchase": {
156
+ "$ref": "#/$defs/amount"
157
+ }
158
+ }
159
+ }
160
+ },
161
+ {
162
+ "if": {
163
+ "required": [
164
+ "mode"
165
+ ],
166
+ "properties": {
167
+ "mode": {
168
+ "const": "standard-a2a"
169
+ }
170
+ }
171
+ },
172
+ "then": {
173
+ "required": [
174
+ "endpoint",
175
+ "authentication",
176
+ "localContract"
177
+ ],
178
+ "properties": {
179
+ "protocol": {
180
+ "const": "x402"
181
+ },
182
+ "endpoint": {},
183
+ "authentication": {},
184
+ "localContract": {}
185
+ }
186
+ },
187
+ "else": {
188
+ "not": {
189
+ "anyOf": [
190
+ {
191
+ "required": [
192
+ "endpoint"
193
+ ],
194
+ "properties": {
195
+ "endpoint": {}
196
+ }
197
+ },
198
+ {
199
+ "required": [
200
+ "authentication"
201
+ ],
202
+ "properties": {
203
+ "authentication": {}
204
+ }
205
+ },
206
+ {
207
+ "required": [
208
+ "localContract"
209
+ ],
210
+ "properties": {
211
+ "localContract": {}
212
+ }
213
+ }
214
+ ]
215
+ }
216
+ }
217
+ }
218
+ ]
219
+ }
220
+ },
221
+ "budgets": {
222
+ "type": "array",
223
+ "minItems": 0,
224
+ "items": {
225
+ "type": "object",
226
+ "additionalProperties": false,
227
+ "required": [
228
+ "currency",
229
+ "maxTotal",
230
+ "period"
231
+ ],
232
+ "properties": {
233
+ "currency": {
234
+ "type": "string",
235
+ "minLength": 1
236
+ },
237
+ "maxTotal": {
238
+ "$ref": "#/$defs/amount"
239
+ },
240
+ "period": {
241
+ "const": "cumulative"
242
+ }
243
+ }
244
+ }
245
+ }
246
+ },
247
+ "$defs": {
248
+ "amount": {
249
+ "type": "string",
250
+ "pattern": "^[1-9][0-9]{0,77}$"
251
+ }
252
+ }
253
+ }