@tetsuo-ai/marketplace-react 0.1.0 → 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.
Files changed (65) hide show
  1. package/CHANGELOG.md +29 -3
  2. package/README.md +50 -20
  3. package/dist/{chunk-ABS77JB2.js → chunk-D2TDU3TJ.js} +3 -3
  4. package/dist/{chunk-ABS77JB2.js.map → chunk-D2TDU3TJ.js.map} +1 -1
  5. package/dist/{chunk-GN5DYVN5.js → chunk-ECU7HGO3.js} +6 -5
  6. package/dist/chunk-ECU7HGO3.js.map +1 -0
  7. package/dist/{chunk-YORZNYZZ.js → chunk-FAIRTAIB.js} +53 -17
  8. package/dist/chunk-FAIRTAIB.js.map +1 -0
  9. package/dist/{chunk-5OTKSRHM.js → chunk-MNJ2EQDJ.js} +3 -3
  10. package/dist/{chunk-5OTKSRHM.js.map → chunk-MNJ2EQDJ.js.map} +1 -1
  11. package/dist/{chunk-KJMR6OGC.js → chunk-WJUVTFJ7.js} +105 -9
  12. package/dist/chunk-WJUVTFJ7.js.map +1 -0
  13. package/dist/components/agenc-components.css +20 -0
  14. package/dist/components/index.cjs +147 -17
  15. package/dist/components/index.cjs.map +1 -1
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.ts +2 -2
  18. package/dist/components/index.js +3 -3
  19. package/dist/hooks/index.cjs +350 -28
  20. package/dist/hooks/index.cjs.map +1 -1
  21. package/dist/hooks/index.d.cts +160 -36
  22. package/dist/hooks/index.d.ts +160 -36
  23. package/dist/hooks/index.js +299 -19
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/{index-BLrlBVj-.d.cts → index-C9R3B80j.d.ts} +176 -47
  26. package/dist/{index-CKTYsNPH.d.ts → index-CTTh1ZPg.d.cts} +176 -47
  27. package/dist/index.cjs +168 -33
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +10 -19
  30. package/dist/index.d.ts +10 -19
  31. package/dist/index.js +17 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/signers/index.cjs +4 -3
  34. package/dist/signers/index.cjs.map +1 -1
  35. package/dist/signers/index.js +2 -2
  36. package/dist/{useAgentTrackRecord-BLf1nrbu.d.cts → useAgentTrackRecord-BCvRHYM2.d.cts} +7 -7
  37. package/dist/{useAgentTrackRecord-BLf1nrbu.d.ts → useAgentTrackRecord-BCvRHYM2.d.ts} +7 -7
  38. package/package.json +4 -3
  39. package/src/components/HireButton.tsx +1 -2
  40. package/src/components/HireCheckoutModal.tsx +8 -9
  41. package/src/components/ProviderCard.stories.tsx +54 -4
  42. package/src/components/ProviderCard.tsx +113 -9
  43. package/src/components/ReferrerDisclosure.tsx +8 -12
  44. package/src/components/__fixtures__/index.tsx +28 -0
  45. package/src/components/agenc-components.css +20 -0
  46. package/src/components/index.ts +12 -0
  47. package/src/components/strings.ts +10 -2
  48. package/src/components/useAgentVerification.ts +223 -0
  49. package/src/hooks/index.ts +47 -4
  50. package/src/hooks/internal.ts +74 -2
  51. package/src/hooks/useHire.ts +30 -38
  52. package/src/hooks/useHumanlessHireFlow.ts +259 -0
  53. package/src/hooks/useRateHire.ts +52 -0
  54. package/src/hooks/useReferrerEarnings.ts +32 -33
  55. package/src/hooks/useTaskActivation.ts +58 -0
  56. package/src/hooks/useTaskLifecycle.ts +110 -0
  57. package/src/hooks/useTaskWork.ts +76 -0
  58. package/src/index.ts +12 -2
  59. package/src/provider/AgencProvider.tsx +3 -3
  60. package/src/provider/referrer.ts +24 -32
  61. package/src/strings/index.ts +5 -3
  62. package/src/types.ts +7 -10
  63. package/dist/chunk-GN5DYVN5.js.map +0 -1
  64. package/dist/chunk-KJMR6OGC.js.map +0 -1
  65. package/dist/chunk-YORZNYZZ.js.map +0 -1
