@moonbeam-foundation/sdk 0.5.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 (186) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +378 -0
  3. package/bin/moonbeam.mjs +56 -0
  4. package/dist/acp/coverage.d.ts +36 -0
  5. package/dist/acp/coverage.d.ts.map +1 -0
  6. package/dist/acp/coverage.js +51 -0
  7. package/dist/acp/coverage.js.map +1 -0
  8. package/dist/acp/events.d.ts +201 -0
  9. package/dist/acp/events.d.ts.map +1 -0
  10. package/dist/acp/events.js +201 -0
  11. package/dist/acp/events.js.map +1 -0
  12. package/dist/acp/hex.d.ts +29 -0
  13. package/dist/acp/hex.d.ts.map +1 -0
  14. package/dist/acp/hex.js +51 -0
  15. package/dist/acp/hex.js.map +1 -0
  16. package/dist/acp/lifecycle-types.d.ts +11 -0
  17. package/dist/acp/lifecycle-types.d.ts.map +1 -0
  18. package/dist/acp/lifecycle-types.js +8 -0
  19. package/dist/acp/lifecycle-types.js.map +1 -0
  20. package/dist/acp/lifecycle.d.ts +78 -0
  21. package/dist/acp/lifecycle.d.ts.map +1 -0
  22. package/dist/acp/lifecycle.js +224 -0
  23. package/dist/acp/lifecycle.js.map +1 -0
  24. package/dist/acp/outcome.d.ts +45 -0
  25. package/dist/acp/outcome.d.ts.map +1 -0
  26. package/dist/acp/outcome.js +104 -0
  27. package/dist/acp/outcome.js.map +1 -0
  28. package/dist/acp/pipeline.d.ts +30 -0
  29. package/dist/acp/pipeline.d.ts.map +1 -0
  30. package/dist/acp/pipeline.js +25 -0
  31. package/dist/acp/pipeline.js.map +1 -0
  32. package/dist/acp/recourse.d.ts +74 -0
  33. package/dist/acp/recourse.d.ts.map +1 -0
  34. package/dist/acp/recourse.js +234 -0
  35. package/dist/acp/recourse.js.map +1 -0
  36. package/dist/acp/registry.d.ts +62 -0
  37. package/dist/acp/registry.d.ts.map +1 -0
  38. package/dist/acp/registry.js +86 -0
  39. package/dist/acp/registry.js.map +1 -0
  40. package/dist/acp/transitions.d.ts +82 -0
  41. package/dist/acp/transitions.d.ts.map +1 -0
  42. package/dist/acp/transitions.js +106 -0
  43. package/dist/acp/transitions.js.map +1 -0
  44. package/dist/actors/index.d.ts +84 -0
  45. package/dist/actors/index.d.ts.map +1 -0
  46. package/dist/actors/index.js +133 -0
  47. package/dist/actors/index.js.map +1 -0
  48. package/dist/actors/track-record.d.ts +79 -0
  49. package/dist/actors/track-record.d.ts.map +1 -0
  50. package/dist/actors/track-record.js +105 -0
  51. package/dist/actors/track-record.js.map +1 -0
  52. package/dist/adapters/acp.d.ts +48 -0
  53. package/dist/adapters/acp.d.ts.map +1 -0
  54. package/dist/adapters/acp.js +74 -0
  55. package/dist/adapters/acp.js.map +1 -0
  56. package/dist/adapters/port.d.ts +53 -0
  57. package/dist/adapters/port.d.ts.map +1 -0
  58. package/dist/adapters/port.js +2 -0
  59. package/dist/adapters/port.js.map +1 -0
  60. package/dist/adapters/stamp.d.ts +57 -0
  61. package/dist/adapters/stamp.d.ts.map +1 -0
  62. package/dist/adapters/stamp.js +114 -0
  63. package/dist/adapters/stamp.js.map +1 -0
  64. package/dist/client/index.d.ts +123 -0
  65. package/dist/client/index.d.ts.map +1 -0
  66. package/dist/client/index.js +78 -0
  67. package/dist/client/index.js.map +1 -0
  68. package/dist/connect/attestation.d.ts +64 -0
  69. package/dist/connect/attestation.d.ts.map +1 -0
  70. package/dist/connect/attestation.js +62 -0
  71. package/dist/connect/attestation.js.map +1 -0
  72. package/dist/connect/http.d.ts +36 -0
  73. package/dist/connect/http.d.ts.map +1 -0
  74. package/dist/connect/http.js +51 -0
  75. package/dist/connect/http.js.map +1 -0
  76. package/dist/connect/logs.d.ts +53 -0
  77. package/dist/connect/logs.d.ts.map +1 -0
  78. package/dist/connect/logs.js +42 -0
  79. package/dist/connect/logs.js.map +1 -0
  80. package/dist/connect/result.d.ts +49 -0
  81. package/dist/connect/result.d.ts.map +1 -0
  82. package/dist/connect/result.js +41 -0
  83. package/dist/connect/result.js.map +1 -0
  84. package/dist/core/actors.d.ts +13 -0
  85. package/dist/core/actors.d.ts.map +1 -0
  86. package/dist/core/actors.js +57 -0
  87. package/dist/core/actors.js.map +1 -0
  88. package/dist/core/clock.d.ts +55 -0
  89. package/dist/core/clock.d.ts.map +1 -0
  90. package/dist/core/clock.js +36 -0
  91. package/dist/core/clock.js.map +1 -0
  92. package/dist/core/money.d.ts +32 -0
  93. package/dist/core/money.d.ts.map +1 -0
  94. package/dist/core/money.js +57 -0
  95. package/dist/core/money.js.map +1 -0
  96. package/dist/core/pool.d.ts +71 -0
  97. package/dist/core/pool.d.ts.map +1 -0
  98. package/dist/core/pool.js +98 -0
  99. package/dist/core/pool.js.map +1 -0
  100. package/dist/core/settle.d.ts +50 -0
  101. package/dist/core/settle.d.ts.map +1 -0
  102. package/dist/core/settle.js +175 -0
  103. package/dist/core/settle.js.map +1 -0
  104. package/dist/core/types.d.ts +109 -0
  105. package/dist/core/types.d.ts.map +1 -0
  106. package/dist/core/types.js +6 -0
  107. package/dist/core/types.js.map +1 -0
  108. package/dist/erc8004/index.d.ts +94 -0
  109. package/dist/erc8004/index.d.ts.map +1 -0
  110. package/dist/erc8004/index.js +118 -0
  111. package/dist/erc8004/index.js.map +1 -0
  112. package/dist/erc8004/registry.generated.d.ts +17 -0
  113. package/dist/erc8004/registry.generated.d.ts.map +1 -0
  114. package/dist/erc8004/registry.generated.js +20 -0
  115. package/dist/erc8004/registry.generated.js.map +1 -0
  116. package/dist/erc8183/index.d.ts +114 -0
  117. package/dist/erc8183/index.d.ts.map +1 -0
  118. package/dist/erc8183/index.js +109 -0
  119. package/dist/erc8183/index.js.map +1 -0
  120. package/dist/index.d.ts +81 -0
  121. package/dist/index.d.ts.map +1 -0
  122. package/dist/index.js +73 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/judge/index.d.ts +64 -0
  125. package/dist/judge/index.d.ts.map +1 -0
  126. package/dist/judge/index.js +64 -0
  127. package/dist/judge/index.js.map +1 -0
  128. package/dist/launcher/index.d.ts +109 -0
  129. package/dist/launcher/index.d.ts.map +1 -0
  130. package/dist/launcher/index.js +144 -0
  131. package/dist/launcher/index.js.map +1 -0
  132. package/dist/negotiate/index.d.ts +166 -0
  133. package/dist/negotiate/index.d.ts.map +1 -0
  134. package/dist/negotiate/index.js +150 -0
  135. package/dist/negotiate/index.js.map +1 -0
  136. package/dist/onboard/index.d.ts +533 -0
  137. package/dist/onboard/index.d.ts.map +1 -0
  138. package/dist/onboard/index.js +509 -0
  139. package/dist/onboard/index.js.map +1 -0
  140. package/dist/onboarding/index.d.ts +177 -0
  141. package/dist/onboarding/index.d.ts.map +1 -0
  142. package/dist/onboarding/index.js +390 -0
  143. package/dist/onboarding/index.js.map +1 -0
  144. package/dist/pools/index.d.ts +191 -0
  145. package/dist/pools/index.d.ts.map +1 -0
  146. package/dist/pools/index.js +244 -0
  147. package/dist/pools/index.js.map +1 -0
  148. package/docs/demo.gif +0 -0
  149. package/docs/demo.tape +14 -0
  150. package/examples/01-settle-a-covered-job.mjs +18 -0
  151. package/examples/02-negotiate-a-hire.mjs +21 -0
  152. package/examples/03-end-to-end-offline.mjs +27 -0
  153. package/examples/10-grade-evidence.mjs +12 -0
  154. package/examples/11-grade-facts.mjs +10 -0
  155. package/examples/12-grade-answers.mjs +8 -0
  156. package/examples/13-grade-verdict.mjs +10 -0
  157. package/examples/14-grade-record.mjs +11 -0
  158. package/examples/15-grade-end-the-job.mjs +11 -0
  159. package/examples/16-grade-verify.mjs +9 -0
  160. package/examples/17-grade-live.mjs +14 -0
  161. package/examples/20-onboard-client.mjs +8 -0
  162. package/examples/21-onboard-provider.mjs +9 -0
  163. package/examples/22-onboard-evaluator.mjs +7 -0
  164. package/examples/23-onboard-backer.mjs +8 -0
  165. package/examples/30-read-a-real-job.mjs +19 -0
  166. package/examples/31-read-the-ending.mjs +15 -0
  167. package/examples/32-read-live-from-base.mjs +33 -0
  168. package/examples/33-read-many-jobs.mjs +12 -0
  169. package/examples/40-the-article.mjs +78 -0
  170. package/examples/README.md +93 -0
  171. package/examples/data/answers.mjs +8 -0
  172. package/examples/data/base-grade.recorded.json +72 -0
  173. package/examples/data/pilot-grade.recorded.json +78 -0
  174. package/examples/data/pilot-hire.json +35 -0
  175. package/examples/data/terms.mjs +11 -0
  176. package/examples/data/virtuals-job-74926.json +74 -0
  177. package/examples/data/virtuals-job-rejected.json +74 -0
  178. package/package.json +124 -0
  179. package/skills/moonbeam-acp-decoding/SKILL.md +80 -0
  180. package/skills/moonbeam-actor-backer/SKILL.md +81 -0
  181. package/skills/moonbeam-actor-challenger/SKILL.md +62 -0
  182. package/skills/moonbeam-actor-client/SKILL.md +67 -0
  183. package/skills/moonbeam-actor-doubter/SKILL.md +55 -0
  184. package/skills/moonbeam-actor-evaluator/SKILL.md +67 -0
  185. package/skills/moonbeam-actor-provider/SKILL.md +63 -0
  186. package/skills/moonbeam-assurance/SKILL.md +58 -0
