@tetsuo-ai/marketplace-react 0.3.2 → 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.
Files changed (42) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/{chunk-ZAMIL27X.js → chunk-JVXGNW3Q.js} +35 -4
  3. package/dist/chunk-JVXGNW3Q.js.map +1 -0
  4. package/dist/chunk-XLA7DARS.js +255 -0
  5. package/dist/chunk-XLA7DARS.js.map +1 -0
  6. package/dist/components/index.cjs +179 -43
  7. package/dist/components/index.cjs.map +1 -1
  8. package/dist/components/index.d.cts +2 -2
  9. package/dist/components/index.d.ts +2 -2
  10. package/dist/components/index.js +2 -2
  11. package/dist/hooks/index.cjs +206 -40
  12. package/dist/hooks/index.cjs.map +1 -1
  13. package/dist/hooks/index.d.cts +64 -4
  14. package/dist/hooks/index.d.ts +64 -4
  15. package/dist/hooks/index.js +98 -46
  16. package/dist/hooks/index.js.map +1 -1
  17. package/dist/{index-DQ3Xovkq.d.ts → index-CmVz0OOm.d.ts} +50 -5
  18. package/dist/{index-UxuvIlmD.d.cts → index-DAZzhuO4.d.cts} +50 -5
  19. package/dist/index.cjs +168 -33
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +3 -3
  24. package/dist/{useAgentTrackRecord-BCvRHYM2.d.cts → useAgentTrackRecord-DPt3SfYz.d.cts} +39 -2
  25. package/dist/{useAgentTrackRecord-BCvRHYM2.d.ts → useAgentTrackRecord-DPt3SfYz.d.ts} +39 -2
  26. package/package.json +2 -2
  27. package/src/components/GuaranteedBadge.tsx +73 -0
  28. package/src/components/index.ts +4 -0
  29. package/src/components/strings.ts +8 -0
  30. package/src/hooks/index.ts +13 -0
  31. package/src/hooks/internal.ts +3 -0
  32. package/src/hooks/moderation-attestor.ts +176 -57
  33. package/src/hooks/useCompletionBond.ts +156 -0
  34. package/src/hooks/useHire.ts +27 -0
  35. package/src/hooks/useHumanlessHireFlow.ts +74 -17
  36. package/src/hooks/useTaskActivation.ts +19 -13
  37. package/src/hooks/useTaskGuarantee.ts +120 -0
  38. package/src/index.ts +2 -0
  39. package/src/types.ts +5 -2
  40. package/dist/chunk-2Y6JN2VZ.js +0 -143
  41. package/dist/chunk-2Y6JN2VZ.js.map +0 -1
  42. package/dist/chunk-ZAMIL27X.js.map +0 -1
@@ -1,5 +1,5 @@
1
- export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-UxuvIlmD.cjs';
1
+ export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from '../index-DAZzhuO4.cjs';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
+ import '../useAgentTrackRecord-DPt3SfYz.cjs';
4
5
  import '@solana/kit';
5
- import '../useAgentTrackRecord-BCvRHYM2.cjs';
@@ -1,5 +1,5 @@
1
- export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-DQ3Xovkq.js';
1
+ export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from '../index-CmVz0OOm.js';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
+ import '../useAgentTrackRecord-DPt3SfYz.js';
4
5
  import '@solana/kit';