@@ -14,11 +14,12 @@ var EN_STRINGS = {
14
14
  "provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
15
15
  "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
16
16
  "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
17
- // Referrer config validation (the P6.2 gate surface).
17
+ // Referrer config validation / capability surface.
18
18
  "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
19
19
  "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
20
- "referrer.notLive": "This site earns a referral fee (pending protocol support).",
21
- "referrer.notLiveReason": "Referral settlement is not yet deployed on this cluster (PLAN.md P6.2). Referrer config is accepted and validated but not injected into hires.",
20
+ "referrer.notLive": "Referral fee is not active for this hire.",
21
+ "referrer.notLiveReason": "No referrer is configured for this provider.",
22
+ "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
22
23
  // Read transport.
23
24
  "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
24
25
  // Generic loading / empty / error states (components extend these).
@@ -79,9 +80,9 @@ var EN_COMPONENT_STRINGS = {
79
80
  "components.hire.moderationPending": "Moderation pending",
80
81
  "components.hire.moderationIssues": "Moderation issues found",
81
82
  "components.hire.notConnected": "Connect a wallet to hire.",
82
- // Referrer disclosure (P6.2 gate — never claims a live fee).
83
+ // Referrer disclosure.
83
84
  "components.referrer.disclosure": "This site earns a referral fee.",
84
- "components.referrer.disclosurePending": "This site earns a referral fee (pending protocol support).",
85
+ "components.referrer.disclosurePending": "Referral fee is not active for this hire.",
85
86
  "components.referrer.feeBps": "{bps} bps",
86
87
  // TaskTimeline.
87
88
  "components.taskTimeline.title": "Task progress",
@@ -121,6 +122,13 @@ var EN_COMPONENT_STRINGS = {
121
122
  "components.provider.provisional": "provisional",
122
123
  "components.provider.noData": "No track record yet.",
123
124
  "components.provider.unavailable": "Track record is unavailable on this read transport.",
125
+ // Domain trust (P7.3) — VERIFIED is an on-chain attestation; CLAIMED is the
126
+ // operator's self-reported metadata. The copy keeps them distinct so a buyer
127
+ // never reads an unverified claim as a proven one.
128
+ "components.provider.verifiedDomain": "Verified: {domain}",
129
+ "components.provider.verifiedDomainLabel": "Verified domain {domain}",
130
+ "components.provider.claimedDomain": "Claims: {domain}",
131
+ "components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)",
124
132
  // PoweredByAgenC.
125
133
  "components.poweredBy.label": "Powered by AgenC",
126
134
  "components.poweredBy.trustLink": "Learn how this works"
@@ -629,6 +637,36 @@ function requireClient(client) {
629
637
  }
630
638
  return client;
631
639
  }
640
+ function resolveReferrerArgs(ctx) {
641
+ const capability = ctx.resolveReferrerCapability();
642
+ if (!capability.live || !capability.referrer) {
643
+ return { referrerArgs: {}, referrerInjected: false };
644
+ }
645
+ return {
646
+ referrerArgs: {
647
+ referrer: capability.referrer.wallet,
648
+ referrerFeeBps: capability.referrer.feeBps
649
+ },
650
+ referrerInjected: true
651
+ };
652
+ }
653
+ function signerAddress(signerOrAddress) {
654
+ if (typeof signerOrAddress === "string") {
655
+ return signerOrAddress;
656
+ }
657
+ if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
658
+ return signerOrAddress.address;
659
+ }
660
+ throw new Error("Expected a TransactionSigner or Address with an address field.");
661
+ }
662
+ function withoutReferrerArgs(input) {
663
+ const {
664
+ referrer: _referrer,
665
+ referrerFeeBps: _referrerFeeBps,
666
+ ...rest
667
+ } = input;
668
+ return rest;
669
+ }
632
670
 
633
671
  // src/hooks/useHire.ts
634
672
  function useHire() {
@@ -636,29 +674,29 @@ function useHire() {
636
674
  const mutation = reactQuery.useMutation({
637
675
  mutationFn: async (input) => {
638
676
  const client = requireClient(ctx.client);
639
- const capability = ctx.resolveReferrerCapability();
640
- const referrerInjected = capability.live && ctx.referrer !== null;
677
+ const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
678
+ const hireInput = withoutReferrerArgs(input);
641
679
  const creator = input.creator ?? client.signer;
642
680
  let signature;
643
681
  if (input.humanless === true) {
644
- const ix = await marketplaceSdk.facade.hireFromListingHumanless({
645
- ...input,
646
- creator
647
- // NOTE: P6.2 referrer fields would spread here under capability.live.
682
+ const result = await client.hireFromListingHumanless({
683
+ ...hireInput,
684
+ creator,
685
+ ...referrerArgs
648
686
  });
649
- ({ signature } = await client.send([ix]));
687
+ signature = result.signature;
650
688
  } else {
651
689
  const authority = input.authority ?? client.signer;
652
690
  const result = await client.hireFromListing({
653
- ...input,
691
+ ...hireInput,
654
692
  authority,
655
- creator
656
- // NOTE: P6.2 referrer fields would spread here under capability.live.
693
+ creator,
694
+ ...referrerArgs
657
695
  });
658
696
  signature = result.signature;
659
697
  }
660
698
  const [taskPda] = await marketplaceSdk.findTaskPda({
661
- creator: typeof creator === "object" && creator !== null && "address" in creator ? creator.address : creator,
699
+ creator: signerAddress(creator),
662
700
  taskId: input.taskId
663
701
  });
664
702
  return { signature, taskPda, referrerInjected };
@@ -1174,9 +1212,90 @@ function DisputeBanner({
1174
1212
  ) : null
1175
1213
  ] });
1176
1214
  }
1215
+ var UNVERIFIED = Object.freeze({
1216
+ verified: false
1217
+ });
1218
+ function evaluateAgentVerification(account, nowSeconds) {
1219
+ if (!account) return UNVERIFIED;
1220
+ if (account.revoked) return UNVERIFIED;
1221
+ if (account.expiresAt !== 0n && nowSeconds >= account.expiresAt) {
1222
+ return UNVERIFIED;
1223
+ }
1224
+ return {
1225
+ verified: true,
1226
+ domain: account.verifiedDomain,
1227
+ method: account.method,
1228
+ verifiedBy: account.verifiedBy,
1229
+ verifiedAt: account.verifiedAt,
1230
+ expiresAt: account.expiresAt,
1231
+ revoked: false
1232
+ };
1233
+ }
1234
+ function defaultNow() {
1235
+ return BigInt(Math.floor(Date.now() / 1e3));
1236
+ }
1237
+ function agentVerificationReaderFromRpc(rpc, options) {
1238
+ const now = options?.now ?? defaultNow;
1239
+ return async (agentPda) => {
1240
+ const [pda] = await marketplaceSdk.findAgentVerificationPda({ agent: agentPda });
1241
+ const maybe = await marketplaceSdk.fetchMaybeAgentVerification(rpc, pda);
1242
+ return evaluateAgentVerification(maybe.exists ? maybe.data : null, now());
1243
+ };
1244
+ }
1245
+ function useAgentVerification(agentPda, options) {
1246
+ const reader = options?.reader;
1247
+ const enabled = (options?.enabled ?? true) && Boolean(agentPda) && Boolean(reader);
1248
+ const query = reactQuery.useQuery({
1249
+ queryKey: ["agenc", "agentVerification", agentPda ? String(agentPda) : ""],
1250
+ enabled,
1251
+ queryFn: async () => {
1252
+ return reader(agentPda);
1253
+ }
1254
+ });
1255
+ const verification = query.error ? UNVERIFIED : query.data ?? UNVERIFIED;
1256
+ return {
1257
+ verification,
1258
+ verified: verification.verified,
1259
+ isLoading: query.isLoading && enabled,
1260
+ error: query.error ?? null,
1261
+ refetch: () => void query.refetch()
1262
+ };
1263
+ }
1264
+ function VerifiedDomainBadge({
1265
+ domain,
1266
+ unstyled
1267
+ }) {
1268
+ return /* @__PURE__ */ jsxRuntime.jsx(
1269
+ Badge,
1270
+ {
1271
+ tone: "success",
1272
+ unstyled,
1273
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--verified",
1274
+ label: tc("components.provider.verifiedDomainLabel", { domain }),
1275
+ children: tc("components.provider.verifiedDomain", { domain })
1276
+ }
1277
+ );
1278
+ }
1279
+ function ClaimedDomainBadge({
1280
+ domain,
1281
+ unstyled
1282
+ }) {
1283
+ return /* @__PURE__ */ jsxRuntime.jsx(
1284
+ Badge,
1285
+ {
1286
+ tone: "neutral",
1287
+ unstyled,
1288
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--claimed",
1289
+ label: tc("components.provider.claimedDomainLabel", { domain }),
1290
+ children: tc("components.provider.claimedDomain", { domain })
1291
+ }
1292
+ );
1293
+ }
1177
1294
  function ProviderCard({
1178
1295
  agent,
1179
1296
  trackRecord,
1297
+ verification = UNVERIFIED,
1298
+ operatorDomain,
1180
1299
  verified = false,
1181
1300
  isLoading = false,
1182
1301
  error = null,
@@ -1185,12 +1304,19 @@ function ProviderCard({
1185
1304
  className
1186
1305
  }) {
1187
1306
  const cardClass = rootClass("agenc-provider", unstyled, className);
1307
+ const isVerified = verification.verified || verification === UNVERIFIED && verified;
1308
+ const verifiedDomain = verification.verified ? verification.domain : null;
1309
+ const claimed = typeof operatorDomain === "string" && operatorDomain.trim() !== "" ? operatorDomain.trim() : null;
1310
+ const domainBadge = verifiedDomain ? /* @__PURE__ */ jsxRuntime.jsx(VerifiedDomainBadge, { domain: verifiedDomain, unstyled }) : claimed ? /* @__PURE__ */ jsxRuntime.jsx(ClaimedDomainBadge, { domain: claimed, unstyled }) : null;
1188
1311
  const header = /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-provider__header", children: [
1189
1312
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__id", children: [
1190
1313
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__label", children: tc("components.provider.title") }),
1191
1314
  agent ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__pda", children: truncateAddress(agent) }) : null
1192
1315
  ] }),
1193
- /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified, unstyled })
1316
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__badges", children: [
1317
+ domainBadge,
1318
+ /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified: isVerified, unstyled })
1319
+ ] })
1194
1320
  ] });
