uvd-describe-sdk 0.3.0 → 0.4.1
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/CHANGELOG.md +116 -0
- package/README.md +80 -4
- package/dist/{client-BMfgl1zP.d.mts → client-0sg4J53x.d.mts} +256 -23
- package/dist/{client-BMfgl1zP.d.ts → client-0sg4J53x.d.ts} +256 -23
- package/dist/{config-DzzhWFYr.d.mts → config-gjJ08BUJ.d.mts} +1 -1
- package/dist/{config-DzzhWFYr.d.ts → config-gjJ08BUJ.d.ts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +95 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -3
- package/dist/index.mjs.map +1 -1
- package/dist/partner/index.d.mts +2 -2
- package/dist/partner/index.d.ts +2 -2
- package/dist/partner/index.js.map +1 -1
- package/dist/partner/index.mjs.map +1 -1
- package/dist/x402/index.d.mts +1 -1
- package/dist/x402/index.d.ts +1 -1
- package/package.json +2 -1
- package/src/caveats.ts +297 -21
- package/src/config.ts +1 -1
- package/src/index.ts +16 -1
- package/src/parse.ts +42 -0
- package/src/types.ts +50 -1
|
@@ -524,40 +524,60 @@ declare function failedAfterPaying(error: unknown): error is DescribeError & {
|
|
|
524
524
|
* string comparison kept returning false and nobody was told.
|
|
525
525
|
*
|
|
526
526
|
* Exporting the set is one of the four "día 0" requirements the platform team
|
|
527
|
-
* put on any SDK of the house
|
|
528
|
-
* contrato exportado*. Typing them here means a consumer never re-types them,
|
|
527
|
+
* put on any SDK of the house: *los caveat `code`s como contrato exportado*. Typing them here means a consumer never re-types them,
|
|
529
528
|
* and a typo is a compile error rather than a branch that is never taken.
|
|
530
529
|
*
|
|
531
530
|
* ## Why the type is not a closed union
|
|
532
531
|
*
|
|
533
|
-
* `CaveatCode | (string & {})` gives autocomplete on the
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
532
|
+
* `CaveatCode | (string & {})` gives autocomplete on the codes that exist today
|
|
533
|
+
* AND still accepts one more the server adds tomorrow. A closed union would turn
|
|
534
|
+
* every new server-side code into a type error in code that is already deployed
|
|
535
|
+
* and working — the passthrough rule (tipar lo conocido, CONSERVAR lo que no)
|
|
536
|
+
* applied to the type system. The measured precedent is `Facet.direction`:
|
|
537
|
+
* FastAPI silently dropped a field nobody had declared, and the response looked
|
|
538
|
+
* correct with the data missing.
|
|
540
539
|
*
|
|
541
540
|
* The codes carry no version and never bump `POLICY_VERSION`: a caveat is
|
|
542
541
|
* advisory by construction and identifies a CUT, it never moves a score.
|
|
543
542
|
*/
|
|
543
|
+
|
|
544
544
|
/**
|
|
545
|
-
* The
|
|
546
|
-
* `describenet/caveats.py:
|
|
547
|
-
* `tests/test_caveat_codes.py` pins literally, so adding or
|
|
548
|
-
* there goes red on purpose
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
545
|
+
* The ten cuts describe.net serves on 2026-09-15, copied from the frozen set in
|
|
546
|
+
* `describenet/caveats.py:177-192` (describe-net `origin/main` at `4fd11c0`),
|
|
547
|
+
* which its own `tests/test_caveat_codes.py` pins literally, so adding or
|
|
548
|
+
* renaming one over there goes red on purpose. Same order as upstream.
|
|
549
|
+
*
|
|
550
|
+
* What the FREE route evaluates, per the server itself (`caveats.py:513`,
|
|
551
|
+
* `_publicos_evaluados`): `burn-address` always, and `thin-chain` when it has the
|
|
552
|
+
* per-chain rows — which `GET /wallets/{wallet}/chains` always has. Every other
|
|
553
|
+
* wallet-scope code is DECLARED as not evaluated, by name, in
|
|
554
|
+
* `WalletReputation.caveatsNotComputed`. `facilitator-authored` is agent scope
|
|
555
|
+
* and is in neither: a wallet profile lists no rows. An empty `caveats: []` on a
|
|
556
|
+
* free response therefore still means "no public-data caveat", NOT "clean" — and
|
|
557
|
+
* `requireFullCaveats()` is the gate that knows it. See `CAVEAT_SCOPE_FREE`.
|
|
558
|
+
*
|
|
559
|
+
* `thin-chain` (upstream since 2026-09-04, `cf8f806`; on the free route since
|
|
560
|
+
* 2026-09-05) is mirrored since 0.4.1, added to both twins together so the set
|
|
561
|
+
* both SDKs publish never differs. 0.4.0 shipped nine and knew it: until then
|
|
562
|
+
* `isKnownCaveatCode('thin-chain')` answered `false`, and the caveat still
|
|
563
|
+
* arrived whole — the tolerant answer this module was built to give.
|
|
564
|
+
*
|
|
565
|
+
* ⚠️ CORRECTED 2026-09-15, and the old text is left because somebody will look
|
|
566
|
+
* for it. It read: *"The eight cuts served on 2026-08-30, copied from the frozen
|
|
567
|
+
* set in `describenet/caveats.py:172-183` … Only `no-score` and `burn-address`
|
|
568
|
+
* are computable from public data, so the free routes serve a documented SUBSET
|
|
569
|
+
* … The other six need the grain and ride the metered routes."* Two codes had
|
|
570
|
+
* landed upstream since and this mirror carried neither; `facilitator-authored`
|
|
571
|
+
* (`6e25d71`, 2026-09-14) was mirrored in 0.4.0, `thin-chain` in 0.4.1. And
|
|
572
|
+
* `no-score` is not evaluated on the free route at all: the server declares it
|
|
573
|
+
* in the list.
|
|
554
574
|
*/
|
|
555
|
-
declare const CAVEAT_CODES: readonly ["no-score", "concentration-degraded", "single-rater", "few-raters", "top-client-share", "campaign-per-rater", "self-rated", "burn-address"];
|
|
556
|
-
/** The
|
|
575
|
+
declare const CAVEAT_CODES: readonly ["no-score", "concentration-degraded", "single-rater", "few-raters", "top-client-share", "campaign-per-rater", "self-rated", "burn-address", "thin-chain", "facilitator-authored"];
|
|
576
|
+
/** The known codes as a union — for `switch`, not for validation. */
|
|
557
577
|
type KnownCaveatCode = (typeof CAVEAT_CODES)[number];
|
|
558
578
|
/**
|
|
559
|
-
* What a caveat's `code` may be:
|
|
560
|
-
*
|
|
579
|
+
* What a caveat's `code` may be: a known one, or any string the server starts
|
|
580
|
+
* sending. The `(string & {})` half is what keeps autocomplete alive
|
|
561
581
|
* while leaving the union open.
|
|
562
582
|
*/
|
|
563
583
|
type CaveatCode = KnownCaveatCode | (string & {});
|
|
@@ -597,6 +617,170 @@ declare function isKnownCaveatCode(code: string): code is KnownCaveatCode;
|
|
|
597
617
|
declare function hasCaveat(subject: {
|
|
598
618
|
caveats?: readonly Caveat[];
|
|
599
619
|
} | null | undefined, code: CaveatCode): boolean;
|
|
620
|
+
/**
|
|
621
|
+
* `requireFullCaveats()` refused: this answer does not vouch for every cut.
|
|
622
|
+
*
|
|
623
|
+
* ## 🔴 NOT a `DescribeError`, and that is the decision
|
|
624
|
+
*
|
|
625
|
+
* `DescribeError` is the failure taxonomy — transport and protocol, "we could
|
|
626
|
+
* not read" — and consumers wrap it in their own fail-open:
|
|
627
|
+
* `catch (e) { if (e instanceof DescribeError) return null; }`. A refusal caught
|
|
628
|
+
* there degrades into "describe.net is down", and a gate built to tolerate
|
|
629
|
+
* outages lets the subject THROUGH: the same silent green the 2026-08-31 row
|
|
630
|
+
* exists to stop. This is not a failure to read; it is a successful read that
|
|
631
|
+
* does not support the decision being asked of it. So it extends `Error`, carries
|
|
632
|
+
* no `kind`, `transient` or `serviceFault`, and `failOpenCovers()` and
|
|
633
|
+
* `failedAfterPaying()` both answer `false` for it.
|
|
634
|
+
*
|
|
635
|
+
* Decided by the Python twin the same night (`CaveatsNotComputedError`,
|
|
636
|
+
* `uvd_describe_sdk/caveats.py`) and adopted here for parity. The first draft of
|
|
637
|
+
* this package made it a `DescribeError` with a new `kind`; the argument above is
|
|
638
|
+
* why that was the wrong door — and it would also have broken, at compile time,
|
|
639
|
+
* every exhaustive `switch` over `DescribeErrorKind`.
|
|
640
|
+
*
|
|
641
|
+
* ## `notComputed` — branch on it, never on the message
|
|
642
|
+
*
|
|
643
|
+
* ```
|
|
644
|
+
* ['few-raters', …] the answer DECLARED these unevaluated: unverified, not passed
|
|
645
|
+
* null the answer declared NOTHING — a server older than
|
|
646
|
+
* 2026-09-14, or a payload stored before then. Not `[]`.
|
|
647
|
+
* ```
|
|
648
|
+
*
|
|
649
|
+
* A declared `[]` never reaches this class: it passes the gate.
|
|
650
|
+
*/
|
|
651
|
+
declare class CaveatsNotComputedError extends Error {
|
|
652
|
+
/**
|
|
653
|
+
* What to do INSTEAD, as a frozen literal that interpolates nothing — the
|
|
654
|
+
* redaction rule of `recovery.ts` (invariant 11), without being an entry of
|
|
655
|
+
* that table, because this is not a `kind`. Same text on the class and on
|
|
656
|
+
* every instance.
|
|
657
|
+
*
|
|
658
|
+
* ⚠️ Not byte-identical to the Python twin's, and that is declared rather than
|
|
659
|
+
* hidden: theirs names `wallet_breakdown()`, `payer=`, `partner=` and
|
|
660
|
+
* `fallback_reader`, which are Python spellings. This one names what both SDKs
|
|
661
|
+
* share — the route, and the two ways through it.
|
|
662
|
+
*/
|
|
663
|
+
static readonly recovery: string;
|
|
664
|
+
/** Same literal as {@link CaveatsNotComputedError.recovery}, on the instance. */
|
|
665
|
+
readonly recovery: string;
|
|
666
|
+
/** The wallet whose answer was refused, as served. */
|
|
667
|
+
readonly wallet: string;
|
|
668
|
+
/** A COPY of what the answer declared, or `null` if it declared nothing. */
|
|
669
|
+
readonly notComputed: string[] | null;
|
|
670
|
+
constructor(message: string, opts: {
|
|
671
|
+
wallet: string;
|
|
672
|
+
notComputed: readonly string[] | null;
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Return `result` only if its answer DECLARED it left no caveat code out.
|
|
677
|
+
*
|
|
678
|
+
* ```ts
|
|
679
|
+
* const rep = await describe.wallet(address);
|
|
680
|
+
* if (rep === null) { … } // no answer at all: decide THAT first
|
|
681
|
+
* requireFullCaveats(rep); // throws CaveatsNotComputedError
|
|
682
|
+
* ```
|
|
683
|
+
*
|
|
684
|
+
* ## The bug it closes, found by karma-hello
|
|
685
|
+
*
|
|
686
|
+
* A quality gate built on the FREE route passes everybody (karma-hello, channel,
|
|
687
|
+
* 2026-08-31; `describe-net/docs/BACKLOG.md:221`). The evidence-quality cuts —
|
|
688
|
+
* `single-rater`, `few-raters`, `campaign-per-rater`, … — are computed only by
|
|
689
|
+
* the paid decomposition, so on `GET /wallets/{wallet}/chains`
|
|
690
|
+
* `hasCaveat(rep, 'single-rater')` is `false` for every wallet, the one with a
|
|
691
|
+
* single rater included. Honest code, and a gate that cannot fail anyone.
|
|
692
|
+
*
|
|
693
|
+
* Since 2026-09-14 the free answer DECLARES the names it did not evaluate
|
|
694
|
+
* (`WalletReputation.caveatsNotComputed`), and the server names this very helper
|
|
695
|
+
* as the reason the declaration is a list and not a count
|
|
696
|
+
* (`describenet/caveats.py:493-494`: *"el SDK puede ofrecer
|
|
697
|
+
* `require_full_caveats()` sin tabla propia"*). No table of our own here either:
|
|
698
|
+
* the verdict is read off the answer, never off a list typed in this package.
|
|
699
|
+
*
|
|
700
|
+
* ## Three states, and only one passes
|
|
701
|
+
*
|
|
702
|
+
* ```
|
|
703
|
+
* caveatsNotComputed = [] → returns `result`, the same object
|
|
704
|
+
* caveatsNotComputed = ['…', …] → throws; `error.notComputed` is the list
|
|
705
|
+
* caveatsNotComputed = null → throws; `error.notComputed` is null
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* 🔴 **Against the live index this throws for every `wallet()` today** —
|
|
709
|
+
* measured 2026-09-15: the same seven codes for a wallet with 471 distinct raters
|
|
710
|
+
* and for one with no identity at all. That is the gate working: the free route
|
|
711
|
+
* does not evaluate the evidence-quality cuts, and a decision that needs them has
|
|
712
|
+
* to buy `walletBreakdown()` (or read it over the partner rail). What changes is
|
|
713
|
+
* that the gate can no longer find that out by passing.
|
|
714
|
+
*
|
|
715
|
+
* ## 🔴 Why `null` THROWS — the decision, and its sources
|
|
716
|
+
*
|
|
717
|
+
* - The position of 2026-08-31, written in `describe-net/docs/BACKLOG.md:221`:
|
|
718
|
+
* *"la línea gratis/pago es regla de costo y **el scope es la señal**; el SDK
|
|
719
|
+
* puede ganar `require_full_caveats()`"*. That row is about a gate that goes
|
|
720
|
+
* green without knowing what was not computed. A `null` that passes is that
|
|
721
|
+
* gate, back — silently, on every old deployment and every stored payload.
|
|
722
|
+
* - The service refuses the same collapse on its own side: its MCP tool carries
|
|
723
|
+
* `None` *"cuando la API no lo trae: una API vieja no declaró nada, y `[]`
|
|
724
|
+
* afirmaría que lo calculó todo"* (`describenet/mcp_server.py:896-901`).
|
|
725
|
+
* - Before 2026-09-14 the free route did not evaluate those cuts either; it only
|
|
726
|
+
* did not SAY so (`caveatScope: 'public-data-subset'` was the whole signal). An
|
|
727
|
+
* old answer's silence is the old gap, not a clean bill.
|
|
728
|
+
*
|
|
729
|
+
* ## It takes a `WalletReputation`, and nothing else
|
|
730
|
+
*
|
|
731
|
+
* The one result that declares what it did not compute. Anything else is a
|
|
732
|
+
* `TypeError` naming the mistake — never a pass, and never the refusal above:
|
|
733
|
+
*
|
|
734
|
+
* - `null` is "describe.net did not answer", the third absence (invariant 3).
|
|
735
|
+
* Handle it before asking about caveats.
|
|
736
|
+
* - A `WalletBreakdown` or an `AgentReputation` comes from a metered route, which
|
|
737
|
+
* evaluates its own caveat scope and declares no omissions: there is nothing
|
|
738
|
+
* here for this gate to read.
|
|
739
|
+
* - A raw wire payload (snake_case) was never parsed: `parseWalletReputation()`.
|
|
740
|
+
*
|
|
741
|
+
* Never called by the client and never swallowed by `failOpen`. And passing
|
|
742
|
+
* means the caveats are COMPLETE, not that they are empty — `hasCaveat()` is
|
|
743
|
+
* still the question after the gate.
|
|
744
|
+
*/
|
|
745
|
+
declare function requireFullCaveats(result: WalletReputation): WalletReputation;
|
|
746
|
+
/**
|
|
747
|
+
* The two classes served in `ratings[].author_class` since describe.net
|
|
748
|
+
* 2026-09-14 — the schema's own enum (`describenet/api.py:962`,
|
|
749
|
+
* `Literal["facilitator-authored", "rater-authored"]`), and
|
|
750
|
+
* `types.schema.test.ts` pins this tuple against the snapshot's `enum`. The
|
|
751
|
+
* Python twin calls the same set `KNOWN_AUTHOR_CLASSES`, the way it calls
|
|
752
|
+
* `CAVEAT_CODES` `KNOWN_CAVEAT_CODES`.
|
|
753
|
+
*
|
|
754
|
+
* They live next to the caveat codes because one of them IS one: the agent-scope
|
|
755
|
+
* caveat `facilitator-authored` fires exactly when some row carries that class
|
|
756
|
+
* (`describenet/caveats.py:614`, which reads the field instead of recomputing it,
|
|
757
|
+
* so the two cannot disagree inside one answer).
|
|
758
|
+
*/
|
|
759
|
+
declare const AUTHOR_CLASSES: readonly ["facilitator-authored", "rater-authored"];
|
|
760
|
+
/** The known classes as a union — for `switch`, not for validation. */
|
|
761
|
+
type KnownAuthorClass = (typeof AUTHOR_CLASSES)[number];
|
|
762
|
+
/**
|
|
763
|
+
* What `Rating.authorClass` may be: a known class, or any string the server
|
|
764
|
+
* starts sending.
|
|
765
|
+
*
|
|
766
|
+
* Open, not closed, and recording that decision is why this type exists. The
|
|
767
|
+
* server's enum is closed TODAY; a third class there is a new contract on their
|
|
768
|
+
* side and must not become a type error — or worse, a thrown parse — on ours. A
|
|
769
|
+
* parser that rejected it would destroy a PAID read over one advisory field; one
|
|
770
|
+
* that nulled it would read as "no class served". So it arrives verbatim and
|
|
771
|
+
* `isKnownAuthorClass()` says whether this SDK has heard of it: the `CaveatCode`
|
|
772
|
+
* rule, applied one field over.
|
|
773
|
+
*/
|
|
774
|
+
type AuthorClass = KnownAuthorClass | (string & {});
|
|
775
|
+
/**
|
|
776
|
+
* Is this one of the author classes this SDK knows?
|
|
777
|
+
*
|
|
778
|
+
* NOT a validator, same as `isKnownCaveatCode`: `false` means "newer than this
|
|
779
|
+
* SDK" — or, for `null`, a row served before 2026-09-14 that carries no class at
|
|
780
|
+
* all. Neither is invalid. Before filtering rows on it, decide what an unknown
|
|
781
|
+
* class means for YOUR count; this SDK will not decide that for you.
|
|
782
|
+
*/
|
|
783
|
+
declare function isKnownAuthorClass(value: string | null | undefined): value is KnownAuthorClass;
|
|
600
784
|
|
|
601
785
|
/**
|
|
602
786
|
* The wire shapes — hand-written, and here is the argument for that.
|
|
@@ -784,6 +968,34 @@ interface WalletReputation extends Sealed {
|
|
|
784
968
|
chainsWithIdentity: number;
|
|
785
969
|
chainsWithReputation: number;
|
|
786
970
|
totalReviews: number;
|
|
971
|
+
/**
|
|
972
|
+
* The caveat codes that the paid decomposition evaluates and THIS free answer
|
|
973
|
+
* did not — sorted, served since describe.net 2026-09-14
|
|
974
|
+
* (`describenet/caveats.py:525-532`, `not_computed_public`, derived from the
|
|
975
|
+
* same module that builds `caveats`). **Names, never outcomes**: whether any of
|
|
976
|
+
* them fires for this wallet is exactly what stays paid.
|
|
977
|
+
*
|
|
978
|
+
* Seven codes on 2026-09-15, for a wallet with 471 raters and for `0xdead…beef`
|
|
979
|
+
* alike — the declaration depends on what the route evaluates, not on the
|
|
980
|
+
* subject. Read it live; the count is not a constant.
|
|
981
|
+
*
|
|
982
|
+
* 🔴 **Three states, and they stay three:**
|
|
983
|
+
*
|
|
984
|
+
* ```
|
|
985
|
+
* ['few-raters', …] NOT evaluated here — read each one as UNVERIFIED, never as passed
|
|
986
|
+
* [] the answer says it evaluated every wallet-scope cut
|
|
987
|
+
* null nothing readable was declared: a server older than 2026-09-14,
|
|
988
|
+
* a payload stored before then, or a value that is not a list
|
|
989
|
+
* of non-empty strings. NOT `[]` — nothing was promised, and
|
|
990
|
+
* `caveatScope` still says what was evaluated
|
|
991
|
+
* ```
|
|
992
|
+
*
|
|
993
|
+
* The failure this field closes is karma-hello's (2026-08-31): a quality gate
|
|
994
|
+
* built on this route passed every wallet, because `caveats: []` here is the
|
|
995
|
+
* silence of cuts that were never run. Do not gate on it by hand —
|
|
996
|
+
* `requireFullCaveats()` is the gate, and it reads the `null` correctly.
|
|
997
|
+
*/
|
|
998
|
+
caveatsNotComputed: CaveatCode[] | null;
|
|
787
999
|
}
|
|
788
1000
|
/** How lopsided the evidence is. `null` when there is not enough to say. */
|
|
789
1001
|
interface Concentration {
|
|
@@ -954,6 +1166,27 @@ interface WalletBreakdown extends Sealed {
|
|
|
954
1166
|
*/
|
|
955
1167
|
interface Rating {
|
|
956
1168
|
client: string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Who SIGNED this row, as a class — served since describe.net 2026-09-14
|
|
1171
|
+
* (`describenet/api.py:962`, `rating_roles.author_class_of`).
|
|
1172
|
+
*
|
|
1173
|
+
* - `facilitator-authored` — `client` is a known relayer (today the x402
|
|
1174
|
+
* facilitator's EVM wallet) that wrote the rating on behalf of the real
|
|
1175
|
+
* rater. **`client` is NOT the counterparty**: every such row shares one
|
|
1176
|
+
* `client`, so any per-rater count — `concentration.distinctRaters`,
|
|
1177
|
+
* `topClientShare` — merges all of them into one voice. Filter on this
|
|
1178
|
+
* before reading `client` as "who rated".
|
|
1179
|
+
* - `rater-authored` — `client` is not a relayer the index knows about. 🔴 It
|
|
1180
|
+
* does NOT prove who signed; it is the absence of a known relayer.
|
|
1181
|
+
* - `null` — no class was served (a server older than 2026-09-14, or a stored
|
|
1182
|
+
* payload). Unknown, and deliberately NOT defaulted to `rater-authored`:
|
|
1183
|
+
* that would assert the one thing the index says it cannot.
|
|
1184
|
+
*
|
|
1185
|
+
* An unknown string arrives VERBATIM — the union is open, like `CaveatCode`,
|
|
1186
|
+
* and `isKnownAuthorClass()` says whether this SDK has heard of it. Per row
|
|
1187
|
+
* only: neither the index nor this SDK computes any score or count by class.
|
|
1188
|
+
*/
|
|
1189
|
+
authorClass: AuthorClass | null;
|
|
957
1190
|
feedbackIndex: number;
|
|
958
1191
|
value: number;
|
|
959
1192
|
valueDecimals: number;
|
|
@@ -1674,4 +1907,4 @@ declare class DescribeClient {
|
|
|
1674
1907
|
private assertPayableTo;
|
|
1675
1908
|
}
|
|
1676
1909
|
|
|
1677
|
-
export { type AgentReputation as A, type
|
|
1910
|
+
export { isKnownAuthorClass as $, type AgentReputation as A, type FreshnessScope as B, CAVEAT_CODES as C, type DescribeErrorKind as D, type KnownCaveatCode as E, type Facet as F, type PartnerSigner as G, type HealthChain as H, type IndexHealth as I, type PaymentAttempt as J, type KnownAuthorClass as K, type LeaderboardRow as L, type SelfRated as M, type Network as N, type Ownership as O, type PaymentEvidence as P, type Snapshot as Q, type Rating as R, type Sealed as S, type Timestamp as T, type WalletChainRow as U, type X402Payer as V, type WalletBreakdown as W, type X402Challenge as X, failOpenCovers as Y, failedAfterPaying as Z, hasCaveat as _, type WalletReputation as a, isKnownCaveatCode as a0, requireFullCaveats as a1, AUTHOR_CLASSES as b, type Activity as c, type AuthorClass as d, CAVEAT_SCOPE_FREE as e, CAVEAT_SCOPE_METERED as f, type Caveat as g, type CaveatCode as h, CaveatsNotComputedError as i, type Concentration as j, type Confidence as k, DescribeClient as l, type DescribeClientConfig as m, DescribeError as n, type DescribeFailure as o, DescribeHTTPError as p, DescribeMalformedHash as q, DescribeNotFound as r, DescribePartnerRejected as s, DescribePartnerUnsigned as t, DescribePaymentRefused as u, DescribePaymentRequired as v, DescribeTimeout as w, DescribeUnparseable as x, DescribeUnreachable as y, type Freshness as z };
|
|
@@ -138,7 +138,7 @@ declare const PARTNER_KEY_ENV = "DESCRIBE_PARTNER_PRIVATE_KEY";
|
|
|
138
138
|
* time instead of at runtime. Bumping the version without the constant is a
|
|
139
139
|
* red test, not a silent lie in someone's access log.
|
|
140
140
|
*/
|
|
141
|
-
declare const SDK_VERSION = "0.
|
|
141
|
+
declare const SDK_VERSION = "0.4.1";
|
|
142
142
|
/** `uvd-describe-sdk-ts/0.1.0`, plus `(+<product>)` when the caller names itself. */
|
|
143
143
|
declare const SDK_NAME = "uvd-describe-sdk-ts";
|
|
144
144
|
/**
|
|
@@ -138,7 +138,7 @@ declare const PARTNER_KEY_ENV = "DESCRIBE_PARTNER_PRIVATE_KEY";
|
|
|
138
138
|
* time instead of at runtime. Bumping the version without the constant is a
|
|
139
139
|
* red test, not a silent lie in someone's access log.
|
|
140
140
|
*/
|
|
141
|
-
declare const SDK_VERSION = "0.
|
|
141
|
+
declare const SDK_VERSION = "0.4.1";
|
|
142
142
|
/** `uvd-describe-sdk-ts/0.1.0`, plus `(+<product>)` when the caller names itself. */
|
|
143
143
|
declare const SDK_NAME = "uvd-describe-sdk-ts";
|
|
144
144
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DescribeErrorKind, P as PaymentEvidence, A as AgentReputation, I as IndexHealth, L as LeaderboardRow, W as WalletBreakdown, a as WalletReputation } from './client-
|
|
2
|
-
export { b as Activity, C as CAVEAT_CODES,
|
|
3
|
-
export { D as DEFAULT_BASE_URL, a as DEFAULT_JITTER_MS, b as DEFAULT_SITE_URL, c as DEFAULT_TIMEOUT_MS, P as PARTNER_CHAIN_ID, d as PARTNER_KEY_ENV, S as SDK_NAME, e as SDK_VERSION, T as TREASURY_EVM, u as userAgent } from './config-
|
|
1
|
+
import { D as DescribeErrorKind, P as PaymentEvidence, A as AgentReputation, I as IndexHealth, L as LeaderboardRow, W as WalletBreakdown, a as WalletReputation } from './client-0sg4J53x.mjs';
|
|
2
|
+
export { b as AUTHOR_CLASSES, c as Activity, d as AuthorClass, C as CAVEAT_CODES, e as CAVEAT_SCOPE_FREE, f as CAVEAT_SCOPE_METERED, g as Caveat, h as CaveatCode, i as CaveatsNotComputedError, j as Concentration, k as Confidence, l as DescribeClient, m as DescribeClientConfig, n as DescribeError, o as DescribeFailure, p as DescribeHTTPError, q as DescribeMalformedHash, r as DescribeNotFound, s as DescribePartnerRejected, t as DescribePartnerUnsigned, u as DescribePaymentRefused, v as DescribePaymentRequired, w as DescribeTimeout, x as DescribeUnparseable, y as DescribeUnreachable, F as Facet, z as Freshness, B as FreshnessScope, H as HealthChain, K as KnownAuthorClass, E as KnownCaveatCode, N as Network, O as Ownership, G as PartnerSigner, J as PaymentAttempt, R as Rating, S as Sealed, M as SelfRated, Q as Snapshot, T as Timestamp, U as WalletChainRow, X as X402Challenge, V as X402Payer, Y as failOpenCovers, Z as failedAfterPaying, _ as hasCaveat, $ as isKnownAuthorClass, a0 as isKnownCaveatCode, a1 as requireFullCaveats } from './client-0sg4J53x.mjs';
|
|
3
|
+
export { D as DEFAULT_BASE_URL, a as DEFAULT_JITTER_MS, b as DEFAULT_SITE_URL, c as DEFAULT_TIMEOUT_MS, P as PARTNER_CHAIN_ID, d as PARTNER_KEY_ENV, S as SDK_NAME, e as SDK_VERSION, T as TREASURY_EVM, u as userAgent } from './config-gjJ08BUJ.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* What to do INSTEAD — the sentence `transient` cannot say.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DescribeErrorKind, P as PaymentEvidence, A as AgentReputation, I as IndexHealth, L as LeaderboardRow, W as WalletBreakdown, a as WalletReputation } from './client-
|
|
2
|
-
export { b as Activity, C as CAVEAT_CODES,
|
|
3
|
-
export { D as DEFAULT_BASE_URL, a as DEFAULT_JITTER_MS, b as DEFAULT_SITE_URL, c as DEFAULT_TIMEOUT_MS, P as PARTNER_CHAIN_ID, d as PARTNER_KEY_ENV, S as SDK_NAME, e as SDK_VERSION, T as TREASURY_EVM, u as userAgent } from './config-
|
|
1
|
+
import { D as DescribeErrorKind, P as PaymentEvidence, A as AgentReputation, I as IndexHealth, L as LeaderboardRow, W as WalletBreakdown, a as WalletReputation } from './client-0sg4J53x.js';
|
|
2
|
+
export { b as AUTHOR_CLASSES, c as Activity, d as AuthorClass, C as CAVEAT_CODES, e as CAVEAT_SCOPE_FREE, f as CAVEAT_SCOPE_METERED, g as Caveat, h as CaveatCode, i as CaveatsNotComputedError, j as Concentration, k as Confidence, l as DescribeClient, m as DescribeClientConfig, n as DescribeError, o as DescribeFailure, p as DescribeHTTPError, q as DescribeMalformedHash, r as DescribeNotFound, s as DescribePartnerRejected, t as DescribePartnerUnsigned, u as DescribePaymentRefused, v as DescribePaymentRequired, w as DescribeTimeout, x as DescribeUnparseable, y as DescribeUnreachable, F as Facet, z as Freshness, B as FreshnessScope, H as HealthChain, K as KnownAuthorClass, E as KnownCaveatCode, N as Network, O as Ownership, G as PartnerSigner, J as PaymentAttempt, R as Rating, S as Sealed, M as SelfRated, Q as Snapshot, T as Timestamp, U as WalletChainRow, X as X402Challenge, V as X402Payer, Y as failOpenCovers, Z as failedAfterPaying, _ as hasCaveat, $ as isKnownAuthorClass, a0 as isKnownCaveatCode, a1 as requireFullCaveats } from './client-0sg4J53x.js';
|
|
3
|
+
export { D as DEFAULT_BASE_URL, a as DEFAULT_JITTER_MS, b as DEFAULT_SITE_URL, c as DEFAULT_TIMEOUT_MS, P as PARTNER_CHAIN_ID, d as PARTNER_KEY_ENV, S as SDK_NAME, e as SDK_VERSION, T as TREASURY_EVM, u as userAgent } from './config-gjJ08BUJ.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* What to do INSTEAD — the sentence `transient` cannot say.
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var DEFAULT_JITTER_MS = 400;
|
|
|
8
8
|
var TREASURY_EVM = "0xe4dc963c56979E0260fc146b87eE24F18220e545";
|
|
9
9
|
var PARTNER_CHAIN_ID = 8453;
|
|
10
10
|
var PARTNER_KEY_ENV = "DESCRIBE_PARTNER_PRIVATE_KEY";
|
|
11
|
-
var SDK_VERSION = "0.
|
|
11
|
+
var SDK_VERSION = "0.4.1";
|
|
12
12
|
var SDK_NAME = "uvd-describe-sdk-ts";
|
|
13
13
|
function userAgent(product) {
|
|
14
14
|
const base = `${SDK_NAME}/${SDK_VERSION}`;
|
|
@@ -298,7 +298,25 @@ var CAVEAT_CODES = [
|
|
|
298
298
|
* nobody can answer for its reputation. The ratings are real on-chain facts
|
|
299
299
|
* — which is why they are still served — but the subject is not an identity.
|
|
300
300
|
*/
|
|
301
|
-
"burn-address"
|
|
301
|
+
"burn-address",
|
|
302
|
+
/**
|
|
303
|
+
* At least one of two or more scored chains rests on fewer than
|
|
304
|
+
* `reading_policy.min_raters` distinct raters. Its weight in the global score
|
|
305
|
+
* is small but never zero, so it still moves the number: read the per-chain
|
|
306
|
+
* composition before the global. Never fires on a single chain — there the
|
|
307
|
+
* weight cancels and `single-rater` / `few-raters` already say it. Wallet
|
|
308
|
+
* scope, and evaluated on the FREE route too (from `chains[]`). Since
|
|
309
|
+
* 2026-09-04; mirrored since 0.4.1.
|
|
310
|
+
*/
|
|
311
|
+
"thin-chain",
|
|
312
|
+
/**
|
|
313
|
+
* Some rows of `ratings[]` carry `authorClass: 'facilitator-authored'`: a
|
|
314
|
+
* relayer signed them, so their `client` is not the counterparty and every
|
|
315
|
+
* per-rater count merges them into one voice. AGENT scope only — the one
|
|
316
|
+
* metered answer that lists rows — and it carries no numbers, on purpose: the
|
|
317
|
+
* aggregate by author was cancelled upstream on 2026-08-29. Since 2026-09-14.
|
|
318
|
+
*/
|
|
319
|
+
"facilitator-authored"
|
|
302
320
|
];
|
|
303
321
|
var CAVEAT_SCOPE_FREE = "public-data-subset";
|
|
304
322
|
var CAVEAT_SCOPE_METERED = "full";
|
|
@@ -308,6 +326,60 @@ function isKnownCaveatCode(code) {
|
|
|
308
326
|
function hasCaveat(subject, code) {
|
|
309
327
|
return (subject?.caveats ?? []).some((c) => c.code === code);
|
|
310
328
|
}
|
|
329
|
+
var CaveatsNotComputedError = class _CaveatsNotComputedError extends Error {
|
|
330
|
+
/**
|
|
331
|
+
* What to do INSTEAD, as a frozen literal that interpolates nothing — the
|
|
332
|
+
* redaction rule of `recovery.ts` (invariant 11), without being an entry of
|
|
333
|
+
* that table, because this is not a `kind`. Same text on the class and on
|
|
334
|
+
* every instance.
|
|
335
|
+
*
|
|
336
|
+
* ⚠️ Not byte-identical to the Python twin's, and that is declared rather than
|
|
337
|
+
* hidden: theirs names `wallet_breakdown()`, `payer=`, `partner=` and
|
|
338
|
+
* `fallback_reader`, which are Python spellings. This one names what both SDKs
|
|
339
|
+
* share — the route, and the two ways through it.
|
|
340
|
+
*/
|
|
341
|
+
static recovery = "What this free answer did not evaluate is what the metered decomposition sells: `GET /reputation/wallet/{wallet}` evaluates the wallet-scope cuts this error lists \u2014 paid per call with x402, or free for a wallet on describe.net's partner allowlist. If the error lists nothing, the answer declared nothing (a server older than 2026-09-14, or a payload stored before then), and that is not a pass either: the decomposition is still the route that evaluates them.";
|
|
342
|
+
/** Same literal as {@link CaveatsNotComputedError.recovery}, on the instance. */
|
|
343
|
+
recovery = _CaveatsNotComputedError.recovery;
|
|
344
|
+
/** The wallet whose answer was refused, as served. */
|
|
345
|
+
wallet;
|
|
346
|
+
/** A COPY of what the answer declared, or `null` if it declared nothing. */
|
|
347
|
+
notComputed;
|
|
348
|
+
constructor(message, opts) {
|
|
349
|
+
super(message);
|
|
350
|
+
this.name = "CaveatsNotComputedError";
|
|
351
|
+
this.wallet = opts.wallet;
|
|
352
|
+
this.notComputed = opts.notComputed === null ? null : [...opts.notComputed];
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
function isWalletReputation(v) {
|
|
356
|
+
if (typeof v !== "object" || v === null || Array.isArray(v)) return false;
|
|
357
|
+
return typeof v.wallet === "string" && "globalScore" in v && !("finalScore" in v) && !("agentId" in v);
|
|
358
|
+
}
|
|
359
|
+
function requireFullCaveats(result) {
|
|
360
|
+
if (!isWalletReputation(result)) {
|
|
361
|
+
throw new TypeError(
|
|
362
|
+
"requireFullCaveats() takes the WalletReputation that wallet() returns. A null means describe.net did NOT answer \u2014 handle that before asking about caveats. A WalletBreakdown or an AgentReputation comes from a metered route, which evaluates its own caveat scope and declares no omissions. A raw payload goes through parseWalletReputation() first."
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const declared = result.caveatsNotComputed;
|
|
366
|
+
if (!Array.isArray(declared)) {
|
|
367
|
+
throw new CaveatsNotComputedError(
|
|
368
|
+
`the answer for ${result.wallet} did not declare which caveat codes it left out (no \`caveats_not_computed\`): a server older than 2026-09-14, or a payload stored before then. Undeclared is not \`[]\`, so this gate does not pass.`,
|
|
369
|
+
{ wallet: result.wallet, notComputed: null }
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
if (declared.length === 0) return result;
|
|
373
|
+
const codes = declared.map(String);
|
|
374
|
+
throw new CaveatsNotComputedError(
|
|
375
|
+
`the answer for ${result.wallet} declares ${codes.length} caveat code(s) it did not compute: ${codes.join(", ")}. Unverified, not passed.`,
|
|
376
|
+
{ wallet: result.wallet, notComputed: codes }
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
var AUTHOR_CLASSES = ["facilitator-authored", "rater-authored"];
|
|
380
|
+
function isKnownAuthorClass(value) {
|
|
381
|
+
return AUTHOR_CLASSES.includes(value);
|
|
382
|
+
}
|
|
311
383
|
|
|
312
384
|
// src/parse.ts
|
|
313
385
|
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -336,6 +408,15 @@ function parseCaveats(v) {
|
|
|
336
408
|
}
|
|
337
409
|
return out;
|
|
338
410
|
}
|
|
411
|
+
function parseNotComputed(v) {
|
|
412
|
+
if (!Array.isArray(v)) return null;
|
|
413
|
+
const codes = [];
|
|
414
|
+
for (const item of v) {
|
|
415
|
+
if (typeof item !== "string" || item === "") return null;
|
|
416
|
+
codes.push(item);
|
|
417
|
+
}
|
|
418
|
+
return codes;
|
|
419
|
+
}
|
|
339
420
|
function parseFacets(v) {
|
|
340
421
|
if (!isObj(v)) return {};
|
|
341
422
|
const out = {};
|
|
@@ -441,6 +522,12 @@ function parseRatings(v) {
|
|
|
441
522
|
const malformed = [];
|
|
442
523
|
return {
|
|
443
524
|
client: String(r.client ?? ""),
|
|
525
|
+
// Tolerant on purpose, the `isKnownCaveatCode` pattern: a class this SDK
|
|
526
|
+
// has not heard of arrives verbatim, never thrown (one advisory field
|
|
527
|
+
// must not destroy a paid read) and never nulled (dropping it would read
|
|
528
|
+
// as "no class served"). Only a non-string or an empty string is `null`:
|
|
529
|
+
// there is nothing to keep (the Python twin's `_author_class`, same rule).
|
|
530
|
+
authorClass: typeof r.author_class === "string" && r.author_class !== "" ? r.author_class : null,
|
|
444
531
|
feedbackIndex: num(r.feedback_index),
|
|
445
532
|
value: num(r.value),
|
|
446
533
|
valueDecimals: num(r.value_decimals),
|
|
@@ -494,6 +581,8 @@ function parseWalletReputation(payload) {
|
|
|
494
581
|
chainsWithIdentity: num(payload.chains_with_identity),
|
|
495
582
|
chainsWithReputation: num(payload.chains_with_reputation),
|
|
496
583
|
totalReviews: num(payload.total_reviews),
|
|
584
|
+
// `null` when absent or unreadable — NEVER `[]`. See `parseNotComputed`.
|
|
585
|
+
caveatsNotComputed: parseNotComputed(payload.caveats_not_computed),
|
|
497
586
|
policyVersion: optString(payload.policy_version),
|
|
498
587
|
caveats: parseCaveats(payload.caveats),
|
|
499
588
|
caveatScope: CAVEAT_SCOPE_FREE,
|
|
@@ -1167,9 +1256,11 @@ function resolveDistinctRaters(wallet) {
|
|
|
1167
1256
|
return best;
|
|
1168
1257
|
}
|
|
1169
1258
|
|
|
1259
|
+
exports.AUTHOR_CLASSES = AUTHOR_CLASSES;
|
|
1170
1260
|
exports.CAVEAT_CODES = CAVEAT_CODES;
|
|
1171
1261
|
exports.CAVEAT_SCOPE_FREE = CAVEAT_SCOPE_FREE;
|
|
1172
1262
|
exports.CAVEAT_SCOPE_METERED = CAVEAT_SCOPE_METERED;
|
|
1263
|
+
exports.CaveatsNotComputedError = CaveatsNotComputedError;
|
|
1173
1264
|
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
|
|
1174
1265
|
exports.DEFAULT_JITTER_MS = DEFAULT_JITTER_MS;
|
|
1175
1266
|
exports.DEFAULT_SITE_URL = DEFAULT_SITE_URL;
|
|
@@ -1197,6 +1288,7 @@ exports.failOpenCovers = failOpenCovers;
|
|
|
1197
1288
|
exports.failedAfterPaying = failedAfterPaying;
|
|
1198
1289
|
exports.formatScore = formatScore;
|
|
1199
1290
|
exports.hasCaveat = hasCaveat;
|
|
1291
|
+
exports.isKnownAuthorClass = isKnownAuthorClass;
|
|
1200
1292
|
exports.isKnownCaveatCode = isKnownCaveatCode;
|
|
1201
1293
|
exports.looksLikeOnchainId = looksLikeOnchainId;
|
|
1202
1294
|
exports.looksLikeSettlementReceipt = looksLikeSettlementReceipt;
|
|
@@ -1207,6 +1299,7 @@ exports.parseLeaderboard = parseLeaderboard;
|
|
|
1207
1299
|
exports.parseWalletBreakdown = parseWalletBreakdown;
|
|
1208
1300
|
exports.parseWalletReputation = parseWalletReputation;
|
|
1209
1301
|
exports.recoveryFor = recoveryFor;
|
|
1302
|
+
exports.requireFullCaveats = requireFullCaveats;
|
|
1210
1303
|
exports.resolveDistinctRaters = resolveDistinctRaters;
|
|
1211
1304
|
exports.roundScore = roundScore;
|
|
1212
1305
|
exports.userAgent = userAgent;
|