@tetsuo-ai/marketplace-react 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +21 -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-A7ETZFNH.js → chunk-WJUVTFJ7.js} +6 -6
  12. package/dist/chunk-WJUVTFJ7.js.map +1 -0
  13. package/dist/components/index.cjs +47 -16
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +2 -2
  16. package/dist/components/index.d.ts +2 -2
  17. package/dist/components/index.js +3 -3
  18. package/dist/hooks/index.cjs +350 -28
  19. package/dist/hooks/index.cjs.map +1 -1
  20. package/dist/hooks/index.d.cts +160 -36
  21. package/dist/hooks/index.d.ts +160 -36
  22. package/dist/hooks/index.js +299 -19
  23. package/dist/hooks/index.js.map +1 -1
  24. package/dist/{index-zLJX8XdK.d.ts → index-C9R3B80j.d.ts} +29 -37
  25. package/dist/{index-DUsGVhDz.d.cts → index-CTTh1ZPg.d.cts} +29 -37
  26. package/dist/index.cjs +68 -32
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +10 -19
  29. package/dist/index.d.ts +10 -19
  30. package/dist/index.js +17 -12
  31. package/dist/index.js.map +1 -1
  32. package/dist/signers/index.cjs +4 -3
  33. package/dist/signers/index.cjs.map +1 -1
  34. package/dist/signers/index.js +2 -2
  35. package/dist/{useAgentTrackRecord-BLf1nrbu.d.cts → useAgentTrackRecord-BCvRHYM2.d.cts} +7 -7
  36. package/dist/{useAgentTrackRecord-BLf1nrbu.d.ts → useAgentTrackRecord-BCvRHYM2.d.ts} +7 -7
  37. package/package.json +3 -2
  38. package/src/components/HireButton.tsx +1 -2
  39. package/src/components/HireCheckoutModal.tsx +8 -9
  40. package/src/components/ReferrerDisclosure.tsx +8 -12
  41. package/src/components/strings.ts +2 -2
  42. package/src/hooks/index.ts +47 -4
  43. package/src/hooks/internal.ts +74 -2
  44. package/src/hooks/useHire.ts +30 -38
  45. package/src/hooks/useHumanlessHireFlow.ts +259 -0
  46. package/src/hooks/useRateHire.ts +52 -0
  47. package/src/hooks/useReferrerEarnings.ts +32 -33
  48. package/src/hooks/useTaskActivation.ts +58 -0
  49. package/src/hooks/useTaskLifecycle.ts +110 -0
  50. package/src/hooks/useTaskWork.ts +76 -0
  51. package/src/index.ts +2 -2
  52. package/src/provider/AgencProvider.tsx +3 -3
  53. package/src/provider/referrer.ts +24 -32
  54. package/src/strings/index.ts +5 -3
  55. package/src/types.ts +7 -10
  56. package/dist/chunk-A7ETZFNH.js.map +0 -1
  57. package/dist/chunk-GN5DYVN5.js.map +0 -1
  58. package/dist/chunk-YORZNYZZ.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-DUsGVhDz.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, 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-CTTh1ZPg.cjs';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
4
  import '@solana/kit';
5
- import '../useAgentTrackRecord-BLf1nrbu.cjs';
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-zLJX8XdK.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, 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-C9R3B80j.js';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
4
  import '@solana/kit';