1195
1321
  if (error) {
1196
1322
  return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
@@ -1316,12 +1442,15 @@ exports.ReviewPanel = ReviewPanel;
1316
1442
  exports.Spinner = Spinner;
1317
1443
  exports.StateMessage = StateMessage;
1318
1444
  exports.TaskTimeline = TaskTimeline;
1445
+ exports.UNVERIFIED = UNVERIFIED;
1319
1446
  exports.VerifiedBadge = VerifiedBadge;
1447
+ exports.agentVerificationReaderFromRpc = agentVerificationReaderFromRpc;
1320
1448
  exports.cx = cx;
1321
1449
  exports.decodeListingCategory = decodeListingCategory;
1322
1450
  exports.decodeListingName = decodeListingName;
1323
1451
  exports.decodeListingTags = decodeListingTags;
1324
1452
  exports.elementClass = elementClass;
1453
+ exports.evaluateAgentVerification = evaluateAgentVerification;
1325
1454
  exports.formatPriceSol = formatPriceSol;
1326
1455
  exports.formatRate = formatRate;
1327
1456
  exports.formatSol = formatSol;
@@ -1330,6 +1459,7 @@ exports.rootClass = rootClass;
1330
1459
  exports.tc = tc;
1331
1460
  exports.toHex = toHex;
1332
1461
  exports.truncateAddress = truncateAddress;
1462
+ exports.useAgentVerification = useAgentVerification;
1333
1463
  exports.useFocusTrap = useFocusTrap;
1334
1464
  //# sourceMappingURL=index.cjs.map
1335
1465
  //# sourceMappingURL=index.cjs.map