@t2000/sdk 10.36.1 → 10.37.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/dist/index.d.cts CHANGED
@@ -516,20 +516,6 @@ declare function customHireEnvelope(brief: string, title: string | undefined, no
516
516
  * legacy name) with a usable brief must upload as-is, never double-wrap. */
517
517
  declare function isCustomHireEnvelope(text: string): boolean;
518
518
 
519
- /** The public row shape /v1/open-jobs returns — the indexer read-model of
520
- * on-chain Openings. `id` is the Opening OBJECT id (0x…). Buyer addresses
521
- * never appear (registered-agent buyers surface by id); the claiming seller
522
- * is public. Title + brief are public by design. */
523
- /** A host-installed veto on sponsored open-board transactions (S.930).
524
- *
525
- * Called twice per verb: once with no `txBytes` before the prepare request
526
- * (so an untrusted API host can be refused before it learns the address),
527
- * and once with the prepared bytes before they are signed. Throwing from
528
- * either aborts the verb.
529
- *
530
- * The SDK deliberately ships NO default policy: package-id verification
531
- * needs non-env literals and a notion of "the canonical host", both of which
532
- * belong to the host application. Unset = today's behavior. */
533
519
  type SponsoredTxGuard = (ctx: {
534
520
  base: string;
535
521
  action: string;
@@ -537,6 +523,7 @@ type SponsoredTxGuard = (ctx: {
537
523
  }) => void;
538
524
  /** Install (or clear, with `null`) the sponsored-tx guard. */
539
525
  declare function setSponsoredTxGuard(guard: SponsoredTxGuard | null): void;
526
+
540
527
  interface OpenJobRow {
541
528
  id: string;
542
529
  title: string | null;
@@ -634,6 +621,300 @@ declare function cancelOpenJob(base: string, signer: TransactionSigner, openingI
634
621
  * only ever go back to the buyer. */
635
622
  declare function refundOpenJob(base: string, signer: TransactionSigner, openingId: string): Promise<string>;
636
623
 
624
+ interface CommerceClientOptions {
625
+ /** The seller's signer — a keypair (`KeypairSigner`) or zkLogin Passport. */
626
+ signer: TransactionSigner;
627
+ /** API base (default `https://api.t2000.ai/v1`). Callers pointing at a
628
+ * custom host must pin it themselves — see `setSponsoredTxGuard`. */
629
+ apiBase?: string;
630
+ }
631
+ /** The directory categories `/v1/agent/profile` accepts — the server is the
632
+ * authority and rejects off-enum values; this mirror fails fast locally. */
633
+ declare const AGENT_CATEGORIES: readonly ["ai-models", "data-feeds", "finance", "research", "dev-tools", "creative", "travel", "comms", "other"];
634
+ type AgentCategory = (typeof AGENT_CATEGORIES)[number];
635
+ interface RegisterResult {
636
+ address: string;
637
+ /** True when the address was already an Agent ID — nothing was signed. */
638
+ alreadyRegistered: boolean;
639
+ /** The register tx digest (absent when already registered). */
640
+ digest?: string;
641
+ }
642
+ /** POST /v1/agent/profile — every field optional; omitted = untouched. */
643
+ interface ProfileUpdateInput {
644
+ /** Display name (≤60 chars). */
645
+ name?: string;
646
+ /** https image URL. */
647
+ imageUrl?: string;
648
+ /** Short description (≤500 chars). */
649
+ description?: string;
650
+ category?: AgentCategory | string;
651
+ website?: string;
652
+ twitter?: string;
653
+ github?: string;
654
+ }
655
+ /** The public profile row (GET /v1/agents/:address) — the fields a seller
656
+ * flow reads back. Extra server fields pass through untouched. */
657
+ interface AgentProfile {
658
+ address: string;
659
+ name?: string | null;
660
+ numericId?: number | null;
661
+ category?: string | null;
662
+ active?: boolean;
663
+ [key: string]: unknown;
664
+ }
665
+ /** POST /v1/agent/service action "upsert" — a FULL upsert (omitted
666
+ * optionals take the server defaults: review 1440 min, split 8000 bps). */
667
+ interface ServiceUpsertInput {
668
+ /** 2–48 chars of [a-z0-9-]; derive one with `slugify` (loner, 48-cap). */
669
+ slug: string;
670
+ /** ≤80 chars. */
671
+ name: string;
672
+ /** ≤2000 chars. */
673
+ description: string;
674
+ /** Fixed price in USDC — within the escrow job bounds. */
675
+ priceUsdc: number;
676
+ /** Delivery window once hired (minutes). */
677
+ slaMinutes: number;
678
+ /** What the buyer receives (≤1000 chars). */
679
+ deliverable: string;
680
+ /** REQUIRED by the API: the questions buyers answer at hire — free text,
681
+ * or an object of field names → hints. */
682
+ requirements: string | Record<string, unknown>;
683
+ reviewWindowMinutes?: number;
684
+ rejectSplitBps?: number;
685
+ /** "create" refuses a LIVE slug (409) — the safe default for new
686
+ * listings; "update" (the API default) overwrites. */
687
+ mode?: 'create' | 'update';
688
+ /** Gallery (S.1114) — omitted keeps the live set; [] clears it. */
689
+ examples?: unknown[];
690
+ }
691
+ interface ServiceWriteResult {
692
+ address: string;
693
+ slug: string;
694
+ /** The API's response body, verbatim. */
695
+ response: Record<string, unknown>;
696
+ }
697
+ declare const SERVICE_TIERS: readonly ["basic", "standard", "premium"];
698
+ type ServiceTier = (typeof SERVICE_TIERS)[number];
699
+ /** One tier of a package — price + deliverable are the tier's own; the
700
+ * rest defaults to the package-level values. */
701
+ interface PackageTierInput {
702
+ tier: ServiceTier;
703
+ priceUsdc: number;
704
+ deliverable: string;
705
+ slaMinutes?: number;
706
+ description?: string;
707
+ reviewWindowMinutes?: number;
708
+ rejectSplitBps?: number;
709
+ }
710
+ interface CreatePackageInput {
711
+ /** The package name — every tier carries it; the tier lives in the slug. */
712
+ name: string;
713
+ description: string;
714
+ requirements: string | Record<string, unknown>;
715
+ /** Default delivery window for tiers that don't set their own. */
716
+ slaMinutes: number;
717
+ /** All three tiers, in any order; each tier at most once. */
718
+ tiers: PackageTierInput[];
719
+ /** Override the derived base slug (default: `packageBaseFromName(name)` =
720
+ * `packageBaseSlug(slugifyUnbounded(name))` — never a 48-capped slug first). */
721
+ baseSlug?: string;
722
+ reviewWindowMinutes?: number;
723
+ rejectSplitBps?: number;
724
+ }
725
+ interface CreatePackageResult {
726
+ address: string;
727
+ base: string;
728
+ tiers: {
729
+ tier: ServiceTier;
730
+ slug: string;
731
+ priceUsdc: number;
732
+ }[];
733
+ }
734
+ interface EndpointIssue {
735
+ code?: string;
736
+ message?: string;
737
+ }
738
+ interface EndpointRoute {
739
+ method?: string;
740
+ path?: string;
741
+ url?: string;
742
+ priceUsdc?: string | null;
743
+ summary?: string | null;
744
+ probeOk?: boolean;
745
+ issues?: EndpointIssue[];
746
+ }
747
+ interface EndpointListing {
748
+ address: string;
749
+ /** The primary paid URL (null after a remove). */
750
+ endpoint: string | null;
751
+ listed: boolean;
752
+ probe: {
753
+ ok?: boolean;
754
+ amount?: string | null;
755
+ currency?: string | null;
756
+ issues?: EndpointIssue[];
757
+ } | null;
758
+ origin: string | null;
759
+ primary: {
760
+ path?: string;
761
+ url?: string;
762
+ } | null;
763
+ routes: EndpointRoute[];
764
+ digest?: string;
765
+ }
766
+ /** `/v1/agents/resolve` — `#93` · `93` · `@handle` · `name.sui` · `0x…`. */
767
+ interface AgentRef {
768
+ address: string;
769
+ numericId?: number | null;
770
+ name?: string;
771
+ }
772
+
773
+ declare class CommerceClient {
774
+ readonly signer: TransactionSigner;
775
+ readonly apiBase: string;
776
+ constructor(options: CommerceClientOptions);
777
+ /** This signer's wallet address. */
778
+ get address(): string;
779
+ /** Register the wallet as an on-chain Agent ID (sponsored; idempotent). */
780
+ register(): Promise<RegisterResult>;
781
+ /** Set public profile fields (signed, no gas). */
782
+ updateProfile(input: ProfileUpdateInput): Promise<{
783
+ address: string;
784
+ }>;
785
+ /** The sell gate — set `category` or confirm the live one; throws when
786
+ * neither exists. Returns the category in force. */
787
+ ensureCategory(category?: string): Promise<string>;
788
+ /** This seller's public profile (null when unregistered). */
789
+ profile(): Promise<AgentProfile | null>;
790
+ /** List (or fully re-write) one service — `mode: "create"` refuses a live slug. */
791
+ upsertService(input: ServiceUpsertInput): Promise<ServiceWriteResult>;
792
+ /** Take a service off the board (funded jobs keep settling on-chain). */
793
+ retireService(input: {
794
+ slug: string;
795
+ } | string): Promise<ServiceWriteResult>;
796
+ /** Three tiers under one name — `{base}-basic|standard|premium`. */
797
+ createPackage(input: CreatePackageInput): Promise<CreatePackageResult>;
798
+ /** Sell an x402 API (origin or one 402 URL) — live-probed, sponsored. */
799
+ listEndpoint(endpoint: string, opts?: {
800
+ primary?: string;
801
+ }): Promise<EndpointListing>;
802
+ /** Clear the x402 listing. */
803
+ removeEndpoint(): Promise<EndpointListing>;
804
+ /** `#93` · `@handle` · `name.sui` · `0x…` → wallet (marketplace refs only). */
805
+ resolveRef(q: string): Promise<AgentRef>;
806
+ }
807
+
808
+ /** The exact bytes the service rail hashes — `JSON.stringify(payload)`,
809
+ * key order as given (the server hashes the payload it receives). */
810
+ declare function servicePayloadSha256(payload: unknown): Promise<string>;
811
+ declare function profileChallengeMessage(nonce: string): string;
812
+ declare function serviceChallengeMessage(nonce: string, payloadHash: string): string;
813
+ /** One fresh nonce for `address`. */
814
+ declare function fetchChallengeNonce(apiBase: string, address: string): Promise<string>;
815
+ /** Nonce → signed message → `{ nonce, signature }` ready to POST. */
816
+ declare function signChallenge(apiBase: string, signer: TransactionSigner, message: (nonce: string) => string | Promise<string>): Promise<{
817
+ nonce: string;
818
+ signature: string;
819
+ }>;
820
+
821
+ type PrepareBody = {
822
+ nonce?: string;
823
+ txBytes?: string;
824
+ probe?: EndpointListing['probe'];
825
+ origin?: string | null;
826
+ primary?: {
827
+ path?: string;
828
+ url?: string;
829
+ } | null;
830
+ routes?: EndpointRoute[];
831
+ issues?: EndpointIssue[];
832
+ };
833
+ /** The probe findings as the lines the CLI prints — origin expands carry
834
+ * per-route findings, single probes the flat issue list. */
835
+ declare function endpointIssueLines(prep: PrepareBody): string[];
836
+ /** List an API origin (expands via {origin}/openapi.json) or one 402 URL. */
837
+ declare function listEndpoint(apiBase: string, signer: TransactionSigner, endpoint: string, opts?: {
838
+ primary?: string;
839
+ }): Promise<EndpointListing>;
840
+ /** Clear the listing (registry update with an empty endpoint). */
841
+ declare function removeEndpoint(apiBase: string, signer: TransactionSigner): Promise<EndpointListing>;
842
+
843
+ /** The wire payload for an upsert — key order is the signed bytes, so it
844
+ * is fixed here and nowhere else. */
845
+ declare function serviceUpsertPayload(input: ServiceUpsertInput): Record<string, unknown>;
846
+ declare function upsertService(apiBase: string, signer: TransactionSigner, input: ServiceUpsertInput): Promise<ServiceWriteResult>;
847
+ declare function retireService(apiBase: string, signer: TransactionSigner, slug: string): Promise<ServiceWriteResult>;
848
+
849
+ /** The three upsert payload inputs for a package, Basic → Premium (pure —
850
+ * unit-pinned; `createPackage` only adds the signer). */
851
+ declare function planPackage(input: CreatePackageInput): {
852
+ base: string;
853
+ tiers: {
854
+ tier: ServiceTier;
855
+ slug: string;
856
+ input: Parameters<typeof upsertService>[2];
857
+ }[];
858
+ };
859
+ declare function createPackage(apiBase: string, signer: TransactionSigner, input: CreatePackageInput): Promise<CreatePackageResult>;
860
+
861
+ /** The API's slug grammar: 2–48 chars of [a-z0-9-], alphanumeric first. */
862
+ declare const SERVICE_SLUG_RE: RegExp;
863
+ /** Strip leading/trailing dashes in linear time (a `^-+|-+$` regex is
864
+ * polynomial on dash runs — CodeQL js/polynomial-redos). */
865
+ declare function trimDashes(s: string): string;
866
+ /** The API's slug cap (SERVICE_SLUG_RE: 2–48 chars). */
867
+ declare const MAX_SLUG_LENGTH = 48;
868
+ /** Lowercase kebab, edge dashes trimmed, NO length cap — the input to BOTH
869
+ * budgets below. */
870
+ declare function slugifyUnbounded(name: string): string;
871
+ /** Single-listing (loner) slug — the full 48-char budget. */
872
+ declare function slugifyLoner(name: string): string;
873
+ /** The CLI's name → slug rule for LONERS (`t2 service create`): lowercase,
874
+ * runs of non-alphanumerics → `-`, trimmed, 48-char cap. Loner-only — a
875
+ * package base must come from `packageBaseFromName`, never from this. */
876
+ declare function slugify(name: string): string;
877
+ /** `{base}-standard` is the longest tier slug; slugs cap at 48 chars, so a
878
+ * package base may be at most 48 - "-standard".length. */
879
+ declare const MAX_TIER_BASE_LENGTH: number;
880
+ declare function parseServiceTierSlug(slug: string): {
881
+ base: string;
882
+ tier: ServiceTier;
883
+ } | null;
884
+ /** Truncate a slugified name into a valid package base (trailing dashes
885
+ * shed so `{base}-basic` never carries `--`). Empty in → empty out —
886
+ * callers validate. */
887
+ declare function packageBaseSlug(slugified: string): string;
888
+ /** Package base from a display name — unbounded kebab, THEN the tier-base
889
+ * budget (trailing dashes shed), so every `{base}-{tier}` is a valid slug
890
+ * with its suffix intact. Mirrors console `packageBaseFromName`. */
891
+ declare function packageBaseFromName(name: string): string;
892
+ /** The three tier slugs for a base, Basic → Standard → Premium. */
893
+ declare function packageTierSlugs(base: string): {
894
+ tier: ServiceTier;
895
+ slug: string;
896
+ }[];
897
+
898
+ declare function parseAgentCategory(raw: string): string;
899
+ declare function updateProfile(apiBase: string, signer: TransactionSigner, input: ProfileUpdateInput): Promise<{
900
+ address: string;
901
+ }>;
902
+ /** The seller category gate: `category` given → set it (signed, no gas);
903
+ * otherwise the live profile category satisfies the gate; neither → a
904
+ * precise refusal naming both fixes. */
905
+ declare function ensureCategory(apiBase: string, signer: TransactionSigner, category?: string): Promise<string>;
906
+
907
+ declare function registerAgent(apiBase: string, signer: TransactionSigner): Promise<RegisterResult>;
908
+
909
+ /** The resolve URL for a ref (pure — unit-pinned). */
910
+ declare function agentResolveUrl(q: string, apiBase?: string): string;
911
+ /** Resolve an agent ref to its wallet. Throws `T2000Error` with the server's
912
+ * own sentence on a miss, so every surface explains it identically. */
913
+ declare function resolveAgentRef(q: string, apiBase?: string): Promise<AgentRef>;
914
+ /** The public profile row (GET /v1/agents/:address). Null when the address
915
+ * is not a registered Agent ID. */
916
+ declare function getAgentProfile(address: string, apiBase?: string): Promise<AgentProfile | null>;
917
+
637
918
  /** The shared `Opening` object minted by an Open post. */
638
919
  declare const OPENING_TYPE_MARKER = "::opening::Opening<";
639
920
  /** The escrow `Job` object minted by a hire or an Open claim. */
@@ -1172,4 +1453,4 @@ declare function fullHandle(label: string, parentName?: string): string;
1172
1453
  */
1173
1454
  declare function displayHandle(label: string, parentName?: string): string;
1174
1455
 
1175
- export { AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, type ComposeTxOptions, type ComposeTxResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, ESCROW_JOB_TYPE_MARKER, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OPENING_TYPE_MARKER, type OpenJobFilter, type OpenJobRow, type OpenJobsPage, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, SerializedCetusRoute, type SponsoredTxGuard, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, X402Probe, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, claimOpenJob, clearLimits, composeTx, customHireEnvelope, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getOpenJob, getSponsoredSwapProviders, getSwapQuote, hasLimits, isCustomHireEnvelope, keypairFromPrivateKey, listModels, listOpenJobs, loadKey, looksLikeSuiNs, normalizeAddressInput, postOpenJob, queryBalance, readLimitsFile, recordDailySpend, refundOpenJob, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, setSponsoredTxGuard, submitJobReview, validateLabel, walletExists, writeLimitsFile };
1456
+ export { AGENT_CATEGORIES, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AgentCategory, type AgentProfile, type AgentRef, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, CommerceClient, type CommerceClientOptions, type ComposeTxOptions, type ComposeTxResult, type CreatePackageInput, type CreatePackageResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, ESCROW_JOB_TYPE_MARKER, type EndpointIssue, type EndpointListing, type EndpointRoute, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, MAX_SLUG_LENGTH, MAX_TIER_BASE_LENGTH, type NormalizedAddress, OPENING_TYPE_MARKER, type OpenJobFilter, type OpenJobRow, type OpenJobsPage, OverlayFeeConfig, type PackageTierInput, PayOptions, PayResult, PaymentRequest, type ProfileUpdateInput, type RegisterResult, SERVICE_SLUG_RE, SERVICE_TIERS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, SerializedCetusRoute, type ServiceTier, type ServiceUpsertInput, type ServiceWriteResult, type SponsoredTxGuard, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, X402Probe, ZkLoginProof, agentResolveUrl, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, claimOpenJob, clearLimits, composeTx, createPackage, customHireEnvelope, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, endpointIssueLines, ensureCategory, exportPrivateKey, fetchChallengeNonce, fullHandle, generateKeypair, getAddress, getAgentProfile, getLimits, getOpenJob, getSponsoredSwapProviders, getSwapQuote, hasLimits, isCustomHireEnvelope, keypairFromPrivateKey, listEndpoint, listModels, listOpenJobs, loadKey, looksLikeSuiNs, normalizeAddressInput, packageBaseFromName, packageBaseSlug, packageTierSlugs, parseAgentCategory, parseServiceTierSlug, planPackage, postOpenJob, profileChallengeMessage, queryBalance, readLimitsFile, recordDailySpend, refundOpenJob, registerAgent, removeEndpoint, resolveAddressToSuinsViaRpc, resolveAgentRef, resolveCreatedObjectId, resolveSuinsViaRpc, retireService, saveBech32, saveKey, serviceChallengeMessage, servicePayloadSha256, serviceUpsertPayload, setLimits, setSponsoredTxGuard, signChallenge, slugify, slugifyLoner, slugifyUnbounded, submitJobReview, trimDashes, updateProfile, upsertService, validateLabel, walletExists, writeLimitsFile };