@@ -0,0 +1,74 @@
1
+ [
2
+ {
3
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
4
+ "topics": [
5
+ "0xb0f0239bfdd96453e24733e18bfc24b70d8fadf123dd977473518dd577ee79b9",
6
+ "0x000000000000000000000000000000000000000000000000000000000001248b",
7
+ "0x0000000000000000000000004f120b736ecdef6f7b1ec9ed5b437206d0b14f17",
8
+ "0x0000000000000000000000009f06a199208d680ef329eb87379943b496f3a0e0"
9
+ ],
10
+ "data": "0x0000000000000000000000004f120b736ecdef6f7b1ec9ed5b437206d0b14f17000000000000000000000000000000000000000000000000000000006a8c61a10000000000000000000000000000000000000000000000000000000000000000",
11
+ "blockNumber": "0x300fee0",
12
+ "transactionHash": "0xbb6e73a485979842e92781931f5214efc09f275e6272ce634460b3268753d907",
13
+ "logIndex": "0x5c"
14
+ },
15
+ {
16
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
17
+ "topics": [
18
+ "0x869e2577b006bf47ee981cf6fec2e25583548081c14b98deab587f77b5068038",
19
+ "0x000000000000000000000000000000000000000000000000000000000001248b"
20
+ ],
21
+ "data": "0x00000000000000000000000000000000000000000000000000000000000493e0",
22
+ "blockNumber": "0x300fee7",
23
+ "transactionHash": "0x05a0dff833e8ab1a0b224027a663d0a58bbffc5df1fdb3c74fcfbd605a49c671",
24
+ "logIndex": "0x4d"
25
+ },
26
+ {
27
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
28
+ "topics": [
29
+ "0xe3fbcc1ea1bdc559ec7f0347efde7655e58b5f45a30b0e4470a583c3ef5496b3",
30
+ "0x000000000000000000000000000000000000000000000000000000000001248b",
31
+ "0x0000000000000000000000004f120b736ecdef6f7b1ec9ed5b437206d0b14f17"
32
+ ],
33
+ "data": "0x00000000000000000000000000000000000000000000000000000000000493e0",
34
+ "blockNumber": "0x300ff1e",
35
+ "transactionHash": "0x4e535a82369eb937755d6536e3d992eae5d7b03ec798ed586e3b8d9b4f661a49",
36
+ "logIndex": "0x89"
37
+ },
38
+ {
39
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
40
+ "topics": [
41
+ "0x80c17db79857f338a6a6df68a6883ecc0ce78e2202fe61ed979733573f40538e",
42
+ "0x000000000000000000000000000000000000000000000000000000000001248b",
43
+ "0x0000000000000000000000009f06a199208d680ef329eb87379943b496f3a0e0"
44
+ ],
45
+ "data": "0x1e3e5c8d5de3f2cb2de72fb1b79b9f996b55d640cf9d31d773ca8f1637105a2a",
46
+ "blockNumber": "0x300ff32",
47
+ "transactionHash": "0xd24da59517240c0de50399d9f97b708d31f1239c428a638307b15898fa7cea81",
48
+ "logIndex": "0x64"
49
+ },
50
+ {
51
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
52
+ "topics": [
53
+ "0x7ca5472b7ea78c2c0141c5a12ee6d170cf4ce8ed06be3d22c8252ddfc7a6a2c4",
54
+ "0x000000000000000000000000000000000000000000000000000000000001248b",
55
+ "0x0000000000000000000000004f120b736ecdef6f7b1ec9ed5b437206d0b14f17"
56
+ ],
57
+ "data": "0x00000000000000000000000000000000000000000000000000000000000493e0",
58
+ "blockNumber": "0x3010226",
59
+ "transactionHash": "0x1b04674979a4536661f436abb49b7fbc1e38dffa13dce3f50d9bcfef756d6452",
60
+ "logIndex": "0x3c5"
61
+ },
62
+ {
63
+ "address": "0x238e541bfefd82238730d00a2208e5497f1832e0",
64
+ "topics": [
65
+ "0xae7362b1af91f4492868987b9c73990d780060811551b58728fbe96fd1bab275",
66
+ "0x000000000000000000000000000000000000000000000000000000000001248b",
67
+ "0x0000000000000000000000004f120b736ecdef6f7b1ec9ed5b437206d0b14f17"
68
+ ],
69
+ "data": "0x9aa5717893e28fc5572bf05d83054d923cce76dc2633e725ffa11509348c5836",
70
+ "blockNumber": "0x3010226",
71
+ "transactionHash": "0x1b04674979a4536661f436abb49b7fbc1e38dffa13dce3f50d9bcfef756d6452",
72
+ "logIndex": "0x3c6"
73
+ }
74
+ ]
package/package.json ADDED
@@ -0,0 +1,124 @@
1
+ {
2
+ "name": "@moonbeam-foundation/sdk",
3
+ "version": "0.5.2",
4
+ "description": "Assurance for agent work: wrap a job in a price, a judge and a deadline, and settle it against proof.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./acp": {
16
+ "types": "./dist/acp/events.d.ts",
17
+ "import": "./dist/acp/events.js"
18
+ },
19
+ "./actors": {
20
+ "types": "./dist/actors/index.d.ts",
21
+ "import": "./dist/actors/index.js"
22
+ },
23
+ "./adapters/acp": {
24
+ "types": "./dist/adapters/acp.d.ts",
25
+ "import": "./dist/adapters/acp.js"
26
+ },
27
+ "./connect": {
28
+ "types": "./dist/connect/http.d.ts",
29
+ "import": "./dist/connect/http.js"
30
+ },
31
+ "./client": {
32
+ "types": "./dist/client/index.d.ts",
33
+ "import": "./dist/client/index.js"
34
+ },
35
+ "./launcher": {
36
+ "types": "./dist/launcher/index.d.ts",
37
+ "import": "./dist/launcher/index.js"
38
+ },
39
+ "./adapters/stamp": {
40
+ "types": "./dist/adapters/stamp.d.ts",
41
+ "import": "./dist/adapters/stamp.js"
42
+ },
43
+ "./onboard": {
44
+ "types": "./dist/onboard/index.d.ts",
45
+ "import": "./dist/onboard/index.js"
46
+ },
47
+ "./pools": {
48
+ "types": "./dist/pools/index.d.ts",
49
+ "import": "./dist/pools/index.js"
50
+ },
51
+ "./judge": {
52
+ "types": "./dist/judge/index.d.ts",
53
+ "import": "./dist/judge/index.js"
54
+ },
55
+ "./package.json": "./package.json"
56
+ },
57
+ "files": [
58
+ "dist",
59
+ "skills",
60
+ "README.md",
61
+ "LICENSE",
62
+ "bin",
63
+ "examples",
64
+ "docs"
65
+ ],
66
+ "sideEffects": false,
67
+ "engines": {
68
+ "node": ">=20"
69
+ },
70
+ "scripts": {
71
+ "build": "tsc -p tsconfig.build.json",
72
+ "typecheck": "tsc --noEmit",
73
+ "test": "vitest run",
74
+ "test:watch": "vitest",
75
+ "test:coverage": "vitest run --coverage",
76
+ "lint": "tsc --noEmit && vitest run --reporter=dot",
77
+ "prepublishOnly": "npm run build && npm test"
78
+ },
79
+ "keywords": [
80
+ "moonbeam",
81
+ "assurance",
82
+ "escrow",
83
+ "ai-agents",
84
+ "agent-commerce-protocol",
85
+ "acp",
86
+ "settlement",
87
+ "base",
88
+ "agent-economy",
89
+ "escrow-settlement",
90
+ "ai-agent-skills",
91
+ "jev",
92
+ "judge",
93
+ "erc-8183"
94
+ ],
95
+ "devDependencies": {
96
+ "@types/node": "^22.20.0",
97
+ "@vitest/coverage-v8": "^4.1.8",
98
+ "typescript": "^5.7.3",
99
+ "viem": "^2.55.19",
100
+ "vitest": "^4.1.8"
101
+ },
102
+ "dependencies": {
103
+ "@taifoon/jev": "^0.2.13",
104
+ "@taifoon/jev-wilson": "^0.2.0",
105
+ "@taifoon/n8n-nodes-typesafe": "^2.0.4"
106
+ },
107
+ "bin": {
108
+ "moonbeam": "bin/moonbeam.mjs"
109
+ },
110
+ "repository": {
111
+ "type": "git",
112
+ "url": "git+https://github.com/moonbeam-foundation/moonbeam-sdk.git"
113
+ },
114
+ "homepage": "https://github.com/moonbeam-foundation/moonbeam-sdk#readme",
115
+ "publishConfig": {
116
+ "access": "public",
117
+ "registry": "https://registry.npmjs.org"
118
+ },
119
+ "bugs": {
120
+ "url": "https://github.com/moonbeam-foundation/moonbeam-sdk/issues",
121
+ "email": "builders@moonbeam.foundation"
122
+ },
123
+ "author": "Moonbeam Foundation <builders@moonbeam.foundation>"
124
+ }
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: moonbeam-acp-decoding
3
+ description: Decode on-chain agent-commerce event logs into typed job state and a settlement verdict. Use when reading agent-job logs from Base, asking what a job's outcome was, mapping a close reason to a verdict, correlating a dispute with its adjudication, measuring how many jobs had an independent grader, or wiring an RPC log stream into settlement. Covers decodeAcpLog, foldTask, toOutcome, attributeDispute, independentShare.
4
+ ---
5
+
6
+ # Decoding agent-commerce traffic
7
+
8
+ ```ts
9
+ import { decodeAcpLogs, foldTask, toOutcome, localClock } from '@moonbeam-foundation/sdk';
10
+
11
+ const state = foldTask(decodeAcpLogs(logs)); // logs for ONE job
12
+ const outcome = toOutcome(state, localClock(now));
13
+ ```
14
+
15
+ `decodeAcpLog` returns `null` for anything unrecognised and never throws — most
16
+ logs in a block are not agent-commerce events, so "not mine" is the ordinary
17
+ answer. Decoding is keyed on topic0 and is address-agnostic, so it survives
18
+ redeployment.
19
+
20
+ ## Three traps
21
+
22
+ **1. A close reason of "adjudicated" is not a verdict.** It says an arbitrator
23
+ decided, not *for whom*. You must find the paired `adjudicated` event carrying
24
+ the winner. `toOutcome` returns `{ verdict: null, pending:
25
+ 'adjudicationWinnerUnknown' }` rather than guessing.
26
+
27
+ **2. `Disputed` is ambiguous by construction.** Two different contracts declare
28
+ an identical `Disputed(bytes32,address)`, so they share a topic0 and cannot be
29
+ told apart from the log alone. The decoder reports `source: 'ambiguous'`.
30
+ Narrow it only with a known emitting address:
31
+
32
+ ```ts
33
+ attributeDispute(log, { taskSpace, escrow }); // 'taskSpace' | 'escrow' | 'ambiguous'
34
+ ```
35
+
36
+ **3. A release is weaker than a verdict.** Release is called by the *buyer*, not
37
+ a judge (`basis: 'requesterReleased'`). It means the buyer declared satisfaction
38
+ — enough that no cover is owed, but it is not an adjudicated finding. Do not
39
+ describe it as one.
40
+
41
+ ## Verdicts, and when there is none
42
+
43
+ | Fact | Result |
44
+ |---|---|
45
+ | approved / completed | `doneRight` |
46
+ | rejected | `rejected` — refund, no damage cover |
47
+ | expired / refunded on timeout | `notDelivered` |
48
+ | adjudicated for the provider | `doneRight` |
49
+ | adjudicated for the client | `cheated` — the only verdict cover pays on |
50
+ | dispute open | `null`, `pending: 'awaitingAdjudication'` |
51
+ | deadline passed, nothing claimed | `null`, `pending: 'refundClaimable'` |
52
+
53
+ Refunds are **claimable, not automatic** — someone must call for them, so money
54
+ sits locked until they do.
55
+
56
+ ## Measuring independent grading
57
+
58
+ ```ts
59
+ import { foldTasks, independentShare, findSelfGraded } from '@moonbeam-foundation/sdk';
60
+
61
+ const states = foldTasks(decodeAcpLogs(logs));
62
+ independentShare(states); // fraction graded by a genuine third party
63
+ findSelfGraded(states); // graded by the payer, or ungraded entirely
64
+ ```
65
+
66
+ `verification` is `'none'` (no grader), `'self'` (the payer graded its own job),
67
+ or `'independent'`. On live traffic the independent share is very small — which
68
+ is the gap an assurance layer exists to fill.
69
+
70
+ ## Order does not matter
71
+
72
+ `foldTask` is order-insensitive: statuses only advance, so a late-arriving early
73
+ event cannot rewind the state. Pass events for **one job only** — use
74
+ `groupByJob` or `foldTasks` to split a mixed stream.
75
+
76
+ ## Do not claim
77
+
78
+ The assurance-side contracts are not deployed to mainnet. Decoding being
79
+ address-agnostic means it will work once addresses are published — that is a
80
+ property of the decoder, not evidence of deployment.
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: moonbeam-actor-backer
3
+ description: Back a Moonbeam coverage pool with GLMR (not open yet) — pool income, pool losses, exposure across concurrent jobs, break-even failure rate, and whether a published clearing fee is coherent. Use when the user wants to back a pool, underwrite agent work, asks what backing a pool pays or what it risks, asks about pool solvency or correlated failures, or asks whether a coverage fee is priced right. Covers runSeason, breakEvenFailureRate, poolExposure, solventUnder, clearingFeeIsCoherent. For the OTHER side of this trade — betting that a pool loses — see moonbeam-actor-doubter.
4
+ ---
5
+
6
+ # Backing a coverage pool
7
+
8
+ ## What you risk, first
9
+
10
+ Capital you put into a pool stands behind other people's work. When an adjudicator finds a
11
+ provider cheated, the provider's deposit is consumed first and **your pool pays
12
+ whatever the deposit cannot**. That is the risk, and it is not optional once you
13
+ have backed a pool — the exposure *is* the yield. There is no passive tier, because
14
+ rewards come from real fees rather than from newly minted tokens.
15
+
16
+ You are **not** charged when work is merely graded bad. A rejection refunds the
17
+ client and returns the deposit; the pool pays nothing.
18
+
19
+ ## What you earn
20
+
21
+ The premium on every job that completes, plus fees from doubters taking the
22
+ other side.
23
+
24
+ ```ts
25
+ import { runSeason, breakEvenFailureRate, parseUnits } from '@moonbeam-foundation/sdk';
26
+ const usdc = (v: string) => parseUnits(v);
27
+
28
+ // The deposit here is deliberately below the damage, so the pool is visibly
29
+ // exposed. That is the case worth reasoning about as a backer. When a bond is
30
+ // sized above the damage the residual is zero and the pool pays nothing, which
31
+ // is the intended steady state rather than the one you need to price.
32
+ runSeason({
33
+ jobs: 5_000,
34
+ premiumPerJob: usdc('1'),
35
+ failureRate: 0.006,
36
+ damagePerFailure: usdc('70'),
37
+ depositPerJob: usdc('40'),
38
+ });
39
+ // → premiumEarned 4_970, absorbedByDeposits 1_200, paidByPool 900, net +4_070
40
+ ```
41
+
42
+ ## The number that decides whether to back a pool at all
43
+
44
+ ```ts
45
+ breakEvenFailureRate(usdc('1'), usdc('70'), usdc('40')); // ≈ 0.032
46
+ ```
47
+
48
+ Above that failure rate the pool loses money. Compare it against what the market
49
+ is charging before committing:
50
+
51
+ ```ts
52
+ clearingFeeIsCoherent(34, usdc('1'), usdc('70'), usdc('40')); // false
53
+ ```
54
+
55
+ A clearing fee is the market's estimate of the failure rate it is insuring. If
56
+ that implies a rate far below your break-even, the cover is underpriced and you
57
+ are being paid too little for the risk. **Always run this check.**
58
+
59
+ ## Correlated failure — the question that actually ends pools
60
+
61
+ `runSeason` averages over a period and assumes failures are independent. They
62
+ are not: one bad provider fails many jobs at once.
63
+
64
+ ```ts
65
+ poolExposure(terms, 10, usdc('5000')); // { committed, utilisation, solvent }
66
+ solventUnder(usdc('100'), terms, 10); // false — 10 simultaneous failures break it
67
+ ```
68
+
69
+ ## House rules
70
+
71
+ - Exit is slower than claims settle, so you cannot withdraw ahead of a loss you
72
+ already agreed to cover.
73
+ - Caps start small and rise only as the pool's record grows.
74
+ - Read the pool's own rules before committing.
75
+
76
+ ## Do not claim
77
+
78
+ Pools are not open. They open no earlier than Q4 2026, once the escrow contracts are
79
+ on mainnet — gated, not scheduled.
80
+ No APY has been published and none should be quoted. Figures above are
81
+ illustrative, not a rate card. Nothing here is an offer or a promise of yield.
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: moonbeam-actor-challenger
3
+ description: Contest a single verdict on Moonbeam-insured work by posting a bond against it. Use when the user thinks a judge got one call wrong, wants to appeal or overturn a verdict, asks what challenging costs or pays, asks about the odds of a challenge being worth it, or wants to find jobs where the grader was the paying party. Covers challengeQuote, worthChallenging, findSelfGraded. For issuing verdicts rather than contesting them see moonbeam-actor-evaluator.
4
+ ---
5
+
6
+ # Challenging a verdict
7
+
8
+ ## What you risk, first
9
+
10
+ You post a bond against **one specific verdict**. If the challenge fails, the
11
+ bond is forfeited to the evaluator. A challenge is a bet, not an appeal.
12
+
13
+ ## The odds
14
+
15
+ ```ts
16
+ import { challengeQuote, worthChallenging, parseUnits } from '@moonbeam-foundation/sdk';
17
+ const usdc = (v: string) => parseUnits(v);
18
+
19
+ challengeQuote(terms, usdc('10'));
20
+ // { winAmount: 25, loseAmount: 10, breakEvenProbability: 0.2857 }
21
+
22
+ worthChallenging(terms, usdc('10'), 0.5); // true — 50% > 28.6%
23
+ worthChallenging(terms, usdc('10'), 0.1); // false
24
+ ```
25
+
26
+ You win the **evaluator's bond**, not the job's value. A larger bond does not
27
+ increase the payout — it only raises what you lose when wrong, so bonding more
28
+ than required strictly worsens your odds.
29
+
30
+ ## Finding challengeable work
31
+
32
+ The strongest signal is a job graded by the party who paid for it, or not graded
33
+ at all:
34
+
35
+ ```ts
36
+ import { foldTasks, findSelfGraded, independentShare, decodeAcpLogs } from '@moonbeam-foundation/sdk';
37
+
38
+ const states = foldTasks(decodeAcpLogs(logs));
39
+ findSelfGraded(states); // verification 'self' or 'none'
40
+ independentShare(states); // how much of the population had a real judge
41
+ ```
42
+
43
+ On live agent-commerce traffic, independently graded jobs are a tiny fraction of
44
+ the whole. That population is where an independent verdict would have had
45
+ something to say.
46
+
47
+ ## Timing
48
+
49
+ A challenge is only meaningful while the window is open. Check the job's state
50
+ first — `toOutcome` returning `pending: 'awaitingAdjudication'` means a dispute
51
+ is already raised and an arbitrator has yet to rule.
52
+
53
+ ```ts
54
+ import { toOutcome, recourseFor } from '@moonbeam-foundation/sdk';
55
+ recourseFor('challenger', state, clock).mine;
56
+ ```
57
+
58
+ ## Do not claim
59
+
60
+ Challenges are not live; they open **Q4 2026** at the earliest, alongside
61
+ custody. Bond sizes above are illustrative. A wrong challenge loses the bond in
62
+ full — never present challenging as risk-free, and this is not trading advice.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: moonbeam-actor-client
3
+ description: Buy cover for agent work as the client/buyer — what a premium costs, what is recovered when work fails, and the damage nobody covers. Use when the user is paying an agent for work, asks whether a job can be insured, asks what happens to their money if the agent fails or cheats, asks what a guarantee costs, or asks whether their deadline is safe. Covers quote, coverGap, recoveryFor, deadline status. For the other side of the job — doing the work under cover — see moonbeam-actor-provider; for selling the cover itself see moonbeam-actor-backer.
4
+ ---
5
+
6
+ # Buying cover for a job
7
+
8
+ ## What you risk, first
9
+
10
+ The premium is not returned when cover was not needed — that is the cost of the
11
+ guarantee. And cover is bounded: if a failure could cost you more than the
12
+ capital bonded to the job, the excess falls on you.
13
+
14
+ ## Check the gap before you rely on cover
15
+
16
+ ```ts
17
+ import { coverGap, recoveryFor, parseUnits } from '@moonbeam-foundation/sdk';
18
+ const usdc = (v: string) => parseUnits(v);
19
+
20
+ coverGap(terms); // damage - (deposit + poolCapital); 0 means fully covered
21
+ recoveryFor(terms); // what you actually receive if cheating is established
22
+ ```
23
+
24
+ `coverGap` is the number no escrow shows you before you commit. If it is above
25
+ zero, you are self-insuring the difference.
26
+
27
+ ## What each outcome means for you
28
+
29
+ | Outcome | You get |
30
+ |---|---|
31
+ | Work delivered | the work; premium spent |
32
+ | Nothing arrived | full refund |
33
+ | Graded bad | full refund — but no damage cover |
34
+ | Arbitrator finds against the provider | refund **plus** damage cover |
35
+
36
+ Note the third row. A rejection refunds you but does **not** pay for the
37
+ consequences of the failure. Damage cover requires an adjudication.
38
+
39
+ ## Can this job be insured at all?
40
+
41
+ ```ts
42
+ import { acpAdapter, DEFAULT_ACP_POLICY, isInsurable } from '@moonbeam-foundation/sdk';
43
+
44
+ isInsurable(job); // false → cannot be covered
45
+ acpAdapter.toTerms(job, DEFAULT_ACP_POLICY); // null for the same reason
46
+ ```
47
+
48
+ Declined when: unpriced, above the policy cap, past the point where the outcome
49
+ is already being decided, missing a signed agreement (nothing to grade against),
50
+ or missing a deadline (nothing resolves it if a grader goes silent).
51
+
52
+ ## You cannot be stranded
53
+
54
+ Past the deadline, the refund is **permissionless** — anyone can trigger it, so
55
+ you never need a silent provider's cooperation to get your money back.
56
+
57
+ ```ts
58
+ import { recourseFor, livenessOf } from '@moonbeam-foundation/sdk';
59
+ recourseFor('client', state, clock).guaranteedExit; // { id: 'claimRefund', by: 'anyone' }
60
+ ```
61
+
62
+ Refunds are *claimable*, not automatic — someone must call it.
63
+
64
+ ## Do not claim
65
+
66
+ Escrow is not deployed to mainnet, so no job can actually be insured today.
67
+ Figures are illustrative, not a rate card, and nothing here is an offer.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: moonbeam-actor-doubter
3
+ description: Size, price and evaluate a DOUBT position against a Moonbeam coverage pool — the bet that insured work fails. Use when the user wants to bet against a pool or a provider, short coverage, take the other side of a guarantee, size a doubt notional, ask whether doubting is worth the fee, or asks why a doubt payout is capped (the arson rule). Covers doubtQuote, maxDoubtPayout, sizeWithinCap. For the OTHER side of this trade — earning the fee by backing the work — see moonbeam-actor-backer.
4
+ ---
5
+
6
+ # Doubting a pool
7
+
8
+ ## What you risk, first
9
+
10
+ You pay the fee up front, every time, and you lose it whenever the work is
11
+ delivered. Doubt is a position that bleeds while nothing goes wrong.
12
+
13
+ ## Pricing a position
14
+
15
+ ```ts
16
+ import { doubtQuote, parseUnits } from '@moonbeam-foundation/sdk';
17
+ const usdc = (v: string) => parseUnits(v);
18
+
19
+ doubtQuote(terms, usdc('30'), 34);
20
+ // { fee: 0.102, maxPayout: 30, capped: false, breakEvenProbability: 0.0034 }
21
+ ```
22
+
23
+ `breakEvenProbability` is the failure rate at which the position is EV-neutral.
24
+ Take it only if you believe the real failure rate is higher than the fee implies.
25
+
26
+ ## The cap you must check before sizing
27
+
28
+ ```ts
29
+ doubtQuote(terms, usdc('9000'), 34).capped; // true
30
+ sizeWithinCap(terms, usdc('9000')); // false
31
+ maxDoubtPayout(terms); // 5040 = deposit + poolCapital
32
+ ```
33
+
34
+ **A doubt payout can never exceed the capital already bonded to the job.** Size
35
+ above that and you are paying a fee on notional that cannot pay out — the excess
36
+ is spent for nothing. Always check `capped` before committing.
37
+
38
+ ## Why the cap exists (the arson rule)
39
+
40
+ If doubt could pay more than the capital exposed, the profitable move would be
41
+ to bet against a job and then cause it to fail. The cap makes causing a failure
42
+ always cost more than betting on it can return. The rule protects you too: it is
43
+ why the market you are trading in is not simply a sabotage game.
44
+
45
+ ## When you get paid
46
+
47
+ Only on `cheated` — an arbitrator finding against the provider. Note what this
48
+ excludes: a job that is merely **graded bad** settles as `rejected` and pays
49
+ doubters nothing. Do not model rejections as wins.
50
+
51
+ ## Do not claim
52
+
53
+ Doubt positions are not live; coverage auctions open **Q2 2027** at the earliest.
54
+ No fee schedule has been published — the 34bps used above is illustrative, not a
55
+ rate card. Nothing here is an offer, and this is not trading advice.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: moonbeam-actor-evaluator
3
+ description: Act as a judge/evaluator on Moonbeam-insured agent work — when a proof is required, what a bond risks, and how a verdict can be overturned. Use when the user is grading agent work, running an evaluator, asking whether approving needs proof, asking what happens if a judge is wrong or goes silent, or asking why a rejection does not pay damage cover. Covers proofRequiredFor, bondAtRisk, toOutcome. For contesting someone else's verdict see moonbeam-actor-challenger.
4
+ ---
5
+
6
+ # Judging agent work
7
+
8
+ ## What you risk, first
9
+
10
+ You post a bond to issue verdicts at all. If your call is overturned on
11
+ challenge, **the bond pays the challenger**. Going silent is not an escape:
12
+ the deadline resolves the job without you, and no work waits on a silent grader.
13
+
14
+ ## The one rule that must never be inverted
15
+
16
+ **Refusing to pay is safe. Paying requires proof.**
17
+
18
+ ```ts
19
+ import { proofRequiredFor } from '@moonbeam-foundation/sdk';
20
+ proofRequiredFor('approve'); // true — releasing someone else's money needs proof
21
+ proofRequiredFor('reject'); // false — refusal costs no one anything
22
+ ```
23
+
24
+ Approving releases funds that are not yours, so it must be backed by a proof
25
+ that verifies. Rejecting only withholds, so it never needs one. If a proof fails
26
+ to verify, the approval must fail too — an unproven deliverable can never
27
+ auto-complete.
28
+
29
+ **Absence of proof is not evidence of absence.** If the proof service is
30
+ unreachable, that is *unknown*, not *no proof exists* — and unknown must never
31
+ authorise payment.
32
+
33
+ ## Your rejection does not charge the pool
34
+
35
+ A rejection settles as `rejected`: the client is refunded, the provider's
36
+ deposit is returned, and the coverage pool pays **nothing**. That is deliberate.
37
+ Because rejecting is free and unproven, letting it trigger damage cover would
38
+ make pools underwrite ordinary quality disputes rather than dishonesty.
39
+
40
+ Damage cover pays only on `cheated`, which comes from an arbitrator — a neutral
41
+ party — finding against the provider. You cannot produce that verdict alone.
42
+
43
+ Your calls are contestable: anyone may bond against one of them, and an
44
+ overturned call pays them from your bond. See `moonbeam-actor-challenger` for
45
+ that side.
46
+
47
+ ## Reading where a job stands
48
+
49
+ ```ts
50
+ import { foldTask, toOutcome, decodeAcpLogs, localClock } from '@moonbeam-foundation/sdk';
51
+
52
+ const state = foldTask(decodeAcpLogs(logs));
53
+ toOutcome(state, localClock(now));
54
+ // { verdict: 'rejected', basis: 'evaluatorRejected' }
55
+ // or { verdict: null, pending: 'awaitingAdjudication' }
56
+ ```
57
+
58
+ `toOutcome` returns `verdict: null` whenever the chain has not actually settled
59
+ the question — a raised dispute, or a close marked "adjudicated" without a named
60
+ winner. Never treat a pending outcome as a verdict.
61
+
62
+ ## Do not claim
63
+
64
+ Evaluator contracts are live on **test networks only**; nothing is deployed to
65
+ mainnet. A proof-checking evaluator *narrows* what must be trusted; it does not
66
+ remove trust, so never describe one as requiring no trust at all. Figures are
67
+ illustrative.
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: moonbeam-actor-provider
3
+ description: Take insured agent work as the provider/seller — the deposit required, what a rejection costs versus an adjudicated finding, and how to avoid being stranded by a silent buyer. Use when the user is doing paid agent work, asks what bond is needed to accept an insured job, asks what happens if the buyer never releases payment or the evaluator rejects, or asks whether they can afford to take a job. Covers capitalRequired, canAccept, positionsByVerdict, recourseFor. For buying the cover rather than working under it see moonbeam-actor-client.
4
+ ---
5
+
6
+ # Taking insured work
7
+
8
+ ## What you risk, first
9
+
10
+ You post a deposit to take insured work at all, and it is the **first** capital
11
+ consumed if an arbitrator finds you cheated. Your own money is what makes your
12
+ promise worth anything.
13
+
14
+ ## Can you afford this job?
15
+
16
+ ```ts
17
+ import { capitalRequired, canAccept, parseUnits } from '@moonbeam-foundation/sdk';
18
+ const usdc = (v: string) => parseUnits(v);
19
+
20
+ capitalRequired(terms); // exactly the deposit
21
+ canAccept(terms, freeCapital); // { ok: false, reason: '...' } when it does not fit
22
+ ```
23
+
24
+ `canAccept` returns a reason rather than a bare false, so a refusal can be
25
+ reported rather than guessed at.
26
+
27
+ ## What each outcome costs you
28
+
29
+ ```ts
30
+ positionsByVerdict('provider', terms);
31
+ // { doneRight: +100, notDelivered: 0, rejected: 0, cheated: -40 }
32
+ ```
33
+
34
+ The important row is `rejected: 0`. Being **graded bad costs you nothing beyond
35
+ the job** — your deposit comes back. You only forfeit it when a neutral
36
+ arbitrator finds against you. Do not treat a rejection as a slashing event.
37
+
38
+ ## A silent buyer cannot strand you
39
+
40
+ Only the buyer can call release, so a buyer who simply stops responding could
41
+ otherwise sit on delivered work forever. Your escape is to escalate:
42
+
43
+ ```ts
44
+ import { recourseFor, waitingOn } from '@moonbeam-foundation/sdk';
45
+
46
+ waitingOn(state, clock); // who is holding this up
47
+ recourseFor('provider', state, clock).mine; // includes { id: 'dispute' }
48
+ ```
49
+
50
+ Either party may raise a dispute, which freezes the escrow and forces an
51
+ arbitrator to decide. You never have to wait indefinitely on someone else's
52
+ cooperation.
53
+
54
+ ## Getting paid
55
+
56
+ Payment releases against **proof of the work**, not a status report. An
57
+ evaluator cannot approve without a proof that verifies — which cuts both ways:
58
+ it is a bar to clear, and it is also why an approval cannot later be waved away.
59
+
60
+ ## Do not claim
61
+
62
+ Escrow is not deployed to mainnet; no insured work can be taken today. Deposit
63
+ ratios are illustrative policy defaults, not fixed protocol parameters.