@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.
- package/LICENSE +17 -0
- package/README.md +378 -0
- package/bin/moonbeam.mjs +56 -0
- package/dist/acp/coverage.d.ts +36 -0
- package/dist/acp/coverage.d.ts.map +1 -0
- package/dist/acp/coverage.js +51 -0
- package/dist/acp/coverage.js.map +1 -0
- package/dist/acp/events.d.ts +201 -0
- package/dist/acp/events.d.ts.map +1 -0
- package/dist/acp/events.js +201 -0
- package/dist/acp/events.js.map +1 -0
- package/dist/acp/hex.d.ts +29 -0
- package/dist/acp/hex.d.ts.map +1 -0
- package/dist/acp/hex.js +51 -0
- package/dist/acp/hex.js.map +1 -0
- package/dist/acp/lifecycle-types.d.ts +11 -0
- package/dist/acp/lifecycle-types.d.ts.map +1 -0
- package/dist/acp/lifecycle-types.js +8 -0
- package/dist/acp/lifecycle-types.js.map +1 -0
- package/dist/acp/lifecycle.d.ts +78 -0
- package/dist/acp/lifecycle.d.ts.map +1 -0
- package/dist/acp/lifecycle.js +224 -0
- package/dist/acp/lifecycle.js.map +1 -0
- package/dist/acp/outcome.d.ts +45 -0
- package/dist/acp/outcome.d.ts.map +1 -0
- package/dist/acp/outcome.js +104 -0
- package/dist/acp/outcome.js.map +1 -0
- package/dist/acp/pipeline.d.ts +30 -0
- package/dist/acp/pipeline.d.ts.map +1 -0
- package/dist/acp/pipeline.js +25 -0
- package/dist/acp/pipeline.js.map +1 -0
- package/dist/acp/recourse.d.ts +74 -0
- package/dist/acp/recourse.d.ts.map +1 -0
- package/dist/acp/recourse.js +234 -0
- package/dist/acp/recourse.js.map +1 -0
- package/dist/acp/registry.d.ts +62 -0
- package/dist/acp/registry.d.ts.map +1 -0
- package/dist/acp/registry.js +86 -0
- package/dist/acp/registry.js.map +1 -0
- package/dist/acp/transitions.d.ts +82 -0
- package/dist/acp/transitions.d.ts.map +1 -0
- package/dist/acp/transitions.js +106 -0
- package/dist/acp/transitions.js.map +1 -0
- package/dist/actors/index.d.ts +84 -0
- package/dist/actors/index.d.ts.map +1 -0
- package/dist/actors/index.js +133 -0
- package/dist/actors/index.js.map +1 -0
- package/dist/actors/track-record.d.ts +79 -0
- package/dist/actors/track-record.d.ts.map +1 -0
- package/dist/actors/track-record.js +105 -0
- package/dist/actors/track-record.js.map +1 -0
- package/dist/adapters/acp.d.ts +48 -0
- package/dist/adapters/acp.d.ts.map +1 -0
- package/dist/adapters/acp.js +74 -0
- package/dist/adapters/acp.js.map +1 -0
- package/dist/adapters/port.d.ts +53 -0
- package/dist/adapters/port.d.ts.map +1 -0
- package/dist/adapters/port.js +2 -0
- package/dist/adapters/port.js.map +1 -0
- package/dist/adapters/stamp.d.ts +57 -0
- package/dist/adapters/stamp.d.ts.map +1 -0
- package/dist/adapters/stamp.js +114 -0
- package/dist/adapters/stamp.js.map +1 -0
- package/dist/client/index.d.ts +123 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +78 -0
- package/dist/client/index.js.map +1 -0
- package/dist/connect/attestation.d.ts +64 -0
- package/dist/connect/attestation.d.ts.map +1 -0
- package/dist/connect/attestation.js +62 -0
- package/dist/connect/attestation.js.map +1 -0
- package/dist/connect/http.d.ts +36 -0
- package/dist/connect/http.d.ts.map +1 -0
- package/dist/connect/http.js +51 -0
- package/dist/connect/http.js.map +1 -0
- package/dist/connect/logs.d.ts +53 -0
- package/dist/connect/logs.d.ts.map +1 -0
- package/dist/connect/logs.js +42 -0
- package/dist/connect/logs.js.map +1 -0
- package/dist/connect/result.d.ts +49 -0
- package/dist/connect/result.d.ts.map +1 -0
- package/dist/connect/result.js +41 -0
- package/dist/connect/result.js.map +1 -0
- package/dist/core/actors.d.ts +13 -0
- package/dist/core/actors.d.ts.map +1 -0
- package/dist/core/actors.js +57 -0
- package/dist/core/actors.js.map +1 -0
- package/dist/core/clock.d.ts +55 -0
- package/dist/core/clock.d.ts.map +1 -0
- package/dist/core/clock.js +36 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/money.d.ts +32 -0
- package/dist/core/money.d.ts.map +1 -0
- package/dist/core/money.js +57 -0
- package/dist/core/money.js.map +1 -0
- package/dist/core/pool.d.ts +71 -0
- package/dist/core/pool.d.ts.map +1 -0
- package/dist/core/pool.js +98 -0
- package/dist/core/pool.js.map +1 -0
- package/dist/core/settle.d.ts +50 -0
- package/dist/core/settle.d.ts.map +1 -0
- package/dist/core/settle.js +175 -0
- package/dist/core/settle.js.map +1 -0
- package/dist/core/types.d.ts +109 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/erc8004/index.d.ts +94 -0
- package/dist/erc8004/index.d.ts.map +1 -0
- package/dist/erc8004/index.js +118 -0
- package/dist/erc8004/index.js.map +1 -0
- package/dist/erc8004/registry.generated.d.ts +17 -0
- package/dist/erc8004/registry.generated.d.ts.map +1 -0
- package/dist/erc8004/registry.generated.js +20 -0
- package/dist/erc8004/registry.generated.js.map +1 -0
- package/dist/erc8183/index.d.ts +114 -0
- package/dist/erc8183/index.d.ts.map +1 -0
- package/dist/erc8183/index.js +109 -0
- package/dist/erc8183/index.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/judge/index.d.ts +64 -0
- package/dist/judge/index.d.ts.map +1 -0
- package/dist/judge/index.js +64 -0
- package/dist/judge/index.js.map +1 -0
- package/dist/launcher/index.d.ts +109 -0
- package/dist/launcher/index.d.ts.map +1 -0
- package/dist/launcher/index.js +144 -0
- package/dist/launcher/index.js.map +1 -0
- package/dist/negotiate/index.d.ts +166 -0
- package/dist/negotiate/index.d.ts.map +1 -0
- package/dist/negotiate/index.js +150 -0
- package/dist/negotiate/index.js.map +1 -0
- package/dist/onboard/index.d.ts +533 -0
- package/dist/onboard/index.d.ts.map +1 -0
- package/dist/onboard/index.js +509 -0
- package/dist/onboard/index.js.map +1 -0
- package/dist/onboarding/index.d.ts +177 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +390 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/pools/index.d.ts +191 -0
- package/dist/pools/index.d.ts.map +1 -0
- package/dist/pools/index.js +244 -0
- package/dist/pools/index.js.map +1 -0
- package/docs/demo.gif +0 -0
- package/docs/demo.tape +14 -0
- package/examples/01-settle-a-covered-job.mjs +18 -0
- package/examples/02-negotiate-a-hire.mjs +21 -0
- package/examples/03-end-to-end-offline.mjs +27 -0
- package/examples/10-grade-evidence.mjs +12 -0
- package/examples/11-grade-facts.mjs +10 -0
- package/examples/12-grade-answers.mjs +8 -0
- package/examples/13-grade-verdict.mjs +10 -0
- package/examples/14-grade-record.mjs +11 -0
- package/examples/15-grade-end-the-job.mjs +11 -0
- package/examples/16-grade-verify.mjs +9 -0
- package/examples/17-grade-live.mjs +14 -0
- package/examples/20-onboard-client.mjs +8 -0
- package/examples/21-onboard-provider.mjs +9 -0
- package/examples/22-onboard-evaluator.mjs +7 -0
- package/examples/23-onboard-backer.mjs +8 -0
- package/examples/30-read-a-real-job.mjs +19 -0
- package/examples/31-read-the-ending.mjs +15 -0
- package/examples/32-read-live-from-base.mjs +33 -0
- package/examples/33-read-many-jobs.mjs +12 -0
- package/examples/40-the-article.mjs +78 -0
- package/examples/README.md +93 -0
- package/examples/data/answers.mjs +8 -0
- package/examples/data/base-grade.recorded.json +72 -0
- package/examples/data/pilot-grade.recorded.json +78 -0
- package/examples/data/pilot-hire.json +35 -0
- package/examples/data/terms.mjs +11 -0
- package/examples/data/virtuals-job-74926.json +74 -0
- package/examples/data/virtuals-job-rejected.json +74 -0
- package/package.json +124 -0
- package/skills/moonbeam-acp-decoding/SKILL.md +80 -0
- package/skills/moonbeam-actor-backer/SKILL.md +81 -0
- package/skills/moonbeam-actor-challenger/SKILL.md +62 -0
- package/skills/moonbeam-actor-client/SKILL.md +67 -0
- package/skills/moonbeam-actor-doubter/SKILL.md +55 -0
- package/skills/moonbeam-actor-evaluator/SKILL.md +67 -0
- package/skills/moonbeam-actor-provider/SKILL.md +63 -0
- package/skills/moonbeam-assurance/SKILL.md +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Moonbeam Foundation
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# @moonbeam-foundation/sdk
|
|
2
|
+
|
|
3
|
+
**Assurance for AI agent work: a price, a judge and a deadline, settled against proof.**
|
|
4
|
+
|
|
5
|
+
- **What:** the SDK for Moonbeam's assurance layer on Base. It models a covered job end to end: the seller's deposit,
|
|
6
|
+
the buyer's premium, cover from a GLMR pool, the verdict, and a settlement in which every ledger sums to zero.
|
|
7
|
+
- **Why:** agent escrow refunds the price of a failed job, never the cost of the failure, and the judge has no capital
|
|
8
|
+
behind its verdict. Moonbeam adds the deposit, the pool and a grader (Jev by TypeSafe).
|
|
9
|
+
- **How:** `npm install @moonbeam-foundation/sdk`, then replay Moonbeam's first covered hire on Base, offline, in a few seconds:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx moonbeam demo
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
> Moonbeam ACP is a pilot with selected partners on Base. The contracts are source-verified, and the GLMR pools are
|
|
18
|
+
> not open yet. Nothing here is an offer or a promise of yield, and nothing in this package signs a transaction.
|
|
19
|
+
> Building on Moonbeam and want early access? Write to [builders@moonbeam.foundation](mailto:builders@moonbeam.foundation).
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @moonbeam-foundation/sdk
|
|
25
|
+
npx moonbeam demo
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Node 20 or later.
|
|
29
|
+
|
|
30
|
+
## What problem this solves
|
|
31
|
+
|
|
32
|
+
Agent-to-agent protocols already hold payment in escrow and release it when an
|
|
33
|
+
evaluator approves. If the provider misses the deadline, escrow refunds the
|
|
34
|
+
buyer. That covers the *price of the job*.
|
|
35
|
+
|
|
36
|
+
It does not cover the *cost of the failure* — the campaign that missed its slot,
|
|
37
|
+
the fill that never happened — and it leaves the evaluator with no capital
|
|
38
|
+
behind its verdict. This SDK models the layer that closes both gaps.
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { settle, parseUnits } from '@moonbeam-foundation/sdk';
|
|
44
|
+
|
|
45
|
+
const usdc = (v: string) => parseUnits(v); // USDC has 6 decimals
|
|
46
|
+
|
|
47
|
+
const { ledger, locked } = settle({
|
|
48
|
+
terms: {
|
|
49
|
+
pay: usdc('100'), // what the client pays for the work
|
|
50
|
+
premium: usdc('1'), // what it pays for cover
|
|
51
|
+
deposit: usdc('120'), // the provider's bond, sized above the job
|
|
52
|
+
evaluatorBond: usdc('25'), // the judge's bond
|
|
53
|
+
poolCapital: usdc('5000'), // backers standing behind the provider
|
|
54
|
+
damage: usdc('70'), // consequential loss if the work is bad
|
|
55
|
+
},
|
|
56
|
+
verdict: 'cheated',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
locked; // 221_000000n — pay + premium + deposit, derived not typed
|
|
60
|
+
ledger.client; // +70_000000n — refunded AND compensated
|
|
61
|
+
ledger.provider; // -70_000000n — pays the damage out of its own bond
|
|
62
|
+
ledger.pool; // 0n — the bond covered it; the pool is the tail
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Positive is received, negative is paid, and every settlement sums to zero.
|
|
66
|
+
|
|
67
|
+
The deposit is sized above the job on purpose. Cheating has to cost the
|
|
68
|
+
provider more than the job pays, or the arithmetic argues for cheating; and
|
|
69
|
+
because the bond is first loss, the pool pays only the residual a bond cannot
|
|
70
|
+
cover. Drop the deposit to `40` here and the pool pays `30` on this single
|
|
71
|
+
job, which is the shape a flat premium cannot fund at realistic failure rates.
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
Nineteen runnable files in [`examples/`](examples), all offline except two, built on real Base jobs. `npm test` runs them.
|
|
76
|
+
|
|
77
|
+
| Start with | If you are |
|
|
78
|
+
|---|---|
|
|
79
|
+
| [`03-end-to-end-offline`](examples/03-end-to-end-offline.mjs) | new here: one real job read from Base, graded, settled |
|
|
80
|
+
| [`20`–`23` onboarding](examples/README.md#before-you-take-part) | about to pay, work, judge or back: what you put up, what you can lose, what should stop you |
|
|
81
|
+
| [`10`–`17` the grader](examples/README.md#the-grader-stage-by-stage) | judging jobs: evidence → facts → answers → verdict → record → end the job → verify, then live |
|
|
82
|
+
| [`30`–`33` reading jobs](examples/README.md#reading-jobs-that-already-ran) | studying jobs that already ran, one or many, offline or from a Base RPC |
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
node examples/03-end-to-end-offline.mjs
|
|
86
|
+
# 1 read the chain says: doneRight (judged by: self)
|
|
87
|
+
# 2 grade an independent grader says: complete · re-verifies: true
|
|
88
|
+
# 3 settle client -101 · provider +100 · pool +1 · sums to zero
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## The four outcomes
|
|
92
|
+
|
|
93
|
+
| Verdict | What happens |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `doneRight` | Provider is paid and gets its deposit back; the pool keeps the premium. |
|
|
96
|
+
| `notDelivered` | Nothing arrived. Everything unwinds, nobody punished. |
|
|
97
|
+
| `rejected` | Work arrived and was graded bad. Refund and deposit returned — **no damage cover**. |
|
|
98
|
+
| `cheated` | Client is made whole *beyond* a refund — from the provider's deposit first, then the pool. |
|
|
99
|
+
|
|
100
|
+
The last two rows carry the design's most important distinction. Refusing to pay
|
|
101
|
+
costs an evaluator nothing and requires no proof, so rejections are ordinary
|
|
102
|
+
events rather than evidence of fraud. If every rejection paid damage cover, a
|
|
103
|
+
pool would be underwriting quality disputes and its losses would track the
|
|
104
|
+
rejection rate rather than the fraud rate. So `cheated` — the only verdict that
|
|
105
|
+
draws on the deposit and the pool — is reserved for an adjudication by a neutral
|
|
106
|
+
party.
|
|
107
|
+
|
|
108
|
+
That is what makes **cheating pay the victim**: being cheated is the client's
|
|
109
|
+
best financial outcome after the fact, and every unit paid out comes from someone
|
|
110
|
+
who did wrong or who sold cover, never from an uninvolved party.
|
|
111
|
+
|
|
112
|
+
## Reading the chain
|
|
113
|
+
|
|
114
|
+
Decode agent-commerce logs into typed events, fold them into job state, and ask
|
|
115
|
+
what actually settled:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { decodeAcpLogs, foldTask, toOutcome, localClock } from '@moonbeam-foundation/sdk';
|
|
119
|
+
|
|
120
|
+
const state = foldTask(decodeAcpLogs(logs)); // one job's logs
|
|
121
|
+
const outcome = toOutcome(state, localClock(now));
|
|
122
|
+
// { verdict: 'cheated', basis: 'adjudicatedForClient' }
|
|
123
|
+
// or { verdict: null, pending: 'awaitingAdjudication' }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`toOutcome` returns no verdict whenever the chain has not settled the question —
|
|
127
|
+
a raised dispute, or a close marked "adjudicated" with no named winner. It
|
|
128
|
+
refuses to guess, because a verdict moves money.
|
|
129
|
+
|
|
130
|
+
Decoding is keyed on topic0 and address-agnostic, so it survives redeployment.
|
|
131
|
+
Every pinned constant is re-derived from its signature in the test suite, so a
|
|
132
|
+
typo cannot silently fail to match live traffic. One event is genuinely
|
|
133
|
+
ambiguous — two contracts declare an identical `Disputed` signature — and the
|
|
134
|
+
decoder reports `source: 'ambiguous'` rather than guessing.
|
|
135
|
+
|
|
136
|
+
## Nobody can be locked out
|
|
137
|
+
|
|
138
|
+
A job holds other people's money, so no party may strand another by going quiet:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { livenessOf, recourseFor, waitingOn } from '@moonbeam-foundation/sdk';
|
|
142
|
+
|
|
143
|
+
livenessOf(state, clock); // { noLockout: true, stranded: [] }
|
|
144
|
+
recourseFor('provider', state, clock); // what I can do, and my guaranteed exit
|
|
145
|
+
waitingOn(state, clock); // who is holding this up
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- A silent **provider** cannot strand the client: past the deadline the refund is
|
|
149
|
+
permissionless — anyone may trigger it.
|
|
150
|
+
- A silent **client** cannot strand the provider: release is the client's alone,
|
|
151
|
+
but the provider can escalate to arbitration.
|
|
152
|
+
- A silent **evaluator** cannot strand either: the deadline resolves the job.
|
|
153
|
+
|
|
154
|
+
These are checked against real state rather than asserted in prose.
|
|
155
|
+
|
|
156
|
+
## Time carries its provenance
|
|
157
|
+
|
|
158
|
+
Deadlines decide money, so a `Clock` always records where "now" came from —
|
|
159
|
+
`local`, `chain`, or `attested` (a signed finality attestation). A proof-checking
|
|
160
|
+
setup narrows what must be trusted; it does not remove trust, so the SDK never
|
|
161
|
+
describes an attested clock as requiring none.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { createAttestationSource, clockFromAttestation } from '@moonbeam-foundation/sdk';
|
|
165
|
+
import { recoverMessageAddress } from 'viem';
|
|
166
|
+
|
|
167
|
+
const source = createAttestationSource({ baseUrl: 'https://…' });
|
|
168
|
+
const attestation = await source.latest(8453);
|
|
169
|
+
|
|
170
|
+
// The `signer` field is SELF-REPORTED. Recover it yourself or it proves nothing.
|
|
171
|
+
const ecrecover = (digest: string, signature: string) =>
|
|
172
|
+
recoverMessageAddress({ message: { raw: digest as `0x${string}` }, signature: signature as `0x${string}` });
|
|
173
|
+
|
|
174
|
+
if (attestation.ok) {
|
|
175
|
+
const clock = await clockFromAttestation(attestation.value, ecrecover);
|
|
176
|
+
// Refused outright if the signature does not check out — never downgraded silently.
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Note the recovery scheme: attestations are signed as EIP-191 personal messages
|
|
181
|
+
over the digest, not as a raw hash. Recovery always returns *some* address, so
|
|
182
|
+
the wrong scheme yields a plausible-looking address that simply never matches.
|
|
183
|
+
Verify against a known-good attestation once before relying on it.
|
|
184
|
+
|
|
185
|
+
## Network answers that are not answers
|
|
186
|
+
|
|
187
|
+
Connectors return a `Result` rather than throwing, to keep one distinction the
|
|
188
|
+
SDK considers load-bearing:
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
if (!result.ok && meansAbsent(result.error)) {
|
|
192
|
+
// The source definitively has nothing for this. A fact you can act on.
|
|
193
|
+
} else if (!result.ok) {
|
|
194
|
+
// Unavailable, network failure, malformed: you do not know. Not the same thing.
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
A 404 is honest — the service has no data for that chain. A 500 is an outage.
|
|
199
|
+
Collapsing the two would let a server fault read as "no proof exists", and under
|
|
200
|
+
the rule above, absence of proof must never authorise a payment.
|
|
201
|
+
|
|
202
|
+
The log reader carries the same instinct: some providers answer a valid query
|
|
203
|
+
with an empty set instead of an error, which is indistinguishable from a quiet
|
|
204
|
+
range, so `fetchLogRange` reports emptiness as `noData` unless you explicitly
|
|
205
|
+
vouch for your source. It also pages wide ranges automatically, because
|
|
206
|
+
providers that reject them leave holes in history that later reads never revisit.
|
|
207
|
+
|
|
208
|
+
## Building transactions
|
|
209
|
+
|
|
210
|
+
The SDK builds calls; it never signs or sends them, and never holds a key.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import { createAssuranceClient, asProofBlob } from '@moonbeam-foundation/sdk';
|
|
214
|
+
|
|
215
|
+
const client = createAssuranceClient({ chainId: 84532, escrow, evaluator });
|
|
216
|
+
|
|
217
|
+
client.escrow.claimRefund({ taskId }); // callable by anyone after the deadline
|
|
218
|
+
client.evaluator.approve({ jobId, proof: asProofBlob(blob) }); // proof required by the type
|
|
219
|
+
client.evaluator.reject({ jobId, reason }); // no proof — refusing is always safe
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`asProofBlob` rejects an empty blob, so the approval path cannot be called
|
|
223
|
+
without one. The asymmetry lives in the signatures rather than in a comment.
|
|
224
|
+
|
|
225
|
+
Constructing a client for a chain the contracts are not deployed on throws
|
|
226
|
+
immediately, rather than producing a transaction addressed to nothing.
|
|
227
|
+
|
|
228
|
+
## Judging a job on the Base hook
|
|
229
|
+
|
|
230
|
+
`@moonbeam-foundation/sdk/judge` grades a GLMR job on Moonbeam's assurance hook on Base
|
|
231
|
+
(`0xc0578657Eda85e0a246771aa1839ce79b54eE80d`) and builds the call that ends it. The grade works like this:
|
|
232
|
+
|
|
233
|
+
- Code checks the facts first. A failed check rejects the job, and the model is never asked.
|
|
234
|
+
- Jev, TypeSafe's calibrated decision model, answers four closed questions from the published RUBRIC_v1. Every answer
|
|
235
|
+
comes back as a full probability distribution.
|
|
236
|
+
- Code composes complete, reject or needs_review under fixed thresholds, and returns a receipt that hashes all of it.
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { gradeJob, jobFacts, recordGrade, endJob, verifyGrade } from '@moonbeam-foundation/sdk/judge';
|
|
240
|
+
|
|
241
|
+
const receipt = await gradeJob({
|
|
242
|
+
jobId, // the hook's 32-byte job id
|
|
243
|
+
evidence: { task, delivered },
|
|
244
|
+
facts: jobFacts({ delivered: true, checks: { proof_verifies: () => checkProof(delivered) } }),
|
|
245
|
+
trial: true, // 3 free calls; or key: <your TypeSafe key>
|
|
246
|
+
});
|
|
247
|
+
const onchain = await recordGrade(receipt, { network: 'devnet' }); // none | devnet | base | both — unsigned calls
|
|
248
|
+
const end = endJob(jobId, receipt); // complete(jobId) | reject(jobId, digest) | null (needs_review)
|
|
249
|
+
const check = await verifyGrade(receipt, { chain: false });
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`endJob` is signed by the job's buyer or by an evaluator the hook registered. For needs_review it returns `null`: the
|
|
253
|
+
job stays held until one of those parties decides, or until anyone calls `expire` after the deadline. The tests
|
|
254
|
+
re-encode the hook's `complete` from the covered GLMR hire on Base,
|
|
255
|
+
[`0xc606d00f…3116`](https://basescan.org/tx/0xc606d00fed64e912585bbc93feb15a9289cfcde94289f49f7c74a7a468903116),
|
|
256
|
+
byte for byte.
|
|
257
|
+
|
|
258
|
+
## Skills for AI agents
|
|
259
|
+
|
|
260
|
+
The package ships one skill per actor under `skills/`, so an agent acting as a
|
|
261
|
+
backer gets the backer's reasoning and not the doubter's:
|
|
262
|
+
|
|
263
|
+
`moonbeam-assurance` (router) · `moonbeam-acp-decoding` · and
|
|
264
|
+
`moonbeam-actor-{client,provider,evaluator,backer,doubter,challenger}`
|
|
265
|
+
|
|
266
|
+
Each states what its actor **risks** before what it earns, keeps to runnable
|
|
267
|
+
calls rather than prose economics, and ends with the deployment boundary. Those
|
|
268
|
+
rules are enforced by tests, not convention.
|
|
269
|
+
|
|
270
|
+
## Hooking up a host protocol
|
|
271
|
+
|
|
272
|
+
The `acp` adapter translates an [Agent Commerce
|
|
273
|
+
Protocol](https://whitepaper.virtuals.io/) job into insurable terms:
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { acpAdapter, settle, DEFAULT_ACP_POLICY } from '@moonbeam-foundation/sdk';
|
|
277
|
+
|
|
278
|
+
const terms = acpAdapter.toTerms(job, DEFAULT_ACP_POLICY);
|
|
279
|
+
if (!terms) return; // not insurable — see below
|
|
280
|
+
|
|
281
|
+
const verdict = acpAdapter.toVerdict({ approved: false, score: 0.2 });
|
|
282
|
+
const { ledger } = settle({ terms, verdict });
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
A job is **not insurable** when it is unpriced, above the policy cap, past the
|
|
286
|
+
`transaction` phase (the outcome is already being decided), missing a signed
|
|
287
|
+
Proof of Agreement (nothing to grade against), or missing a deadline (nothing
|
|
288
|
+
resolves it if the evaluator goes silent). `toTerms` returns `null` rather than
|
|
289
|
+
throwing, because "not insured" is the ordinary case, not an error.
|
|
290
|
+
|
|
291
|
+
SLA expiry maps to `notDelivered`, never to `cheated` — the host protocol
|
|
292
|
+
already refunds, and nobody should be punished for a job that simply expired.
|
|
293
|
+
|
|
294
|
+
### Writing another adapter
|
|
295
|
+
|
|
296
|
+
Implement `AssuranceAdapter<HostJob, HostOutcome>`: say what a job costs and what
|
|
297
|
+
its outcome means. Adapters translate; they never settle.
|
|
298
|
+
|
|
299
|
+
The interface is deliberately narrow because it currently has **one**
|
|
300
|
+
implementation. One adapter is a hypothetical seam, two is a real one — so it is
|
|
301
|
+
better to keep this small until a second protocol shows what actually needs to
|
|
302
|
+
be shared.
|
|
303
|
+
|
|
304
|
+
## Who must take part, and who may
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
import { ACTORS, actorsBy } from '@moonbeam-foundation/sdk';
|
|
308
|
+
|
|
309
|
+
actorsBy('obligatory'); // provider, evaluator
|
|
310
|
+
actorsBy('optional'); // client, pool, doubter, challenger
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Only the two roles the system takes at their word must post capital: the
|
|
314
|
+
provider doing the work and the evaluator grading it. Everyone else opts in.
|
|
315
|
+
|
|
316
|
+
Worth being precise about backing a pool: choosing to back one is optional, but once
|
|
317
|
+
in, underwriting is not a separate opt-in — **the exposure is the yield**.
|
|
318
|
+
There is no passive tier, because rewards come from real fees rather than
|
|
319
|
+
inflation.
|
|
320
|
+
|
|
321
|
+
## Pool economics
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
import { runSeason, breakEvenFailureRate, clearingFeeIsCoherent } from '@moonbeam-foundation/sdk';
|
|
325
|
+
|
|
326
|
+
// An undersized bond, to show the pool actually paying. A deposit at or above
|
|
327
|
+
// the damage leaves the pool at zero, which is the intended steady state.
|
|
328
|
+
runSeason({
|
|
329
|
+
jobs: 5_000,
|
|
330
|
+
premiumPerJob: usdc('1'),
|
|
331
|
+
failureRate: 0.006,
|
|
332
|
+
damagePerFailure: usdc('70'),
|
|
333
|
+
depositPerJob: usdc('40'),
|
|
334
|
+
});
|
|
335
|
+
// → premium 4_970, absorbed by deposits 1_200, paid by pool 900, net +4_070
|
|
336
|
+
|
|
337
|
+
breakEvenFailureRate(usdc('1'), usdc('70'), usdc('40')); // ≈ 0.032
|
|
338
|
+
clearingFeeIsCoherent(34, usdc('1'), usdc('70'), usdc('40')); // false
|
|
339
|
+
|
|
340
|
+
// Raise the bond above the damage and the residual disappears:
|
|
341
|
+
runSeason({ /* …as above… */ depositPerJob: usdc('120') });
|
|
342
|
+
// → premium 4_970, absorbed by deposits 2_100, paid by pool 0, net +4_970
|
|
343
|
+
breakEvenFailureRate(usdc('1'), usdc('70'), usdc('120')); // null — no rate breaks it
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
That last call is the useful one. A published clearing fee is a claim about the
|
|
347
|
+
failure rate the market expects; a pool's break-even is the rate it can actually
|
|
348
|
+
survive. If those disagree by an order of magnitude, the two numbers were
|
|
349
|
+
written against different assumptions — which is exactly the kind of drift that
|
|
350
|
+
survives review when the economics live in prose.
|
|
351
|
+
|
|
352
|
+
## Design notes
|
|
353
|
+
|
|
354
|
+
**Money is `bigint` minor units.** No floats anywhere in settlement. Basis-point
|
|
355
|
+
maths rounds *down*, so no unit is ever minted that nobody funded.
|
|
356
|
+
|
|
357
|
+
**The core is pure.** `settle()` takes terms and a verdict and returns a ledger.
|
|
358
|
+
No clock, no chain, no I/O. That is what makes the economics testable:
|
|
359
|
+
conservation of value, the arson cap, and "cheating pays the victim" are
|
|
360
|
+
assertions over a return value rather than claims in a document.
|
|
361
|
+
|
|
362
|
+
**The arson rule.** Doubt payouts are capped at capital already bonded
|
|
363
|
+
(`deposit + poolCapital`), so causing a failure always costs more than betting
|
|
364
|
+
on it can pay.
|
|
365
|
+
|
|
366
|
+
## Development
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
npm install
|
|
370
|
+
npm test # 56 tests
|
|
371
|
+
npm run typecheck # strict, noUncheckedIndexedAccess, exactOptionalPropertyTypes
|
|
372
|
+
npm run build # ESM + .d.ts to dist/
|
|
373
|
+
npm run test:coverage
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## License
|
|
377
|
+
|
|
378
|
+
Apache-2.0
|
package/bin/moonbeam.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// moonbeam demo — Moonbeam's first covered hire on Base, replayed offline: the job, the grade, the settlement.
|
|
3
|
+
// npx moonbeam demo (no key, no network, nothing signed)
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
|
|
6
|
+
const [cmd] = process.argv.slice(2);
|
|
7
|
+
if (cmd !== 'demo') { console.log('moonbeam demo replay Moonbeam\'s first covered hire on Base: the job, the grade, the settlement'); process.exit(cmd ? 2 : 0); }
|
|
8
|
+
|
|
9
|
+
const { settle, parseUnits, formatUnits, conservesValue } = await import('../dist/index.js');
|
|
10
|
+
const hire = JSON.parse(readFileSync(new URL('../examples/data/pilot-hire.json', import.meta.url), 'utf8'));
|
|
11
|
+
const tty = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
12
|
+
const c = (n) => (s) => (tty ? `\u001b[${n}m${s}\u001b[0m` : s);
|
|
13
|
+
const bold = c(1), dim = c(2), green = c(32);
|
|
14
|
+
const step = (n, t) => console.log(bold(`→ [${n}/4] ${t}`));
|
|
15
|
+
const ok = (t) => console.log(`${green('✓')} ${t}`);
|
|
16
|
+
const note = (t) => console.log(dim(` ${t}`));
|
|
17
|
+
const short = (h) => `${h.slice(0, 10)}…${h.slice(-4)}`;
|
|
18
|
+
const D = hire.token.decimals;
|
|
19
|
+
const glmr = (v) => parseUnits(v, D);
|
|
20
|
+
const show = (m) => `${m < 0n ? '−' : '+'}${formatUnits(m < 0n ? -m : m, D)} GLMR`;
|
|
21
|
+
const terms = Object.fromEntries(Object.entries(hire.terms).map(([k, v]) => [k, glmr(v)]));
|
|
22
|
+
|
|
23
|
+
console.log(dim(`moonbeam demo · offline · job ${short(hire.jobId)} on Moonbeam's hook ${short(hire.hook)} (Base)`));
|
|
24
|
+
step(1, 'The job: a covered hire on Base');
|
|
25
|
+
note(`${hire.terms.pay} GLMR job · ${hire.terms.premium} GLMR premium to the pool · ${hire.terms.deposit} GLMR seller deposit · cover reserved from a GLMR pool`);
|
|
26
|
+
for (const [k, t] of Object.entries(hire.txs)) ok(`${k.padEnd(9)} ${short(t.hash)} · block ${t.block.toLocaleString('en-US')} · ${t.what}`);
|
|
27
|
+
|
|
28
|
+
step(2, 'The grader: Jev by TypeSafe, on this job');
|
|
29
|
+
// The same job, graded by Jev from its public record and recorded on Base. The demo re-derives the decision offline.
|
|
30
|
+
const g = JSON.parse(readFileSync(new URL('../examples/data/pilot-grade.recorded.json', import.meta.url), 'utf8'));
|
|
31
|
+
const { grade, facts } = await import('@taifoon/jev');
|
|
32
|
+
const r = await grade({ subject: g.subject, evidence: g.evidence, facts: facts(g.facts), answers: g.answers, model: g.model });
|
|
33
|
+
for (const x of g.answers) note(`${x.id.padEnd(18)} ${String(x.value).padEnd(9)} ${Object.entries(x.probabilities).filter(([, p]) => p > 0).map(([k, p]) => `${k} ${p}`).join(' · ')}`);
|
|
34
|
+
ok(`${r.verdict} · ${r.reasons[0]} · ${g.model}`);
|
|
35
|
+
const same = r.decision?.digest === g.recorded.digest;
|
|
36
|
+
(same ? ok : (t) => console.log(`✗ ${t}`))(`${same ? 'same decision digest as' : 'differs from'} the one recorded on Base: tx ${short(g.recorded.base.tx)} · block ${g.recorded.base.block.toLocaleString('en-US')}`);
|
|
37
|
+
note('why reject: the hook records who paid, what was locked and a digest of the delivery, not what the buyer asked for,');
|
|
38
|
+
note('so no grader can confirm the work met the task. Put the task and the delivery in the evidence (examples/10-13).');
|
|
39
|
+
const verdict = r.verdict === 'complete' ? 'doneRight' : r.verdict === 'reject' ? 'rejected' : null;
|
|
40
|
+
|
|
41
|
+
step(3, 'Settle: how the job ended, and how it would end on the grade');
|
|
42
|
+
const row = (label, v) => { const s = settle({ terms, verdict: v }); ok(`${label.padEnd(30)} client ${show(s.ledger.client).padEnd(16)} provider ${show(s.ledger.provider).padEnd(16)} pool ${show(s.ledger.pool).padEnd(14)} sums to zero: ${conservesValue(s.ledger) ? 'yes' : 'NO'}`); };
|
|
43
|
+
row('on chain: the buyer completed', 'doneRight');
|
|
44
|
+
if (verdict) row(`with Jev as evaluator: ${r.verdict}`, verdict);
|
|
45
|
+
else note('with Jev as evaluator: needs review, nothing ends and the job goes to appeal');
|
|
46
|
+
ok(`locked in escrow ${formatUnits(settle({ terms, verdict: 'doneRight' }).locked, D)} GLMR`);
|
|
47
|
+
|
|
48
|
+
step(4, 'The other endings, on the same terms');
|
|
49
|
+
for (const v of ['notDelivered', 'cheated']) {
|
|
50
|
+
const s = settle({ terms, verdict: v });
|
|
51
|
+
note(`${v.padEnd(12)} client ${show(s.ledger.client).padEnd(16)} provider ${show(s.ledger.provider).padEnd(16)} pool ${show(s.ledger.pool)}`);
|
|
52
|
+
}
|
|
53
|
+
const hurt = settle({ terms: { ...terms, damage: glmr('5') }, verdict: 'cheated' });
|
|
54
|
+
note(`illustrative: had the buyer stated 5 GLMR of damage, cheated → client ${show(hurt.ledger.client)} · provider ${show(hurt.ledger.provider)} · pool ${show(hurt.ledger.pool)} (the deposit pays first)`);
|
|
55
|
+
console.log(dim('\nPilot with selected partners; the GLMR pools are not open yet. Nothing here signs or sends a transaction.'));
|
|
56
|
+
console.log(dim('Building on Moonbeam? builders@moonbeam.foundation'));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AcpEvent, RawLog } from './events.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decode coverage — proving the decoder sees everything, not just something.
|
|
4
|
+
*
|
|
5
|
+
* A decoder that silently skips an event it does not recognise is worse than
|
|
6
|
+
* one that fails loudly: the caller gets a job history with a hole in it and no
|
|
7
|
+
* indication that anything is missing. A settled job can look pending, a
|
|
8
|
+
* refunded one can look live, and nothing anywhere says why.
|
|
9
|
+
*
|
|
10
|
+
* So coverage is measured rather than assumed, and an unrecognised topic is
|
|
11
|
+
* surfaced with enough detail to identify it. The intended use is a standing
|
|
12
|
+
* check against live traffic: anything less than total coverage means the
|
|
13
|
+
* protocol emitted something this build has never seen.
|
|
14
|
+
*/
|
|
15
|
+
export interface CoverageReport {
|
|
16
|
+
readonly total: number;
|
|
17
|
+
readonly decoded: number;
|
|
18
|
+
/** Fraction in [0,1]. A partial history is not a usable history. */
|
|
19
|
+
readonly coverage: number;
|
|
20
|
+
readonly complete: boolean;
|
|
21
|
+
/** Unrecognised topic0s, with how many logs carried each. */
|
|
22
|
+
readonly unknownTopics: Readonly<Record<string, number>>;
|
|
23
|
+
/** One example log per unknown topic, to make identification possible. */
|
|
24
|
+
readonly samples: Readonly<Record<string, RawLog>>;
|
|
25
|
+
readonly events: readonly AcpEvent[];
|
|
26
|
+
}
|
|
27
|
+
export declare function measureCoverage(logs: readonly RawLog[]): CoverageReport;
|
|
28
|
+
/**
|
|
29
|
+
* Throw unless every log decoded.
|
|
30
|
+
*
|
|
31
|
+
* For the standing check against live traffic: a new event type appearing in
|
|
32
|
+
* production should break a build, not quietly degrade every job history the
|
|
33
|
+
* SDK produces afterwards.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertFullCoverage(logs: readonly RawLog[]): CoverageReport;
|
|
36
|
+
//# sourceMappingURL=coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/acp/coverage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;CACtC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CA8BvE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAa1E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { decodeAcpLog } from './events.js';
|
|
2
|
+
export function measureCoverage(logs) {
|
|
3
|
+
const events = [];
|
|
4
|
+
const unknownTopics = {};
|
|
5
|
+
const samples = {};
|
|
6
|
+
for (const log of logs) {
|
|
7
|
+
const event = decodeAcpLog(log);
|
|
8
|
+
if (event) {
|
|
9
|
+
events.push(event);
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const topic0 = log.topics?.[0]?.toLowerCase();
|
|
13
|
+
// A log with no topics is not an unrecognised event, it is not an event at
|
|
14
|
+
// all — counting it would inflate the gap with noise.
|
|
15
|
+
if (!topic0)
|
|
16
|
+
continue;
|
|
17
|
+
unknownTopics[topic0] = (unknownTopics[topic0] ?? 0) + 1;
|
|
18
|
+
samples[topic0] ??= log;
|
|
19
|
+
}
|
|
20
|
+
const total = logs.length;
|
|
21
|
+
const decoded = events.length;
|
|
22
|
+
return {
|
|
23
|
+
total,
|
|
24
|
+
decoded,
|
|
25
|
+
coverage: total === 0 ? 1 : decoded / total,
|
|
26
|
+
complete: Object.keys(unknownTopics).length === 0,
|
|
27
|
+
unknownTopics,
|
|
28
|
+
samples,
|
|
29
|
+
events,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Throw unless every log decoded.
|
|
34
|
+
*
|
|
35
|
+
* For the standing check against live traffic: a new event type appearing in
|
|
36
|
+
* production should break a build, not quietly degrade every job history the
|
|
37
|
+
* SDK produces afterwards.
|
|
38
|
+
*/
|
|
39
|
+
export function assertFullCoverage(logs) {
|
|
40
|
+
const report = measureCoverage(logs);
|
|
41
|
+
if (!report.complete) {
|
|
42
|
+
const detail = Object.entries(report.unknownTopics)
|
|
43
|
+
.map(([topic, count]) => `${topic} (${count} logs)`)
|
|
44
|
+
.join(', ');
|
|
45
|
+
throw new Error(`decode coverage is ${(report.coverage * 100).toFixed(2)}%, not 100%. ` +
|
|
46
|
+
`Unrecognised topic0: ${detail}. ` +
|
|
47
|
+
`Add the event to ACP_TOPIC0 and ACP_SIGNATURES, or the job histories built from these logs will have gaps.`);
|
|
48
|
+
}
|
|
49
|
+
return report;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/acp/coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA8B3C,MAAM,UAAU,eAAe,CAAC,IAAuB;IACrD,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,aAAa,GAA2B,EAAE,CAAC;IACjD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QAC9C,2EAA2E;QAC3E,sDAAsD;QACtD,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACzD,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;IAC1B,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,OAAO;QACL,KAAK;QACL,OAAO;QACP,QAAQ,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK;QAC3C,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC;QACjD,aAAa;QACb,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAuB;IACxD,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;aAChD,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,KAAK,QAAQ,CAAC;aACnD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CACb,sBAAsB,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;YACrE,wBAAwB,MAAM,IAAI;YAClC,4GAA4G,CAC/G,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|