capacity-attest 0.1.1 → 0.2.0
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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +3 -3
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +475 -32
- package/dist/ledger.js.map +1 -1
- package/dist/schema.d.ts +325 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +474 -13
- package/dist/schema.js.map +1 -1
- package/dist/tools.d.ts +10 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +33 -6
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -3,16 +3,41 @@
|
|
|
3
3
|
// al-yad-mcp-server's companion-client.ts vs. index.ts). This lets tests
|
|
4
4
|
// and examples/demo.ts call the real logic directly without spinning up a
|
|
5
5
|
// stdio JSON-RPC transport.
|
|
6
|
-
import {
|
|
6
|
+
import { StrictDeliveryClaimSchema } from "./schema.js";
|
|
7
7
|
import { verifyClaim } from "./signing.js";
|
|
8
8
|
import { appendClaim, claimsForSeller } from "./ledger.js";
|
|
9
9
|
/**
|
|
10
10
|
* Validate the claim's schema, verify its signature (must recover to
|
|
11
11
|
* buyerAddress), and persist it to the append-only ledger. This is the
|
|
12
12
|
* logic behind the `record_delivery` MCP tool.
|
|
13
|
+
*
|
|
14
|
+
* Async because appendClaim() is: its lock-contention retry awaits a real
|
|
15
|
+
* timer instead of busy-waiting, so this function must be awaited by every
|
|
16
|
+
* caller — an un-awaited call here would let the caller's next statement
|
|
17
|
+
* run before the claim is actually locked/checked/written, reordering the
|
|
18
|
+
* exact read-check-write sequence the lock exists to make atomic.
|
|
13
19
|
*/
|
|
14
|
-
export function recordDelivery(input) {
|
|
15
|
-
|
|
20
|
+
export async function recordDelivery(input) {
|
|
21
|
+
// StrictDeliveryClaimSchema, not DeliveryClaimSchema: new claims must also
|
|
22
|
+
// pass the ingest hardening of S-1..S-5 (see schema.ts). That schema is a
|
|
23
|
+
// superset of the frozen one, so it never changes a claimId — it only
|
|
24
|
+
// refuses input the frozen schema would have accepted. Historical ledger
|
|
25
|
+
// lines are still read back through the FROZEN DeliveryClaimSchema in
|
|
26
|
+
// ledger.ts, so a claim recorded before 0.2.0 with (say) a float in
|
|
27
|
+
// promisedSpec stays readable and verifiable forever.
|
|
28
|
+
// safeParse() is wrapped for the same reason verifyClaim() below is: the
|
|
29
|
+
// ingest checks walk caller-supplied data, and hostile or merely odd input
|
|
30
|
+
// (a cyclic object, a shared-reference graph) has already been shown to
|
|
31
|
+
// throw from inside a zod check rather than return a failed parse. The
|
|
32
|
+
// tool's contract is {ok:false, reason}, never an uncaught exception, so
|
|
33
|
+
// every step that touches untrusted input belongs inside a try/catch.
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = StrictDeliveryClaimSchema.safeParse(input);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
return { ok: false, reason: `invalid_claim: ${e.message}` };
|
|
40
|
+
}
|
|
16
41
|
if (!parsed.success) {
|
|
17
42
|
return { ok: false, reason: `invalid_claim: ${parsed.error.issues.map((i) => i.message).join("; ")}` };
|
|
18
43
|
}
|
|
@@ -32,7 +57,7 @@ export function recordDelivery(input) {
|
|
|
32
57
|
return { ok: false, reason: `signature_invalid: ${verdict.reason}` };
|
|
33
58
|
}
|
|
34
59
|
try {
|
|
35
|
-
appendClaim(claim);
|
|
60
|
+
await appendClaim(claim);
|
|
36
61
|
}
|
|
37
62
|
catch (e) {
|
|
38
63
|
return { ok: false, reason: e.message };
|
|
@@ -44,9 +69,11 @@ export function recordDelivery(input) {
|
|
|
44
69
|
* oldest first. Purely factual — no aggregate score, rating, or reputation
|
|
45
70
|
* judgment is computed here; see README.md "Wat dit NIET is". This is the
|
|
46
71
|
* logic behind the `get_delivery_history` MCP tool.
|
|
72
|
+
*
|
|
73
|
+
* Async to match claimsForSeller()'s now-async signature (see ledger.ts).
|
|
47
74
|
*/
|
|
48
|
-
export function getDeliveryHistory(sellerAddress) {
|
|
49
|
-
const claims = claimsForSeller(sellerAddress);
|
|
75
|
+
export async function getDeliveryHistory(sellerAddress) {
|
|
76
|
+
const claims = await claimsForSeller(sellerAddress);
|
|
50
77
|
return { sellerAddress, count: claims.length, claims };
|
|
51
78
|
}
|
|
52
79
|
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,uEAAuE;AACvE,yEAAyE;AACzE,0EAA0E;AAC1E,4BAA4B;AAE5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,uEAAuE;AACvE,yEAAyE;AACzE,0EAA0E;AAC1E,4BAA4B;AAE5B,OAAO,EAAE,yBAAyB,EAAsB,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI3D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAc;IACjD,2EAA2E;IAC3E,0EAA0E;IAC1E,sEAAsE;IACtE,yEAAyE;IACzE,sEAAsE;IACtE,oEAAoE;IACpE,sDAAsD;IACtD,yEAAyE;IACzE,2EAA2E;IAC3E,wEAAwE;IACxE,uEAAuE;IACvE,yEAAyE;IACzE,sEAAsE;IACtE,IAAI,MAA8D,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,EAAE,EAAE,KAA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MAAM,GAAG,MAAM,eAAe,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacity-attest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server for capacity-delivery attestations: after an x402 payment for compute capacity (GPU-hours, storage, API credits, bandwidth), the paying agent leaves a signed, factual claim of what was actually delivered, so other agents can check a seller's delivery history before paying. No reputation score, no judgment, no financial instrument.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|