5
- import '../useAgentTrackRecord-BLf1nrbu.js';
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-A7ETZFNH.js';
2
- import '../chunk-YORZNYZZ.js';
3
- import '../chunk-GN5DYVN5.js';
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-WJUVTFJ7.js';
2
+ import '../chunk-FAIRTAIB.js';
3
+ import '../chunk-ECU7HGO3.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
@@ -13,11 +13,12 @@ var EN_STRINGS = {
13
13
  "provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
14
14
  "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
15
15
  "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
16
- // Referrer config validation (the P6.2 gate surface).
16
+ // Referrer config validation / capability surface.
17
17
  "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
18
18
  "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
19
- "referrer.notLive": "This site earns a referral fee (pending protocol support).",
20
- "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.",
19
+ "referrer.notLive": "Referral fee is not active for this hire.",
20
+ "referrer.notLiveReason": "No referrer is configured for this provider.",
21
+ "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
21
22
  // Read transport.
22
23
  "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
23
24
  // Generic loading / empty / error states (components extend these).
@@ -59,7 +60,7 @@ var queryKeys = {
59
60
  taskStatus: (taskPda) => [QUERY_KEY_ROOT, "taskStatus", taskPda],
60
61
  /** One task's dispute record. */
61
62
  dispute: (taskPda) => [QUERY_KEY_ROOT, "dispute", taskPda],
62
- /** One referrer wallet's earnings (P6.2-gated; see useReferrerEarnings). */
63
+ /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */
63
64
  referrerEarnings: (wallet) => [QUERY_KEY_ROOT, "referrerEarnings", wallet]
64
65
  };
65
66
  function requireClient(client) {
@@ -68,9 +69,45 @@ function requireClient(client) {
68
69
  }
69
70
  return client;
70
71
  }
72
+ function mutationStatusOf(mutation) {
73
+ if (mutation.isPending) return "pending";
74
+ if (mutation.isError) return "error";
75
+ if (mutation.isSuccess) return "success";
76
+ return "idle";
77
+ }
71
78
  function pdaKey(pda) {
72
79
  return String(pda);
73
80
  }
81
+ function resolveReferrerArgs(ctx) {
82
+ const capability = ctx.resolveReferrerCapability();
83
+ if (!capability.live || !capability.referrer) {
84
+ return { referrerArgs: {}, referrerInjected: false };
85
+ }
86
+ return {
87
+ referrerArgs: {
88
+ referrer: capability.referrer.wallet,
89
+ referrerFeeBps: capability.referrer.feeBps
90
+ },
91
+ referrerInjected: true
92
+ };
93
+ }
94
+ function signerAddress(signerOrAddress) {
95
+ if (typeof signerOrAddress === "string") {
96
+ return signerOrAddress;
97
+ }
98
+ if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
99
+ return signerOrAddress.address;
100
+ }
101
+ throw new Error("Expected a TransactionSigner or Address with an address field.");
102
+ }
103
+ function withoutReferrerArgs(input) {
104
+ const {
105
+ referrer: _referrer,
106
+ referrerFeeBps: _referrerFeeBps,
107
+ ...rest
108
+ } = input;
109
+ return rest;
110
+ }
74
111
 
75
112
  // src/hooks/useListings.ts
76
113
  var DEFAULT_PAGE_SIZE = 12;