5
- import '../useAgentTrackRecord-BCvRHYM2.js';
@@ -1,5 +1,5 @@
1
- export { Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, UNVERIFIED, VerifiedBadge, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from '../chunk-ZAMIL27X.js';
2
- import '../chunk-2Y6JN2VZ.js';
1
+ export { Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, GuaranteedBadge, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, UNVERIFIED, VerifiedBadge, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from '../chunk-JVXGNW3Q.js';
2
+ import '../chunk-XLA7DARS.js';
3
3
  import '../chunk-H6PJIDQR.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
@@ -61,6 +61,8 @@ var queryKeys = {
61
61
  taskStatus: (taskPda) => [QUERY_KEY_ROOT, "taskStatus", taskPda],
62
62
  /** One task's dispute record. */
63
63
  dispute: (taskPda) => [QUERY_KEY_ROOT, "dispute", taskPda],
64
+ /** One task's completion-bond ("Guaranteed Hire") state. */
65
+ taskGuarantee: (taskPda) => [QUERY_KEY_ROOT, "taskGuarantee", taskPda],
64
66
  /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */
65
67
  referrerEarnings: (wallet) => [QUERY_KEY_ROOT, "referrerEarnings", wallet]
66
68
  };
@@ -300,6 +302,103 @@ function useTaskStatus(taskPda, options) {
300
302
  refetch: () => void query.refetch()
301
303
  };
302
304
  }
305
+ function useTaskGuarantee(taskPda, options) {
306
+ const ctx = useAgencContext();
307
+ const injected = options?.guaranteeReader;
308
+ const rpcUrl = ctx.rpcUrl;
309
+ const reader = react.useMemo(() => {
310
+ if (injected) return injected;
311
+ if (!rpcUrl) return null;
312
+ return (pda) => marketplaceSdk.fetchTaskGuarantee(
313
+ kit.createSolanaRpc(rpcUrl),
314
+ pda
315
+ );
316
+ }, [injected, rpcUrl]);
317
+ const enabled = (options?.enabled ?? true) && Boolean(taskPda) && reader !== null;
318
+ const query = reactQuery.useQuery({
319
+ queryKey: queryKeys.taskGuarantee(taskPda ? pdaKey(taskPda) : ""),
320
+ enabled,
321
+ queryFn: () => reader(taskPda)
322
+ });
323
+ const guarantee = query.data ?? null;
324
+ return {
325
+ guarantee,
326
+ guaranteed: guarantee?.guaranteed ?? false,
327
+ isLoading: query.isLoading,
328
+ error: query.error ?? null,
329
+ refetch: () => void query.refetch()
330
+ };
331
+ }
332
+ function readRpc(input) {
333
+ return input.rpc ?? (input.rpcUrl ? kit.createSolanaRpc(input.rpcUrl) : null);
334
+ }
335
+ async function resolveRosterEntry(rpc, moderator) {
336
+ const [moderationConfigPda] = await marketplaceSdk.findModerationConfigPda();
337
+ const moderationConfig = await marketplaceSdk.fetchMaybeModerationConfig(
338
+ rpc,
339
+ moderationConfigPda
340
+ );
341
+ if (moderationConfig.exists && moderationConfig.data.moderationAuthority === moderator) {
342
+ return void 0;
343
+ }
344
+ const [rosterPda] = await marketplaceSdk.findModerationAttestorPda({ attestor: moderator });
345
+ const roster = await marketplaceSdk.fetchMaybeModerationAttestor(rpc, rosterPda);
346
+ return roster.exists ? rosterPda : void 0;
347
+ }
348
+ async function resolveActivationModerationAccounts(input) {
349
+ try {
350
+ const rpc = readRpc(input);
351
+ if (!rpc) return {};
352
+ const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);
353
+ const attestorPart = moderationAttestor !== void 0 ? { moderationAttestor } : {};
354
+ const [v2Pda] = await marketplaceSdk.findTaskModerationPda({
355
+ task: input.task,
356
+ jobSpecHash: input.jobSpecHash,
357
+ moderator: input.moderator
358
+ });
359
+ const v2 = await marketplaceSdk.fetchMaybeTaskModeration(rpc, v2Pda);
360
+ if (v2.exists) return attestorPart;
361
+ const [legacyPda] = await marketplaceSdk.facade.findLegacyTaskModerationPda({
362
+ task: input.task,
363
+ jobSpecHash: input.jobSpecHash
364
+ });
365
+ const legacy = await marketplaceSdk.fetchMaybeTaskModeration(rpc, legacyPda);
366
+ if (legacy.exists && legacy.data.moderator === input.moderator) {
367
+ return { ...attestorPart, taskModeration: legacyPda };
368
+ }
369
+ return attestorPart;
370
+ } catch {
371
+ return {};
372
+ }
373
+ }
374
+ async function resolveHireListingModerationAccounts(input) {
375
+ try {
376
+ const rpc = readRpc(input);
377
+ if (!rpc) return {};
378
+ const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);
379
+ const attestorPart = moderationAttestor !== void 0 ? { moderationAttestor } : {};
380
+ const [v2Pda] = await marketplaceSdk.findListingModerationPda({
381
+ listing: input.listing,
382
+ jobSpecHash: input.listingSpecHash,
383
+ moderator: input.moderator
384
+ });
385
+ const v2 = await marketplaceSdk.fetchMaybeListingModeration(rpc, v2Pda);
386
+ if (v2.exists) return attestorPart;
387
+ const [legacyPda] = await marketplaceSdk.facade.findLegacyListingModerationPda({
388
+ listing: input.listing,
389
+ jobSpecHash: input.listingSpecHash
390
+ });
391
+ const legacy = await marketplaceSdk.fetchMaybeListingModeration(rpc, legacyPda);
392
+ if (legacy.exists && legacy.data.moderator === input.moderator) {
393
+ return { ...attestorPart, listingModeration: legacyPda };
394
+ }
395
+ return attestorPart;
396
+ } catch {
397
+ return {};
398
+ }
399
+ }
400
+
401
+ // src/hooks/useHire.ts
303
402
  function useHire() {
304
403
  const ctx = useAgencContext();
305
404
  const mutation = reactQuery.useMutation({
@@ -307,11 +406,22 @@ function useHire() {
307
406
  const client = requireClient(ctx.client);
308
407
  const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
309
408
  const hireInput = withoutReferrerArgs(input);
409
+ const listingSpecHash = input.listingSpecHash;
410
+ let moderationArgs = {};
411
+ if (input.moderationAttestor === void 0 && input.moderatorIsAttestor === void 0 && input.listingModeration === void 0 && listingSpecHash !== void 0) {
412
+ moderationArgs = await resolveHireListingModerationAccounts({
413
+ rpcUrl: ctx.rpcUrl,
414
+ listing: input.listing,
415
+ listingSpecHash,
416
+ moderator: input.moderator
417
+ });
418
+ }
310
419
  const creator = input.creator ?? client.signer;
311
420
  let signature;
312
421
  if (input.humanless === true) {
313
422
  const result = await client.hireFromListingHumanless({
314
423
  ...hireInput,
424
+ ...moderationArgs,
315
425
  creator,
316
426
  ...referrerArgs
317
427
  });
@@ -320,6 +430,7 @@ function useHire() {
320
430
  const authority = input.authority ?? client.signer;
321
431
  const result = await client.hireFromListing({
322
432
  ...hireInput,
433
+ ...moderationArgs,
323
434
  authority,
324
435
  creator,
325
436
  ...referrerArgs
@@ -431,50 +542,21 @@ function useSubmissionReview(taskPda) {
431
542
  }
432
543
  };
433
544
  }
434
- async function resolveActivationModerationAttestor(input) {
435
- try {
436
- const rpc = input.rpc ?? (input.rpcUrl ? kit.createSolanaRpc(input.rpcUrl) : null);
437
- if (!rpc) return void 0;
438
- const [taskModerationPda] = await marketplaceSdk.findTaskModerationPda({
439
- task: input.task,
440
- jobSpecHash: input.jobSpecHash
441
- });
442
- const taskModeration = await marketplaceSdk.fetchMaybeTaskModeration(
443
- rpc,
444
- taskModerationPda
445
- );
446
- if (!taskModeration.exists) return void 0;
447
- const [moderationConfigPda] = await marketplaceSdk.findModerationConfigPda();
448
- const moderationConfig = await marketplaceSdk.fetchMaybeModerationConfig(
449
- rpc,
450
- moderationConfigPda
451
- );
452
- if (moderationConfig.exists && taskModeration.data.moderator === moderationConfig.data.moderationAuthority) {
453
- return void 0;
454
- }
455
- const [rosterPda] = await marketplaceSdk.findModerationAttestorPda({
456
- attestor: taskModeration.data.moderator
457
- });
458
- return rosterPda;
459
- } catch {
460
- return void 0;
461
- }
462
- }
463
-
464
- // src/hooks/useTaskActivation.ts
465
545
  function useTaskActivation(taskPda) {
466
546
  const ctx = useAgencContext();
467
547
  const mutation = reactQuery.useMutation({
468
548
  mutationFn: async (input) => {
469
549
  const client = requireClient(ctx.client);
470
- const moderationAttestor = input.moderationAttestor ?? await resolveActivationModerationAttestor({
550
+ const callerResolved = input.moderationAttestor !== void 0 || input.moderatorIsAttestor !== void 0 || input.taskModeration !== void 0;
551
+ const resolved = callerResolved ? {} : await resolveActivationModerationAccounts({
471
552
  rpcUrl: ctx.rpcUrl,
472
553
  task: taskPda,
473
- jobSpecHash: input.jobSpecHash
554
+ jobSpecHash: input.jobSpecHash,
555
+ moderator: input.moderator
474
556
  });
475
557
  const { signature } = await client.setTaskJobSpec({
476
558
  ...input,
477
- ...moderationAttestor !== void 0 ? { moderationAttestor } : {},
559
+ ...resolved,
478
560
  task: taskPda,
479
561
  creator: input.creator ?? client.signer
480
562
  });
@@ -521,7 +603,16 @@ function validateModerationResult(result) {
521
603
  "Task moderation returned an empty jobSpecUri; activation was not signed."
522
604
  );
523
605
  }
524
- return { jobSpecHash: result.jobSpecHash, jobSpecUri };
606
+ if (typeof result.moderator !== "string" || !result.moderator.trim()) {
607
+ throw new Error(
608
+ "Task moderation returned no moderator pubkey; activation was not signed."
609
+ );
610
+ }
611
+ return {
612
+ jobSpecHash: result.jobSpecHash,
613
+ jobSpecUri,
614
+ moderator: result.moderator
615
+ };
525
616
  }
526
617
  function useHumanlessHireFlow() {
527
618
  const ctx = useAgencContext();
@@ -537,8 +628,19 @@ function useHumanlessHireFlow() {
537
628
  setPhase("hiring");
538
629
  setProgress(emptyProgress());
539
630
  try {
631
+ const hireListingSpecHash = input.hire.listingSpecHash;
632
+ let hireModerationArgs = {};
633
+ if (input.hire.moderationAttestor === void 0 && input.hire.moderatorIsAttestor === void 0 && input.hire.listingModeration === void 0 && hireListingSpecHash !== void 0) {
634
+ hireModerationArgs = await resolveHireListingModerationAccounts({
635
+ rpcUrl: ctx.rpcUrl,
636
+ listing: input.hire.listing,
637
+ listingSpecHash: hireListingSpecHash,
638
+ moderator: input.hire.moderator
639
+ });
640
+ }
540
641
  const hireResult = await client.hireFromListingHumanless({
541
642
  ...hireInput,
643
+ ...hireModerationArgs,
542
644
  creator,
543
645
  ...referrerArgs
544
646
  });
@@ -561,25 +663,29 @@ function useHumanlessHireFlow() {
561
663
  hireSignature: hireResult.signature,
562
664
  referrerInjected
563
665
  });
564
- const { jobSpecHash, jobSpecUri } = validateModerationResult(moderation);
666
+ const { jobSpecHash, jobSpecUri, moderator } = validateModerationResult(moderation);
565
667
  setProgress((current) => ({
566
668
  ...current,
567
669
  jobSpecHash,
568
670
  jobSpecUri
569
671
  }));
570
672
  setPhase("activating");
571
- const moderationAttestor = input.activation?.moderationAttestor ?? await resolveActivationModerationAttestor({
673
+ const activationModerator = input.activation?.moderator ?? moderator;
674
+ const activationCallerResolved = input.activation?.moderationAttestor !== void 0 || input.activation?.moderatorIsAttestor !== void 0 || input.activation?.taskModeration !== void 0;
675
+ const activationModerationArgs = activationCallerResolved ? {} : await resolveActivationModerationAccounts({
572
676
  rpcUrl: ctx.rpcUrl,
573
677
  task: taskPda,
574
- jobSpecHash
678
+ jobSpecHash,
679
+ moderator: activationModerator
575
680
  });
576
681
  const activationResult = await client.setTaskJobSpec({
577
682
  ...input.activation ?? {},
578
- ...moderationAttestor !== void 0 ? { moderationAttestor } : {},
683
+ ...activationModerationArgs,
579
684
  task: taskPda,
580
685
  creator,
581
686
  jobSpecHash,
582
- jobSpecUri
687
+ jobSpecUri,
688
+ moderator: activationModerator
583
689
  });
584
690
  const result = {
585
691
  taskPda,
@@ -798,6 +904,64 @@ function useDispute(taskPda, options) {
798
904
  reset: mutation.reset
799
905
  };
800
906
  }
907
+ function useCompletionBond(taskPda) {
908
+ const ctx = useAgencContext();
909
+ const queryClient = reactQuery.useQueryClient();
910
+ const invalidateGuarantee = react.useCallback(() => {
911
+ void queryClient.invalidateQueries({
912
+ queryKey: queryKeys.taskGuarantee(pdaKey(taskPda))
913
+ });
914
+ }, [queryClient, taskPda]);
915
+ const postMut = reactQuery.useMutation({
916
+ mutationFn: async (input) => {
917
+ const client = requireClient(ctx.client);
918
+ const { signature } = await client.postCompletionBond({
919
+ ...input,
920
+ task: taskPda,
921
+ authority: input.authority ?? client.signer
922
+ });
923
+ invalidateGuarantee();
924
+ return signature;
925
+ }
926
+ });
927
+ const reclaimMut = reactQuery.useMutation({
928
+ mutationFn: async (input) => {
929
+ const client = requireClient(ctx.client);
930
+ const { signature } = await client.reclaimCompletionBond({
931
+ ...input,
932
+ task: taskPda,
933
+ party: input.party ?? client.signer.address
934
+ });
935
+ invalidateGuarantee();
936
+ return signature;
937
+ }
938
+ });
939
+ const post = react.useCallback(
940
+ (input) => postMut.mutateAsync(input),
941
+ [postMut]
942
+ );
943
+ const reclaim = react.useCallback(
944
+ (input) => reclaimMut.mutateAsync(input),
945
+ [reclaimMut]
946
+ );
947
+ const isPending = postMut.isPending || reclaimMut.isPending;
948
+ const status = isPending ? "pending" : mutationStatusOf(
949
+ // Surface the most recently-touched verb's terminal state.
950
+ [postMut, reclaimMut].find((m) => m.isError || m.isSuccess) ?? postMut
951
+ );
952
+ return {
953
+ post,
954
+ reclaim,
955
+ status,
956
+ error: postMut.error ?? reclaimMut.error ?? null,
957
+ signature: postMut.data ?? reclaimMut.data ?? null,
958
+ isPending,
959
+ reset: () => {
960
+ postMut.reset();
961
+ reclaimMut.reset();
962
+ }
963
+ };
964
+ }
801
965
  function useWalletSigner(options) {
802
966
  const ctx = useAgencContext();
803
967
  const adapter = options?.adapter;
@@ -875,6 +1039,7 @@ exports.QUERY_KEY_ROOT = QUERY_KEY_ROOT;
875
1039
  exports.projectTrackRecord = projectTrackRecord;
876
1040
  exports.queryKeys = queryKeys;
877
1041
  exports.useAgentTrackRecord = useAgentTrackRecord;
1042
+ exports.useCompletionBond = useCompletionBond;
878
1043
  exports.useDispute = useDispute;
879
1044
  exports.useHire = useHire;
880
1045
  exports.useHumanlessHireFlow = useHumanlessHireFlow;
@@ -884,6 +1049,7 @@ exports.useRateHire = useRateHire;
884
1049
  exports.useReferrerEarnings = useReferrerEarnings;
885
1050
  exports.useSubmissionReview = useSubmissionReview;
886
1051
  exports.useTaskActivation = useTaskActivation;
1052
+ exports.useTaskGuarantee = useTaskGuarantee;
887
1053
  exports.useTaskLifecycle = useTaskLifecycle;
888
1054
  exports.useTaskStatus = useTaskStatus;
889
1055
  exports.useTaskWork = useTaskWork;