@@ -267,29 +304,29 @@ function useHire() {
267
304
  const mutation = reactQuery.useMutation({
268
305
  mutationFn: async (input) => {
269
306
  const client = requireClient(ctx.client);
270
- const capability = ctx.resolveReferrerCapability();
271
- const referrerInjected = capability.live && ctx.referrer !== null;
307
+ const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
308
+ const hireInput = withoutReferrerArgs(input);
272
309
  const creator = input.creator ?? client.signer;
273
310
  let signature;
274
311
  if (input.humanless === true) {
275
- const ix = await marketplaceSdk.facade.hireFromListingHumanless({
276
- ...input,
277
- creator
278
- // NOTE: P6.2 referrer fields would spread here under capability.live.
312
+ const result = await client.hireFromListingHumanless({
313
+ ...hireInput,
314
+ creator,
315
+ ...referrerArgs
279
316
  });
280
- ({ signature } = await client.send([ix]));
317
+ signature = result.signature;
281
318
  } else {
282
319
  const authority = input.authority ?? client.signer;
283
320
  const result = await client.hireFromListing({
284
- ...input,
321
+ ...hireInput,
285
322
  authority,
286
- creator
287
- // NOTE: P6.2 referrer fields would spread here under capability.live.
323
+ creator,
324
+ ...referrerArgs
288
325
  });
289
326
  signature = result.signature;
290
327
  }
291
328
  const [taskPda] = await marketplaceSdk.findTaskPda({
292
- creator: typeof creator === "object" && creator !== null && "address" in creator ? creator.address : creator,
329
+ creator: signerAddress(creator),
293
330
  taskId: input.taskId
294
331
  });
295
332
  return { signature, taskPda, referrerInjected };
@@ -393,6 +430,293 @@ function useSubmissionReview(taskPda) {
393
430
  }
394
431
  };
395
432
  }
433
+ function useTaskActivation(taskPda) {
434
+ const ctx = useAgencContext();
435
+ const mutation = reactQuery.useMutation({
436
+ mutationFn: async (input) => {
437
+ const client = requireClient(ctx.client);
438
+ const { signature } = await client.setTaskJobSpec({
439
+ ...input,
440
+ task: taskPda,
441
+ creator: input.creator ?? client.signer
442
+ });
443
+ return signature;
444
+ }
445
+ });
446
+ const activate = react.useCallback(
447
+ (input) => mutation.mutateAsync(input),
448
+ [mutation]
449
+ );
450
+ return {
451
+ activate,
452
+ status: mutationStatusOf(mutation),
453
+ signature: mutation.data ?? null,
454
+ error: mutation.error ?? null,
455
+ isPending: mutation.isPending,
456
+ reset: mutation.reset
457
+ };
458
+ }
459
+ function emptyProgress() {
460
+ return {
461
+ taskPda: null,
462
+ hireSignature: null,
463
+ activationSignature: null,
464
+ jobSpecHash: null,
465
+ jobSpecUri: null,
466
+ referrerInjected: false
467
+ };
468
+ }
469
+ function validateModerationResult(result) {
470
+ if (result.moderationAttested !== true) {
471
+ throw new Error(
472
+ "Task moderation was not attested; activation was not signed."
473
+ );
474
+ }
475
+ if (!(result.jobSpecHash instanceof Uint8Array) || result.jobSpecHash.byteLength !== 32) {
476
+ throw new Error(
477
+ "Task moderation returned an invalid jobSpecHash; activation was not signed."
478
+ );
479
+ }
480
+ const jobSpecUri = result.jobSpecUri.trim();
481
+ if (!jobSpecUri) {
482
+ throw new Error(
483
+ "Task moderation returned an empty jobSpecUri; activation was not signed."
484
+ );
485
+ }
486
+ return { jobSpecHash: result.jobSpecHash, jobSpecUri };
487
+ }
488
+ function useHumanlessHireFlow() {
489
+ const ctx = useAgencContext();
490
+ const [phase, setPhase] = react.useState("idle");
491
+ const [progress, setProgress] = react.useState(emptyProgress);
492
+ const flowInFlight = react.useRef(false);
493
+ const mutation = reactQuery.useMutation({
494
+ mutationFn: async (input) => {
495
+ const client = requireClient(ctx.client);
496
+ const creator = input.creator ?? client.signer;
497
+ const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
498
+ const hireInput = withoutReferrerArgs(input.hire);
499
+ setPhase("hiring");
500
+ setProgress(emptyProgress());
501
+ try {
502
+ const hireResult = await client.hireFromListingHumanless({
503
+ ...hireInput,
504
+ creator,
505
+ ...referrerArgs
506
+ });
507
+ const [taskPda] = await marketplaceSdk.findTaskPda({
508
+ creator: signerAddress(creator),
509
+ taskId: input.hire.taskId
510
+ });
511
+ setProgress({
512
+ ...emptyProgress(),
513
+ taskPda,
514
+ hireSignature: hireResult.signature,
515
+ referrerInjected
516
+ });
517
+ setPhase("moderating");
518
+ const moderation = await input.hostAndModerateJobSpec({
519
+ taskPda,
520
+ taskId: input.hire.taskId,
521
+ listing: input.hire.listing,
522
+ jobSpec: input.jobSpec,
523
+ hireSignature: hireResult.signature,
524
+ referrerInjected
525
+ });
526
+ const { jobSpecHash, jobSpecUri } = validateModerationResult(moderation);
527
+ setProgress((current) => ({
528
+ ...current,
529
+ jobSpecHash,
530
+ jobSpecUri
531
+ }));
532
+ setPhase("activating");
533
+ const activationResult = await client.setTaskJobSpec({
534
+ ...input.activation ?? {},
535
+ task: taskPda,
536
+ creator,
537
+ jobSpecHash,
538
+ jobSpecUri
539
+ });
540
+ const result = {
541
+ taskPda,
542
+ hireSignature: hireResult.signature,
543
+ activationSignature: activationResult.signature,
544
+ jobSpecHash,
545
+ jobSpecUri,
546
+ referrerInjected,
547
+ moderation: moderation.moderation
548
+ };
549
+ setProgress((current) => ({
550
+ ...current,
551
+ activationSignature: activationResult.signature
552
+ }));
553
+ setPhase("activated");
554
+ return result;
555
+ } catch (error) {
556
+ setPhase("error");
557
+ throw error;
558
+ }
559
+ }
560
+ });
561
+ const hireAndActivate = react.useCallback(
562
+ async (input) => {
563
+ if (flowInFlight.current) {
564
+ throw new Error("A humanless hire flow is already in progress.");
565
+ }
566
+ flowInFlight.current = true;
567
+ try {
568
+ return await mutation.mutateAsync(input);
569
+ } finally {
570
+ flowInFlight.current = false;
571
+ }
572
+ },
573
+ [mutation]
574
+ );
575
+ const reset = react.useCallback(() => {
576
+ mutation.reset();
577
+ setPhase("idle");
578
+ setProgress(emptyProgress());
579
+ }, [mutation]);
580
+ return {
581
+ hireAndActivate,
582
+ phase,
583
+ status: mutationStatusOf(mutation),
584
+ progress,
585
+ result: mutation.data ?? null,
586
+ error: mutation.error ?? null,
587
+ isPending: mutation.isPending,
588
+ reset
589
+ };
590
+ }
591
+ function useTaskWork(taskPda) {
592
+ const ctx = useAgencContext();
593
+ const claimMut = reactQuery.useMutation({
594
+ mutationFn: async (input) => {
595
+ const client = requireClient(ctx.client);
596
+ const { signature } = await client.claimTaskWithJobSpec({
597
+ ...input,
598
+ task: taskPda
599
+ });
600
+ return signature;
601
+ }
602
+ });
603
+ const submitMut = reactQuery.useMutation({
604
+ mutationFn: async (input) => {
605
+ const client = requireClient(ctx.client);
606
+ const { signature } = await client.submitTaskResult({
607
+ ...input,
608
+ task: taskPda
609
+ });
610
+ return signature;
611
+ }
612
+ });
613
+ const claim = react.useCallback((input) => claimMut.mutateAsync(input), [claimMut]);
614
+ const submit = react.useCallback(
615
+ (input) => submitMut.mutateAsync(input),
616
+ [submitMut]
617
+ );
618
+ const active = claimMut.isPending || submitMut.isPending;
619
+ const latest = [claimMut, submitMut].find((m) => m.isError || m.isSuccess) ?? claimMut;
620
+ return {
621
+ claim,
622
+ submit,
623
+ status: active ? "pending" : mutationStatusOf(latest),
624
+ signature: latest.data ?? null,
625
+ error: claimMut.error ?? submitMut.error ?? null,
626
+ isPending: active,
627
+ reset: () => {
628
+ claimMut.reset();
629
+ submitMut.reset();
630
+ }
631
+ };
632
+ }
633
+ function useTaskLifecycle(taskPda) {
634
+ const ctx = useAgencContext();
635
+ const cancelMut = reactQuery.useMutation({
636
+ mutationFn: async (input) => {
637
+ const client = requireClient(ctx.client);
638
+ const { signature } = await client.cancelTask({
639
+ ...input ?? {},
640
+ task: taskPda,
641
+ authority: input?.authority ?? client.signer
642
+ });
643
+ return signature;
644
+ }
645
+ });
646
+ const closeMut = reactQuery.useMutation({
647
+ mutationFn: async (input) => {
648
+ const client = requireClient(ctx.client);
649
+ const { signature } = await client.closeTask({
650
+ ...input ?? {},
651
+ task: taskPda,
652
+ authority: input?.authority ?? client.signer
653
+ });
654
+ return signature;
655
+ }
656
+ });
657
+ const autoAcceptMut = reactQuery.useMutation({
658
+ mutationFn: async (input) => {
659
+ const client = requireClient(ctx.client);
660
+ const { signature } = await client.autoAcceptTaskResult({
661
+ ...input,
662
+ task: taskPda,
663
+ authority: input.authority ?? client.signer
664
+ });
665
+ return signature;
666
+ }
667
+ });
668
+ const cancel = react.useCallback(
669
+ (input) => cancelMut.mutateAsync(input),
670
+ [cancelMut]
671
+ );
672
+ const close = react.useCallback(
673
+ (input) => closeMut.mutateAsync(input),
674
+ [closeMut]
675
+ );
676
+ const autoAccept = react.useCallback(
677
+ (input) => autoAcceptMut.mutateAsync(input),
678
+ [autoAcceptMut]
679
+ );
680
+ const active = cancelMut.isPending || closeMut.isPending || autoAcceptMut.isPending;
681
+ const latest = [cancelMut, closeMut, autoAcceptMut].find((m) => m.isError || m.isSuccess) ?? cancelMut;
682
+ return {
683
+ cancel,
684
+ close,
685
+ autoAccept,
686
+ status: active ? "pending" : mutationStatusOf(latest),
687
+ signature: latest.data ?? null,
688
+ error: cancelMut.error ?? closeMut.error ?? autoAcceptMut.error ?? null,
689
+ isPending: active,
690
+ reset: () => {
691
+ cancelMut.reset();
692
+ closeMut.reset();
693
+ autoAcceptMut.reset();
694
+ }
695
+ };
696
+ }
697
+ function useRateHire(taskPda) {
698
+ const ctx = useAgencContext();
699
+ const mutation = reactQuery.useMutation({
700
+ mutationFn: async (input) => {
701
+ const client = requireClient(ctx.client);
702
+ const { signature } = await client.rateHire({
703
+ ...input,
704
+ task: taskPda,
705
+ buyer: input.buyer ?? client.signer
706
+ });
707
+ return signature;
708
+ }
709
+ });
710
+ const rate = react.useCallback((input) => mutation.mutateAsync(input), [mutation]);
711
+ return {
712
+ rate,
713
+ status: mutationStatusOf(mutation),
714
+ signature: mutation.data ?? null,
715
+ error: mutation.error ?? null,
716
+ isPending: mutation.isPending,
717
+ reset: mutation.reset
718
+ };
719
+ }
396
720
  function useDispute(taskPda, options) {
397
721
  const ctx = useAgencContext();
398
722
  const reader = options?.disputeReader;
@@ -440,41 +764,34 @@ function useWalletSigner(options) {
440
764
  }, [adapter]);
441
765
  return { signer, connected, connect };
442
766
  }
767
+ var EARNINGS_INDEXER_LIVE = false;
443
768
  function useReferrerEarnings(wallet) {
444
769
  const ctx = useAgencContext();
445
770
  const capability = ctx.resolveReferrerCapability();
446
- const enabled = capability.live && Boolean(wallet);
447
- const query = reactQuery.useQuery(
771
+ const enabled = capability.live && EARNINGS_INDEXER_LIVE;
772
+ reactQuery.useQuery(
448
773
  {
449
774
  queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : ""),
450
775
  enabled,
451
776
  queryFn: async () => {
452
777
  throw new Error(
453
- "useReferrerEarnings: the P6.2 referrer earnings path is not deployed; this query must never run while capability.live is false."
778
+ "useReferrerEarnings: the referrer earnings indexer is not deployed; this query must never run while EARNINGS_INDEXER_LIVE is false."
454
779
  );
455
780
  }
456
781
  }
457
782
  );
458
- if (!capability.live) {
783
+ if (!capability.live || !EARNINGS_INDEXER_LIVE) {
459
784
  return {
460
785
  live: false,
461
786
  totalLamports: 0n,
462
787
  hires: [],
463
788
  isLoading: false,
464
789
  error: null,
465
- reason: capability.reason ?? t("referrer.notLiveReason"),
790
+ reason: capability.live ? t("referrer.earningsNotLiveReason") : capability.reason ?? t("referrer.notLiveReason"),
466
791
  refetch: () => {
467
792
  }
468
793
  };
469
794
  }
470
- return {
471
- live: true,
472
- totalLamports: query.data?.totalLamports ?? 0n,
473
- hires: query.data?.hires ?? [],
474
- isLoading: query.isLoading,
475
- error: query.error ?? null,
476
- refetch: () => void query.refetch()
477
- };
478
795
  }
479
796
 
480
797
  exports.QUERY_KEY_ROOT = QUERY_KEY_ROOT;
@@ -483,11 +800,16 @@ exports.queryKeys = queryKeys;
483
800
  exports.useAgentTrackRecord = useAgentTrackRecord;
484
801
  exports.useDispute = useDispute;
485
802
  exports.useHire = useHire;
803
+ exports.useHumanlessHireFlow = useHumanlessHireFlow;
486
804
  exports.useListing = useListing;
487
805
  exports.useListings = useListings;
806
+ exports.useRateHire = useRateHire;
488
807
  exports.useReferrerEarnings = useReferrerEarnings;
489
808
  exports.useSubmissionReview = useSubmissionReview;
809
+ exports.useTaskActivation = useTaskActivation;
810
+ exports.useTaskLifecycle = useTaskLifecycle;
490
811
  exports.useTaskStatus = useTaskStatus;
812
+ exports.useTaskWork = useTaskWork;
491
813
  exports.useWalletSigner = useWalletSigner;
492
814
  //# sourceMappingURL=index.cjs.map
493
815
  //# sourceMappingURL=index.cjs.map