@tetsuo-ai/marketplace-react 0.1.1 → 0.3.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 +33 -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 +4 -3
  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 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useListings.ts","../../src/hooks/useListing.ts","../../src/hooks/useAgentTrackRecord.ts","../../src/hooks/useTaskStatus.ts","../../src/hooks/useSubmissionReview.ts","../../src/hooks/useDispute.ts","../../src/hooks/useReferrerEarnings.ts"],"names":["useQuery","useState","task","signature","useCallback","useMutation"],"mappings":";;;;;;;;AAuEA,IAAM,iBAAA,GAAoB,EAAA;AAgBnB,SAAS,WAAA,CACd,QACA,OAAA,EACmB;AACnB,EAAA,MAAM,EAAE,IAAA,EAAK,GAA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,OAAA,EAAS,MAAM,KAAK,KAAA,CAAM,OAAA;AAAQ,GACpC;AACF","file":"index.js","sourcesContent":["/**\n * `useListings(filter?)` — the listing-grid read hook.\n *\n * Fetches active service listings through the provider's unified read transport\n * (indexer-first, gPA fallback — the hook never branches on which is live) and\n * caches them via TanStack Query. Filters (`provider`, `category`, `state`) are\n * forwarded verbatim to the transport, which applies server-side memcmp filters\n * (indexer/gPA) and the client-side state filter exactly as the SDK does.\n *\n * ## Pagination model (honest about the transport)\n *\n * The v1 read transport returns the FULL active-listing set in one call — there\n * is no server cursor in either backend (the gPA path can't have one; the\n * indexer's `listActiveListings` is a drop-in of it). So pagination here is a\n * client-side WINDOW over the already-fetched array: `listings` grows by\n * `pageSize` each time `fetchMore()` is called, `hasMore` reflects whether more\n * rows remain in the fetched set. This keeps one network round-trip while still\n * giving a grid an incremental-reveal API. When a future transport gains a\n * cursor, `fetchMore` can swap to `fetchNextPage` without changing this\n * surface.\n *\n * SSR-safe: no `window`/`document`; the query simply does not run until mounted\n * if the host disables it.\n *\n * @module hooks/useListings\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type {\n DecodedProgramAccount,\n ListActiveListingsOptions,\n ServiceListing,\n} from \"../types.js\";\nimport { queryKeys } from \"./internal.js\";\n\n/** A decoded active listing row (address + decoded account). */\nexport type ListingRow = DecodedProgramAccount<ServiceListing>;\n\n/** Filter for {@link useListings}. Mirrors the SDK's `ListActiveListingsOptions`. */\nexport type UseListingsFilter = ListActiveListingsOptions;\n\n/** Options for {@link useListings}. */\nexport interface UseListingsOptions {\n /** Rows revealed per page / per `fetchMore()` call. Default `12`. */\n pageSize?: number;\n /**\n * Disable the query (e.g. until a filter is ready). When `false` the hook\n * returns the idle state and makes no request. Default `true`.\n */\n enabled?: boolean;\n}\n\n/** Return value of {@link useListings}. */\nexport interface UseListingsResult {\n /** The currently-revealed window of listings (grows via `fetchMore`). */\n listings: ListingRow[];\n /** Total active listings the transport returned (the full fetched set). */\n total: number;\n /** True while the underlying fetch is in flight (first load / refetch). */\n isLoading: boolean;\n /** The fetch error (typed `AgencError` for on-chain failures), or null. */\n error: Error | null;\n /** Whether more rows remain in the fetched set to reveal. */\n hasMore: boolean;\n /** Reveal the next `pageSize` rows from the fetched set. No-op when exhausted. */\n fetchMore: () => void;\n /** Force a fresh fetch from the transport. */\n refetch: () => void;\n}\n\nconst DEFAULT_PAGE_SIZE = 12;\n\n/**\n * Read active service listings for a grid.\n *\n * @param filter - Optional provider/category/state filter (SDK semantics).\n * @param options - Page size + enabled flag.\n * @returns {@link UseListingsResult}.\n *\n * @example\n * ```tsx\n * const { listings, isLoading, fetchMore, hasMore } = useListings({\n * category: \"code-generation\",\n * });\n * ```\n */\nexport function useListings(\n filter?: UseListingsFilter,\n options?: UseListingsOptions,\n): UseListingsResult {\n const { read } = useAgencContext();\n const pageSize = options?.pageSize ?? DEFAULT_PAGE_SIZE;\n const enabled = options?.enabled ?? true;\n\n const query = useQuery<ListingRow[], Error>({\n queryKey: queryKeys.listings(filter),\n queryFn: () => read.listActiveListings(filter),\n enabled,\n });\n\n // Client-side reveal window. Reset to one page whenever the underlying data\n // changes (new fetch / filter change resets the key, which remounts data).\n const [visible, setVisible] = useState(pageSize);\n\n const all = query.data ?? [];\n // Clamp the window to [pageSize, all.length] so a filter change that shrinks\n // the set never strands `visible` above the available rows.\n const windowSize = Math.min(Math.max(visible, pageSize), all.length);\n const listings = useMemo(\n () => all.slice(0, windowSize),\n [all, windowSize],\n );\n\n const fetchMore = useCallback(() => {\n setVisible((current) => current + pageSize);\n }, [pageSize]);\n\n const refetch = useCallback(() => {\n setVisible(pageSize);\n void query.refetch();\n }, [pageSize, query]);\n\n return {\n listings,\n total: all.length,\n isLoading: query.isLoading,\n error: query.error ?? null,\n hasMore: windowSize < all.length,\n fetchMore,\n refetch,\n };\n}\n","/**\n * `useListing(pda)` — single-listing detail hook.\n *\n * Joins, in ONE cached query, the three things a listing detail / checkout view\n * needs:\n * - the decoded `ServiceListing` (via `read.getListing`);\n * - the provider's track record (via `read.agentTrackRecord(providerAgent)`),\n * keyed off the listing's `providerAgent` — indexer-native, so it is fetched\n * only when the indexer backend is live and resolves to `null` under the gPA\n * fallback (which has no trustless aggregated track record — the transport\n * throws `ReadTransportUnsupportedError`, which the hook swallows to `null`\n * rather than failing the whole join);\n * - the moderation/attestation state (see the moderation note below).\n *\n * ## Moderation (v1 scope, honest)\n *\n * The read transport does not yet expose a dedicated listing-moderation read\n * (the indexer's listing projection carries the pinned `specHash` but not an\n * attestation verdict). So `moderation` is the listing's indexer projection when\n * present (callers can read `indexer.metadataValid` / `metadataIssues` and the\n * pinned `specHash`) and `null` under the gPA fallback. A dedicated attestation\n * read lands when the indexer projects it; this hook's surface does not change.\n *\n * @module hooks/useListing\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { ReadTransportUnsupportedError } from \"../transport/index.js\";\nimport type {\n Address,\n IndexerAgentTrackRecord,\n IndexerListing,\n ServiceListing,\n} from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** The joined detail payload {@link useListing} resolves. */\nexport interface ListingDetail {\n /** The listing PDA. */\n address: Address;\n /** The decoded on-chain `ServiceListing`. */\n listing: ServiceListing;\n /** The provider's agent PDA (`ServiceListing.providerAgent`). */\n provider: Address;\n /**\n * The provider's indexer track record, or `null` when unavailable (the gPA\n * fallback has no trustless aggregated equivalent).\n */\n trackRecord: IndexerAgentTrackRecord | null;\n /**\n * The listing's indexer projection (carries `metadataValid`,\n * `metadataIssues`, the pinned `specHash`), or `null` under the gPA fallback.\n * The v1 read model does not yet project a standalone attestation verdict.\n */\n moderation: IndexerListing | null;\n}\n\n/** Options for {@link useListing}. */\nexport interface UseListingOptions {\n /** Disable the query (no `pda` yet, etc.). Default `true` when `pda` is set. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useListing}. */\nexport interface UseListingResult {\n /** The joined detail, or null until loaded. */\n detail: ListingDetail | null;\n /** The decoded listing, or null until loaded (convenience projection). */\n listing: ServiceListing | null;\n /** The provider agent PDA, or null until loaded. */\n provider: Address | null;\n /** The provider's track record, or null (unavailable / not yet loaded). */\n trackRecord: IndexerAgentTrackRecord | null;\n /** The listing's indexer/moderation projection, or null. */\n moderation: IndexerListing | null;\n /** True while loading. */\n isLoading: boolean;\n /** The error, or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/**\n * Read one listing and join its provider track record + moderation projection.\n *\n * @param pda - The ServiceListing PDA (string or Address). When falsy the query\n * is disabled.\n * @param options - `enabled` override.\n * @returns {@link UseListingResult}.\n */\nexport function useListing(\n pda: Address | string | undefined | null,\n options?: UseListingOptions,\n): UseListingResult {\n const { read } = useAgencContext();\n const enabled = (options?.enabled ?? true) && Boolean(pda);\n\n const query = useQuery<ListingDetail, Error>({\n queryKey: queryKeys.listing(pda ? pdaKey(pda) : \"\"),\n enabled,\n queryFn: async () => {\n // 1) The listing itself.\n const result = await read.getListing(pda as Address | string);\n const provider = result.account.providerAgent;\n\n // 2) The provider's track record — indexer-native. Swallow the\n // gPA-fallback \"unsupported\" rejection to null so the join still\n // resolves the listing + moderation (degrade, don't fail).\n let trackRecord: IndexerAgentTrackRecord | null = null;\n try {\n trackRecord = await read.agentTrackRecord(provider);\n } catch (err) {\n if (!(err instanceof ReadTransportUnsupportedError)) throw err;\n }\n\n return {\n address: result.address,\n listing: result.account,\n provider,\n trackRecord,\n moderation: result.indexer ?? null,\n };\n },\n });\n\n const detail = query.data ?? null;\n return {\n detail,\n listing: detail?.listing ?? null,\n provider: detail?.provider ?? null,\n trackRecord: detail?.trackRecord ?? null,\n moderation: detail?.moderation ?? null,\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useAgentTrackRecord(agentPda)` — provider reputation hook (PARTIAL, P6.6).\n *\n * Reads the indexer's reconstructed track record for an agent and projects the\n * `{ completionRate, disputeRate, slashHistory, recentOutcomes }` contract.\n *\n * ## P6.6 scope (honest about what is and isn't available)\n *\n * The v1 indexer record (`IndexerAgentTrackRecord`) is event-reconstructed and\n * exposes raw COUNTS: `completions`, `disputesInitiated`, `disputesLost`, and a\n * `slashHistory`. It does NOT yet expose the denominators a true RATE needs\n * (total tasks taken, total disputes faced) — that aggregation lands in\n * PLAN.md P6.6. So:\n * - `slashHistory` and the dispute COUNTS are real today (passed through);\n * - `completionRate` / `disputeRate` are RATIOS and are only meaningful once a\n * denominator exists. Today they are computed from the available counts where\n * a denominator is inferable (completions vs. completions+disputesLost as a\n * conservative proxy) and otherwise `null`. Treat them as provisional until\n * P6.6. The `partial` flag is the audit signal — `true` today.\n * - `recentOutcomes` is reconstructed from `slashHistory` (the only per-event\n * stream in v1); a richer outcome feed lands with P6.6.\n *\n * Indexer-native: the gPA fallback has no aggregated track record, so under it\n * `read.agentTrackRecord` throws `ReadTransportUnsupportedError` and this hook\n * surfaces that error (a track record is not reconstructable trustlessly).\n *\n * @module hooks/useAgentTrackRecord\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address, IndexerAgentTrackRecord } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** A reconstructed outcome event (v1: derived from the slash history). */\nexport interface TrackRecordOutcome {\n /** Outcome kind. v1 only reconstructs slashes from the event stream. */\n kind: \"slash\";\n /** The raw slash event from the indexer record. */\n event: IndexerAgentTrackRecord[\"slashHistory\"][number];\n}\n\n/** The projected track record {@link useAgentTrackRecord} returns. */\nexport interface AgentTrackRecord {\n /** The agent PDA. */\n agent: Address | string;\n /** Completed-task count (real today). */\n completions: number;\n /** Disputes the agent initiated (real today). */\n disputesInitiated: number;\n /** Disputes the agent lost (real today). */\n disputesLost: number;\n /**\n * Completion rate in `[0,1]`, or `null` when no denominator is inferable.\n * PROVISIONAL until P6.6 supplies the true total-tasks denominator.\n */\n completionRate: number | null;\n /**\n * Dispute rate in `[0,1]`, or `null` when no denominator is inferable.\n * PROVISIONAL until P6.6.\n */\n disputeRate: number | null;\n /** Reconstructed slash history (real today). */\n slashHistory: IndexerAgentTrackRecord[\"slashHistory\"];\n /** Reconstructed recent outcomes (v1: from slash history). */\n recentOutcomes: TrackRecordOutcome[];\n /** True while any rate is provisional/derived (P6.6 audit signal). */\n partial: boolean;\n}\n\n/** Options for {@link useAgentTrackRecord}. */\nexport interface UseAgentTrackRecordOptions {\n /** Disable the query. Default `true` when `agentPda` is set. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useAgentTrackRecord}. */\nexport interface UseAgentTrackRecordResult {\n /** The projected track record, or null until loaded. */\n trackRecord: AgentTrackRecord | null;\n /** Convenience: `trackRecord?.completionRate ?? null`. */\n completionRate: number | null;\n /** Convenience: `trackRecord?.disputeRate ?? null`. */\n disputeRate: number | null;\n /** Convenience: `trackRecord?.slashHistory ?? []`. */\n slashHistory: IndexerAgentTrackRecord[\"slashHistory\"];\n /** Convenience: `trackRecord?.recentOutcomes ?? []`. */\n recentOutcomes: TrackRecordOutcome[];\n /** True while loading. */\n isLoading: boolean;\n /** The error (e.g. `ReadTransportUnsupportedError` under gPA), or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/**\n * Project the raw indexer record into the partial track-record contract. Kept\n * exported + pure so structural tests can assert the projection directly.\n */\nexport function projectTrackRecord(\n raw: IndexerAgentTrackRecord,\n): AgentTrackRecord {\n const completions = raw.completions;\n const disputesLost = raw.disputesLost;\n // Conservative proxy denominator: settled outcomes we can SEE (completions +\n // lost disputes). This is NOT the true total-tasks denominator (P6.6); when\n // it is zero there is nothing to rate, so the rates are null.\n const settledKnown = completions + disputesLost;\n const completionRate =\n settledKnown > 0 ? completions / settledKnown : null;\n const disputeRate =\n settledKnown > 0 ? disputesLost / settledKnown : null;\n\n return {\n agent: raw.agent,\n completions,\n disputesInitiated: raw.disputesInitiated,\n disputesLost,\n completionRate,\n disputeRate,\n slashHistory: raw.slashHistory,\n recentOutcomes: raw.slashHistory.map((event) => ({\n kind: \"slash\" as const,\n event,\n })),\n // Always partial in v1: every rate is a proxy until P6.6 lands the real\n // denominators and outcome feed.\n partial: true,\n };\n}\n\n/**\n * Read an agent's (partial) track record.\n *\n * @param agentPda - The AgentRegistration PDA (falsy disables the hook).\n * @param options - `enabled` override.\n * @returns {@link UseAgentTrackRecordResult}.\n */\nexport function useAgentTrackRecord(\n agentPda: Address | string | undefined | null,\n options?: UseAgentTrackRecordOptions,\n): UseAgentTrackRecordResult {\n const { read } = useAgencContext();\n const enabled = (options?.enabled ?? true) && Boolean(agentPda);\n\n const query = useQuery<AgentTrackRecord, Error>({\n queryKey: queryKeys.agentTrackRecord(agentPda ? pdaKey(agentPda) : \"\"),\n enabled,\n queryFn: async () => {\n const raw = await read.agentTrackRecord(agentPda as Address | string);\n return projectTrackRecord(raw);\n },\n });\n\n const tr = query.data ?? null;\n return {\n trackRecord: tr,\n completionRate: tr?.completionRate ?? null,\n disputeRate: tr?.disputeRate ?? null,\n slashHistory: tr?.slashHistory ?? [],\n recentOutcomes: tr?.recentOutcomes ?? [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useTaskStatus(taskPda)` — live task status with a poll fallback.\n *\n * Tracks a Task account's {@link TaskStatus} (and optionally its submission and\n * the coordination events seen for it) after a hire. It is built to satisfy the\n * PLAN_2 A2 contract `{ task, status, submission, events }` while staying SSR-\n * and transport-agnostic.\n *\n * ## How it reads (the seam)\n *\n * The unified read transport intentionally has NO raw account fetch, and the\n * litesvm e2e harness has no RPC — so a task read cannot be assumed from\n * context. `useTaskStatus` therefore takes a **`taskReader`**: an async\n * `(pda) => Promise<Task | null>`. Callers wire it from whatever they have:\n * - a kit RPC: `(pda) => getTaskDecoder().decode(...)` over `getAccountInfo`\n * (the SDK's `waitForTaskStatus` uses exactly this `getAccountInfo` shape);\n * - litesvm e2e: `(pda) => decode(svm.getAccount(pda))`.\n * A reader-less call returns the idle state (and a clear `error` if `poll` was\n * requested) rather than guessing a transport.\n *\n * ## Polling vs. subscription (SSR-safe, cleaned up)\n *\n * - Polling: TanStack Query `refetchInterval` re-runs `taskReader` until the\n * task reaches a terminal status (`Completed`/`Cancelled`/`RejectFrozen`) or\n * the optional `targetStatus` — then stops.\n * - Subscription: when an `events` async-iterable is supplied (e.g. from the\n * SDK's `subscribeMarketplaceEvents`), a `useEffect` (browser-only; never runs\n * during SSR) drains it, appends each event to `events`, and triggers a\n * refetch so status stays fresh without tight polling. The effect aborts the\n * iterable and clears state on unmount.\n *\n * @module hooks/useTaskStatus\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { TaskStatus, type Task } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** Reads a Task account, returning the decoded {@link Task} or null if absent. */\nexport type TaskReader = (pda: Address | string) => Promise<Task | null>;\n\n/**\n * A single coordination event observed for the watched task. Kept loosely typed\n * (the SDK's `AgencEvent` union) so this hook does not pin the event schema.\n */\nexport type ObservedEvent = unknown;\n\n/**\n * An async source of coordination events for the watched task. Pass the result\n * of the SDK's `subscribeMarketplaceEvents(...)` (already address-filtered) or\n * any async iterable. Optional.\n */\nexport type TaskEventsSource = AsyncIterable<ObservedEvent>;\n\n/** Options for {@link useTaskStatus}. */\nexport interface UseTaskStatusOptions {\n /**\n * How to read the Task account. REQUIRED for any live status — without it the\n * hook stays idle. See the module doc for wiring patterns.\n */\n taskReader?: TaskReader;\n /**\n * Optional event source. When given, observed events are appended to\n * `events` and each triggers a refetch. Drained in a browser-only effect and\n * aborted on unmount.\n */\n events?: TaskEventsSource;\n /**\n * Stop polling once the task reaches this status (in addition to terminal\n * statuses). Useful to await a specific transition (e.g. `Completed`).\n */\n targetStatus?: TaskStatus;\n /** Poll interval in ms while non-terminal. Default `2000`. */\n pollIntervalMs?: number;\n /** Disable the hook entirely. Default `true` when `taskPda` + reader exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useTaskStatus}. */\nexport interface UseTaskStatusResult {\n /** The decoded Task, or null until first read. */\n task: Task | null;\n /** The task status, or null until first read. */\n status: TaskStatus | null;\n /**\n * The submission projection. v1 surfaces the task's on-chain `result` bytes\n * (the worker's submitted result) once present; a richer submission read\n * lands with the indexer projection. `null` until a result exists.\n */\n submission: Uint8Array | null;\n /** Coordination events observed for this task (chronological). */\n events: ObservedEvent[];\n /** True while the first read is in flight. */\n isLoading: boolean;\n /** The read error, or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/** Statuses after which no further transition is possible (stop polling). */\nconst TERMINAL_STATUSES: ReadonlySet<TaskStatus> = new Set([\n TaskStatus.Completed,\n TaskStatus.Cancelled,\n TaskStatus.RejectFrozen,\n]);\n\n/** True when the task's `result` bytes are present and non-empty. */\nfunction hasResult(task: Task | null): boolean {\n return task !== null && task.result.length > 0 && task.result.some((b) => b !== 0);\n}\n\n/**\n * Watch a task's status.\n *\n * @param taskPda - The Task PDA to watch (falsy disables the hook).\n * @param options - Reader, event source, target status, poll interval.\n * @returns {@link UseTaskStatusResult}.\n */\nexport function useTaskStatus(\n taskPda: Address | string | undefined | null,\n options?: UseTaskStatusOptions,\n): UseTaskStatusResult {\n // Touch context so the hook is provider-bound (and throws clearly outside it),\n // matching every other hook's contract even though reads come via the reader.\n useAgencContext();\n\n const reader = options?.taskReader;\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);\n const pollIntervalMs = options?.pollIntervalMs ?? 2000;\n\n const [events, setEvents] = useState<ObservedEvent[]>([]);\n\n const query = useQuery<Task | null, Error>({\n queryKey: queryKeys.taskStatus(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n // Poll until terminal / target reached; then stop (return `false`).\n refetchInterval: (q) => {\n const task = q.state.data ?? null;\n if (task === null) return pollIntervalMs;\n if (TERMINAL_STATUSES.has(task.status)) return false;\n if (\n options?.targetStatus !== undefined &&\n task.status === options.targetStatus\n ) {\n return false;\n }\n return pollIntervalMs;\n },\n });\n\n // Drain the optional event source in a browser-only effect (never during SSR;\n // effects don't run on the server). Abort + reset on unmount / source change.\n const refetchRef = useRef(query.refetch);\n refetchRef.current = query.refetch;\n const eventsSource = options?.events;\n useEffect(() => {\n if (!eventsSource) return;\n let cancelled = false;\n (async () => {\n try {\n for await (const ev of eventsSource) {\n if (cancelled) break;\n setEvents((prev) => [...prev, ev]);\n // A status-changing event landed — pull a fresh read.\n void refetchRef.current();\n }\n } catch {\n // A torn-down subscription (unmount) surfaces as an iterator throw;\n // swallow it — the read query owns the surfaced error channel.\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [eventsSource]);\n\n const task = query.data ?? null;\n return {\n task,\n status: task?.status ?? null,\n submission: hasResult(task) ? Uint8Array.from(task!.result) : null,\n events,\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useSubmissionReview(taskPda)` — buyer-side settlement actions.\n *\n * Exposes the three creator review verbs for a task in `PendingValidation`:\n * - `accept(...)` — accept the result and settle the escrow to the worker\n * (`client.acceptTaskResult`, a named client convenience);\n * - `reject(...)` — reject the result with a rejection hash\n * (`facade.rejectTaskResult` -> `client.send`);\n * - `requestChanges(...)` — return the task to the worker with a changes hash\n * (`facade.requestChanges` -> `client.send`).\n *\n * Each verb is its own mutation so a UI can show independent\n * pending/error/success per button. Typed `AgencError`s surface UNTOUCHED.\n *\n * The `task` PDA is bound at hook construction; callers pass only the per-call\n * settlement parties (worker / treasury / hashes) the SDK cannot derive.\n *\n * @module hooks/useSubmissionReview\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { facade, type facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { requireClient } from \"./internal.js\";\n\n/** Per-call input for `accept` (task auto-bound; signer defaults to the client). */\nexport type AcceptInput = Omit<\n Parameters<typeof facadeNs.acceptTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.acceptTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `reject`. */\nexport type RejectInput = Omit<\n Parameters<typeof facadeNs.rejectTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.rejectTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `requestChanges`. */\nexport type RequestChangesInput = Omit<\n Parameters<typeof facadeNs.requestChanges>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.requestChanges>[0][\"creator\"];\n};\n\n/** Lifecycle status of a review verb. */\nexport type ReviewStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** A single review verb's surface. */\nexport interface ReviewAction<TInput> {\n /** Run the action. Resolves to the tx signature; rejects with `AgencError`. */\n (input: TInput): Promise<string>;\n}\n\n/** Return value of {@link useSubmissionReview}. */\nexport interface UseSubmissionReviewResult {\n /** Accept the result and settle to the worker. */\n accept: ReviewAction<AcceptInput>;\n /** Reject the result (with a rejection hash). */\n reject: ReviewAction<RejectInput>;\n /** Request changes (with a changes hash), returning the task to the worker. */\n requestChanges: ReviewAction<RequestChangesInput>;\n /** Aggregate status: `pending` if any verb is in flight, else last settled. */\n status: ReviewStatus;\n /** The most recent error across the three verbs, or null. */\n error: Error | null;\n /** Signature of the last successful action, or null. */\n signature: string | null;\n /** Reset all three mutations to idle. */\n reset: () => void;\n}\n\nfunction statusOf(m: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): ReviewStatus {\n if (m.isPending) return \"pending\";\n if (m.isError) return \"error\";\n if (m.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/**\n * Buyer-side review actions for one task.\n *\n * @param taskPda - The Task PDA under review (bound to every verb).\n * @returns {@link UseSubmissionReviewResult}.\n */\nexport function useSubmissionReview(\n taskPda: Parameters<typeof facadeNs.acceptTaskResult>[0][\"task\"],\n): UseSubmissionReviewResult {\n const ctx = useAgencContext();\n\n const acceptMut = useMutation<string, Error, AcceptInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.acceptTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.acceptTaskResult>[0]);\n return signature;\n },\n });\n\n const rejectMut = useMutation<string, Error, RejectInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.rejectTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.rejectTaskResult>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const requestChangesMut = useMutation<string, Error, RequestChangesInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.requestChanges({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.requestChanges>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const accept = useCallback<ReviewAction<AcceptInput>>(\n (input) => acceptMut.mutateAsync(input),\n [acceptMut],\n );\n const reject = useCallback<ReviewAction<RejectInput>>(\n (input) => rejectMut.mutateAsync(input),\n [rejectMut],\n );\n const requestChanges = useCallback<ReviewAction<RequestChangesInput>>(\n (input) => requestChangesMut.mutateAsync(input),\n [requestChangesMut],\n );\n\n const anyPending =\n acceptMut.isPending || rejectMut.isPending || requestChangesMut.isPending;\n const status: ReviewStatus = anyPending\n ? \"pending\"\n : statusOf(\n // Surface the most recently-touched verb's terminal state.\n [acceptMut, rejectMut, requestChangesMut].find(\n (m) => m.isError || m.isSuccess,\n ) ?? acceptMut,\n );\n\n const error =\n acceptMut.error ?? rejectMut.error ?? requestChangesMut.error ?? null;\n const signature =\n acceptMut.data ?? rejectMut.data ?? requestChangesMut.data ?? null;\n\n return {\n accept,\n reject,\n requestChanges,\n status,\n error,\n signature,\n reset: () => {\n acceptMut.reset();\n rejectMut.reset();\n requestChangesMut.reset();\n },\n };\n}\n","/**\n * `useDispute(taskPda)` — dispute entry point + state for one task.\n *\n * Reads the task's `Dispute` account (via an injected reader seam — same reason\n * as `useTaskStatus`: the unified read transport has no raw account fetch and\n * litesvm has no RPC) and exposes `initiate(...)` which opens a dispute through\n * the write client (`client.initiateDispute`). Typed `AgencError`s surface\n * UNTOUCHED.\n *\n * @module hooks/useDispute\n */\nimport { useMutation, useQuery } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport {\n type Dispute,\n type facade as facadeNs,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys, requireClient } from \"./internal.js\";\n\n/** Reads a Dispute account for a task, returning the decoded value or null. */\nexport type DisputeReader = (\n taskPda: Address | string,\n) => Promise<Dispute | null>;\n\n/**\n * Per-call input for `initiate(...)`. This is the SDK `facade.initiateDispute`\n * input minus the fee-payer `authority` signer (defaulted to the client's\n * signer; pass it to override). `task` is bound at hook construction.\n */\nexport type InitiateDisputeInput = Omit<\n Parameters<typeof facadeNs.initiateDispute>[0],\n \"task\" | \"authority\"\n> & {\n /** Override the initiator authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.initiateDispute>[0][\"authority\"];\n};\n\n/** Lifecycle status of the initiate mutation. */\nexport type DisputeStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link useDispute}. */\nexport interface UseDisputeOptions {\n /** How to read the Dispute account. Without it the read stays idle. */\n disputeReader?: DisputeReader;\n /** Disable the read query. Default `true` when `taskPda` + reader exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useDispute}. */\nexport interface UseDisputeResult {\n /** The decoded dispute, or null (none open / not yet read). */\n dispute: Dispute | null;\n /** Open a dispute. Resolves to the tx signature; rejects with `AgencError`. */\n initiate: (input: InitiateDisputeInput) => Promise<string>;\n /** Status of the initiate mutation. */\n status: DisputeStatus;\n /** Signature of the last successful initiate, or null. */\n signature: string | null;\n /** The read OR initiate error, or null. */\n error: Error | null;\n /** True while reading the dispute. */\n isLoading: boolean;\n /** Force a dispute refetch. */\n refetch: () => void;\n /** Reset the initiate mutation. */\n reset: () => void;\n}\n\n/**\n * Dispute entry + state for one task.\n *\n * @param taskPda - The Task PDA (falsy disables the read).\n * @param options - Reader + enabled.\n * @returns {@link UseDisputeResult}.\n */\nexport function useDispute(\n taskPda: Address | string | undefined | null,\n options?: UseDisputeOptions,\n): UseDisputeResult {\n const ctx = useAgencContext();\n const reader = options?.disputeReader;\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);\n\n const read = useQuery<Dispute | null, Error>({\n queryKey: queryKeys.dispute(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n });\n\n const mutation = useMutation<string, Error, InitiateDisputeInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.initiateDispute({\n ...input,\n task: taskPda as Address,\n authority: input.authority ?? client.signer,\n } as Parameters<typeof facadeNs.initiateDispute>[0]);\n // A new dispute exists — refresh the read.\n void read.refetch();\n return signature;\n },\n });\n\n const initiate = useCallback(\n (input: InitiateDisputeInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: DisputeStatus = mutation.isPending\n ? \"pending\"\n : mutation.isError\n ? \"error\"\n : mutation.isSuccess\n ? \"success\"\n : \"idle\";\n\n return {\n dispute: read.data ?? null,\n initiate,\n status,\n signature: mutation.data ?? null,\n error: mutation.error ?? read.error ?? null,\n isLoading: read.isLoading,\n refetch: () => void read.refetch(),\n reset: mutation.reset,\n };\n}\n","/**\n * `useReferrerEarnings(wallet)` — referrer earnings (STRICTLY P6.2-GATED).\n *\n * ## THE P6.2 GATE (PLAN_2 §0, MANDATORY — this hook is the canonical example)\n *\n * Referrer earnings depend on TWO unbuilt things:\n * 1. the on-chain P6.2 referrer fields snapshotted on `HireRecord` (the 4th\n * settlement leg), and\n * 2. the off-chain `GET /api/explorer/referrers/:wallet/hires` indexer endpoint\n * that aggregates them.\n *\n * NEITHER exists today. So this hook:\n * - resolves `resolveReferrerCapability()` from context;\n * - when `live === false` (ALWAYS, today): returns the documented not-live\n * state `{ live: false, totalLamports: 0n, hires: [] }` and makes NO network\n * request. It NEVER fabricates earnings and NEVER infers a non-zero total\n * from anything.\n * - the real fetch path is written but DEAD-CODE-GATED behind `capability.live`\n * with a clear TODO, so when P6.2 + the endpoint land, only the gate flips —\n * the surface does not change.\n *\n * @module hooks/useReferrerEarnings\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { t } from \"../strings/index.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** A single referral-earning hire (shape defined now; populated post-P6.2). */\nexport interface ReferrerHire {\n /** The minted Task PDA of the referred hire. */\n taskPda: string;\n /** The HireRecord PDA carrying the snapshotted referrer fields. */\n hireRecordPda: string;\n /** Referral fee earned on this hire, in lamports. */\n feeLamports: bigint;\n /** Transaction signature of the hire. */\n signature: string;\n}\n\n/** Return value of {@link useReferrerEarnings}. */\nexport interface UseReferrerEarningsResult {\n /**\n * Whether referral settlement is live on this cluster. ALWAYS `false` today\n * (the P6.2 gate). When false, the numbers below are the documented not-live\n * zero state, not real data.\n */\n live: boolean;\n /** Total lamports earned. `0n` while not live (never fabricated). */\n totalLamports: bigint;\n /** Per-hire earnings. `[]` while not live. */\n hires: ReferrerHire[];\n /** True while a (post-P6.2) fetch is in flight. Always false today. */\n isLoading: boolean;\n /** The fetch error, or null. */\n error: Error | null;\n /**\n * Human-readable reason the data is not live (the capability reason). Present\n * while `live` is false.\n */\n reason?: string;\n /** Force a refetch (no-op while not live). */\n refetch: () => void;\n}\n\n/**\n * Read a referrer wallet's earnings.\n *\n * @param wallet - The referrer wallet (base58 / Address). Falsy disables the\n * (future) fetch; the not-live state is still returned.\n * @returns {@link UseReferrerEarningsResult} — the not-live zero state today.\n *\n * @example\n * ```tsx\n * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);\n * // today: live === false, totalLamports === 0n, hires === []\n * ```\n */\nexport function useReferrerEarnings(\n wallet: Address | string | undefined | null,\n): UseReferrerEarningsResult {\n const ctx = useAgencContext();\n const capability = ctx.resolveReferrerCapability();\n\n // THE GATE: the query is enabled ONLY when referral settlement is live. Today\n // `capability.live` is hardcoded false, so this query never runs and we\n // return the not-live zero state below. NEVER remove this gate.\n const enabled = capability.live && Boolean(wallet);\n\n const query = useQuery<{ totalLamports: bigint; hires: ReferrerHire[] }, Error>(\n {\n queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : \"\"),\n enabled,\n queryFn: async () => {\n // TODO(P6.2 / indexer): once the referrer fields exist on HireRecord\n // AND the indexer exposes `GET /api/explorer/referrers/:wallet/hires`,\n // fetch + sum here. Unreachable today because `enabled` is gated on\n // `capability.live` (hardcoded false). Returning fabricated numbers\n // here would violate PLAN_2 §0 — do not.\n throw new Error(\n \"useReferrerEarnings: the P6.2 referrer earnings path is not \" +\n \"deployed; this query must never run while capability.live is false.\",\n );\n },\n },\n );\n\n if (!capability.live) {\n // The documented not-live state. Zeroes are HONEST (no data exists), not\n // fabricated, and no request was made.\n return {\n live: false,\n totalLamports: 0n,\n hires: [],\n isLoading: false,\n error: null,\n reason: capability.reason ?? t(\"referrer.notLiveReason\"),\n refetch: () => {\n /* no-op while not live */\n },\n };\n }\n\n // --- Post-P6.2 path (currently unreachable; kept wired for the flip) ---\n return {\n live: true,\n totalLamports: query.data?.totalLamports ?? 0n,\n hires: query.data?.hires ?? [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/hooks/useListings.ts","../../src/hooks/useListing.ts","../../src/hooks/useAgentTrackRecord.ts","../../src/hooks/useTaskStatus.ts","../../src/hooks/useSubmissionReview.ts","../../src/hooks/useTaskActivation.ts","../../src/hooks/useHumanlessHireFlow.ts","../../src/hooks/useTaskWork.ts","../../src/hooks/useTaskLifecycle.ts","../../src/hooks/useRateHire.ts","../../src/hooks/useDispute.ts","../../src/hooks/useReferrerEarnings.ts"],"names":["useQuery","useState","task","signature","useCallback","useMutation","useRef"],"mappings":";;;;;;;;AAuEA,IAAM,iBAAA,GAAoB,EAAA;AAgBnB,SAAS,WAAA,CACd,QACA,OAAA,EACmB;AACnB,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,eAAA,EAAgB;AACjC,EAAA,MAAM,QAAA,GAAW,SAAS,QAAA,IAAY,iBAAA;AACtC,EAAA,MAAM,OAAA,GAAU,SAAS,OAAA,IAAW,IAAA;AAEpC,EAAA,MAAM,QAAQ,QAAA,CAA8B;AAAA,IAC1C,QAAA,EAAU,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA;AAAA,IACnC,OAAA,EAAS,MAAM,IAAA,CAAK,kBAAA,CAAmB,MAAM,CAAA;AAAA,IAC7C;AAAA,GACD,CAAA;AAID,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,QAAQ,CAAA;AAE/C,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,IAAA,IAAQ,EAAC;AAG3B,EAAA,MAAM,UAAA,GAAa,KAAK,GAAA,CAAI,IAAA,CAAK,IAAI,OAAA,EAAS,QAAQ,CAAA,EAAG,GAAA,CAAI,MAAM,CAAA;AACnE,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACf,MAAM,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,UAAU,CAAA;AAAA,IAC7B,CAAC,KAAK,UAAU;AAAA,GAClB;AAEA,EAAA,MAAM,SAAA,GAAY,YAAY,MAAM;AAClC,IAAA,UAAA,CAAW,CAA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AAA;AAAA,MACf,OAAO,EAAC;AAAA,MACR,SAAA,EAAW,KAAA;AAAA,MACX,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,WAAW,IAAA,GACf,CAAA,CAAE,gCAAgC,CAAA,GACjC,UAAA,CAAW,MAAA,IAAU,CAAA,CAAE,wBAAwB,CAAA;AAAA,MACpD,SAAS,MAAM;AAAA,MAEf;AAAA,KACF;AAAA,EACF;AAWF","file":"index.js","sourcesContent":["/**\n * `useListings(filter?)` — the listing-grid read hook.\n *\n * Fetches active service listings through the provider's unified read transport\n * (indexer-first, gPA fallback — the hook never branches on which is live) and\n * caches them via TanStack Query. Filters (`provider`, `category`, `state`) are\n * forwarded verbatim to the transport, which applies server-side memcmp filters\n * (indexer/gPA) and the client-side state filter exactly as the SDK does.\n *\n * ## Pagination model (honest about the transport)\n *\n * The v1 read transport returns the FULL active-listing set in one call — there\n * is no server cursor in either backend (the gPA path can't have one; the\n * indexer's `listActiveListings` is a drop-in of it). So pagination here is a\n * client-side WINDOW over the already-fetched array: `listings` grows by\n * `pageSize` each time `fetchMore()` is called, `hasMore` reflects whether more\n * rows remain in the fetched set. This keeps one network round-trip while still\n * giving a grid an incremental-reveal API. When a future transport gains a\n * cursor, `fetchMore` can swap to `fetchNextPage` without changing this\n * surface.\n *\n * SSR-safe: no `window`/`document`; the query simply does not run until mounted\n * if the host disables it.\n *\n * @module hooks/useListings\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type {\n DecodedProgramAccount,\n ListActiveListingsOptions,\n ServiceListing,\n} from \"../types.js\";\nimport { queryKeys } from \"./internal.js\";\n\n/** A decoded active listing row (address + decoded account). */\nexport type ListingRow = DecodedProgramAccount<ServiceListing>;\n\n/** Filter for {@link useListings}. Mirrors the SDK's `ListActiveListingsOptions`. */\nexport type UseListingsFilter = ListActiveListingsOptions;\n\n/** Options for {@link useListings}. */\nexport interface UseListingsOptions {\n /** Rows revealed per page / per `fetchMore()` call. Default `12`. */\n pageSize?: number;\n /**\n * Disable the query (e.g. until a filter is ready). When `false` the hook\n * returns the idle state and makes no request. Default `true`.\n */\n enabled?: boolean;\n}\n\n/** Return value of {@link useListings}. */\nexport interface UseListingsResult {\n /** The currently-revealed window of listings (grows via `fetchMore`). */\n listings: ListingRow[];\n /** Total active listings the transport returned (the full fetched set). */\n total: number;\n /** True while the underlying fetch is in flight (first load / refetch). */\n isLoading: boolean;\n /** The fetch error (typed `AgencError` for on-chain failures), or null. */\n error: Error | null;\n /** Whether more rows remain in the fetched set to reveal. */\n hasMore: boolean;\n /** Reveal the next `pageSize` rows from the fetched set. No-op when exhausted. */\n fetchMore: () => void;\n /** Force a fresh fetch from the transport. */\n refetch: () => void;\n}\n\nconst DEFAULT_PAGE_SIZE = 12;\n\n/**\n * Read active service listings for a grid.\n *\n * @param filter - Optional provider/category/state filter (SDK semantics).\n * @param options - Page size + enabled flag.\n * @returns {@link UseListingsResult}.\n *\n * @example\n * ```tsx\n * const { listings, isLoading, fetchMore, hasMore } = useListings({\n * category: \"code-generation\",\n * });\n * ```\n */\nexport function useListings(\n filter?: UseListingsFilter,\n options?: UseListingsOptions,\n): UseListingsResult {\n const { read } = useAgencContext();\n const pageSize = options?.pageSize ?? DEFAULT_PAGE_SIZE;\n const enabled = options?.enabled ?? true;\n\n const query = useQuery<ListingRow[], Error>({\n queryKey: queryKeys.listings(filter),\n queryFn: () => read.listActiveListings(filter),\n enabled,\n });\n\n // Client-side reveal window. Reset to one page whenever the underlying data\n // changes (new fetch / filter change resets the key, which remounts data).\n const [visible, setVisible] = useState(pageSize);\n\n const all = query.data ?? [];\n // Clamp the window to [pageSize, all.length] so a filter change that shrinks\n // the set never strands `visible` above the available rows.\n const windowSize = Math.min(Math.max(visible, pageSize), all.length);\n const listings = useMemo(\n () => all.slice(0, windowSize),\n [all, windowSize],\n );\n\n const fetchMore = useCallback(() => {\n setVisible((current) => current + pageSize);\n }, [pageSize]);\n\n const refetch = useCallback(() => {\n setVisible(pageSize);\n void query.refetch();\n }, [pageSize, query]);\n\n return {\n listings,\n total: all.length,\n isLoading: query.isLoading,\n error: query.error ?? null,\n hasMore: windowSize < all.length,\n fetchMore,\n refetch,\n };\n}\n","/**\n * `useListing(pda)` — single-listing detail hook.\n *\n * Joins, in ONE cached query, the three things a listing detail / checkout view\n * needs:\n * - the decoded `ServiceListing` (via `read.getListing`);\n * - the provider's track record (via `read.agentTrackRecord(providerAgent)`),\n * keyed off the listing's `providerAgent` — indexer-native, so it is fetched\n * only when the indexer backend is live and resolves to `null` under the gPA\n * fallback (which has no trustless aggregated track record — the transport\n * throws `ReadTransportUnsupportedError`, which the hook swallows to `null`\n * rather than failing the whole join);\n * - the moderation/attestation state (see the moderation note below).\n *\n * ## Moderation (v1 scope, honest)\n *\n * The read transport does not yet expose a dedicated listing-moderation read\n * (the indexer's listing projection carries the pinned `specHash` but not an\n * attestation verdict). So `moderation` is the listing's indexer projection when\n * present (callers can read `indexer.metadataValid` / `metadataIssues` and the\n * pinned `specHash`) and `null` under the gPA fallback. A dedicated attestation\n * read lands when the indexer projects it; this hook's surface does not change.\n *\n * @module hooks/useListing\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { ReadTransportUnsupportedError } from \"../transport/index.js\";\nimport type {\n Address,\n IndexerAgentTrackRecord,\n IndexerListing,\n ServiceListing,\n} from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** The joined detail payload {@link useListing} resolves. */\nexport interface ListingDetail {\n /** The listing PDA. */\n address: Address;\n /** The decoded on-chain `ServiceListing`. */\n listing: ServiceListing;\n /** The provider's agent PDA (`ServiceListing.providerAgent`). */\n provider: Address;\n /**\n * The provider's indexer track record, or `null` when unavailable (the gPA\n * fallback has no trustless aggregated equivalent).\n */\n trackRecord: IndexerAgentTrackRecord | null;\n /**\n * The listing's indexer projection (carries `metadataValid`,\n * `metadataIssues`, the pinned `specHash`), or `null` under the gPA fallback.\n * The v1 read model does not yet project a standalone attestation verdict.\n */\n moderation: IndexerListing | null;\n}\n\n/** Options for {@link useListing}. */\nexport interface UseListingOptions {\n /** Disable the query (no `pda` yet, etc.). Default `true` when `pda` is set. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useListing}. */\nexport interface UseListingResult {\n /** The joined detail, or null until loaded. */\n detail: ListingDetail | null;\n /** The decoded listing, or null until loaded (convenience projection). */\n listing: ServiceListing | null;\n /** The provider agent PDA, or null until loaded. */\n provider: Address | null;\n /** The provider's track record, or null (unavailable / not yet loaded). */\n trackRecord: IndexerAgentTrackRecord | null;\n /** The listing's indexer/moderation projection, or null. */\n moderation: IndexerListing | null;\n /** True while loading. */\n isLoading: boolean;\n /** The error, or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/**\n * Read one listing and join its provider track record + moderation projection.\n *\n * @param pda - The ServiceListing PDA (string or Address). When falsy the query\n * is disabled.\n * @param options - `enabled` override.\n * @returns {@link UseListingResult}.\n */\nexport function useListing(\n pda: Address | string | undefined | null,\n options?: UseListingOptions,\n): UseListingResult {\n const { read } = useAgencContext();\n const enabled = (options?.enabled ?? true) && Boolean(pda);\n\n const query = useQuery<ListingDetail, Error>({\n queryKey: queryKeys.listing(pda ? pdaKey(pda) : \"\"),\n enabled,\n queryFn: async () => {\n // 1) The listing itself.\n const result = await read.getListing(pda as Address | string);\n const provider = result.account.providerAgent;\n\n // 2) The provider's track record — indexer-native. Swallow the\n // gPA-fallback \"unsupported\" rejection to null so the join still\n // resolves the listing + moderation (degrade, don't fail).\n let trackRecord: IndexerAgentTrackRecord | null = null;\n try {\n trackRecord = await read.agentTrackRecord(provider);\n } catch (err) {\n if (!(err instanceof ReadTransportUnsupportedError)) throw err;\n }\n\n return {\n address: result.address,\n listing: result.account,\n provider,\n trackRecord,\n moderation: result.indexer ?? null,\n };\n },\n });\n\n const detail = query.data ?? null;\n return {\n detail,\n listing: detail?.listing ?? null,\n provider: detail?.provider ?? null,\n trackRecord: detail?.trackRecord ?? null,\n moderation: detail?.moderation ?? null,\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useAgentTrackRecord(agentPda)` — provider reputation hook (PARTIAL, P6.6).\n *\n * Reads the indexer's reconstructed track record for an agent and projects the\n * `{ completionRate, disputeRate, slashHistory, recentOutcomes }` contract.\n *\n * ## P6.6 scope (honest about what is and isn't available)\n *\n * The v1 indexer record (`IndexerAgentTrackRecord`) is event-reconstructed and\n * exposes raw COUNTS: `completions`, `disputesInitiated`, `disputesLost`, and a\n * `slashHistory`. It does NOT yet expose the denominators a true RATE needs\n * (total tasks taken, total disputes faced) — that aggregation lands in\n * PLAN.md P6.6. So:\n * - `slashHistory` and the dispute COUNTS are real today (passed through);\n * - `completionRate` / `disputeRate` are RATIOS and are only meaningful once a\n * denominator exists. Today they are computed from the available counts where\n * a denominator is inferable (completions vs. completions+disputesLost as a\n * conservative proxy) and otherwise `null`. Treat them as provisional until\n * P6.6. The `partial` flag is the audit signal — `true` today.\n * - `recentOutcomes` is reconstructed from `slashHistory` (the only per-event\n * stream in v1); a richer outcome feed lands with P6.6.\n *\n * Indexer-native: the gPA fallback has no aggregated track record, so under it\n * `read.agentTrackRecord` throws `ReadTransportUnsupportedError` and this hook\n * surfaces that error (a track record is not reconstructable trustlessly).\n *\n * @module hooks/useAgentTrackRecord\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address, IndexerAgentTrackRecord } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** A reconstructed outcome event (v1: derived from the slash history). */\nexport interface TrackRecordOutcome {\n /** Outcome kind. v1 only reconstructs slashes from the event stream. */\n kind: \"slash\";\n /** The raw slash event from the indexer record. */\n event: IndexerAgentTrackRecord[\"slashHistory\"][number];\n}\n\n/** The projected track record {@link useAgentTrackRecord} returns. */\nexport interface AgentTrackRecord {\n /** The agent PDA. */\n agent: Address | string;\n /** Completed-task count (real today). */\n completions: number;\n /** Disputes the agent initiated (real today). */\n disputesInitiated: number;\n /** Disputes the agent lost (real today). */\n disputesLost: number;\n /**\n * Completion rate in `[0,1]`, or `null` when no denominator is inferable.\n * PROVISIONAL until P6.6 supplies the true total-tasks denominator.\n */\n completionRate: number | null;\n /**\n * Dispute rate in `[0,1]`, or `null` when no denominator is inferable.\n * PROVISIONAL until P6.6.\n */\n disputeRate: number | null;\n /** Reconstructed slash history (real today). */\n slashHistory: IndexerAgentTrackRecord[\"slashHistory\"];\n /** Reconstructed recent outcomes (v1: from slash history). */\n recentOutcomes: TrackRecordOutcome[];\n /** True while any rate is provisional/derived (P6.6 audit signal). */\n partial: boolean;\n}\n\n/** Options for {@link useAgentTrackRecord}. */\nexport interface UseAgentTrackRecordOptions {\n /** Disable the query. Default `true` when `agentPda` is set. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useAgentTrackRecord}. */\nexport interface UseAgentTrackRecordResult {\n /** The projected track record, or null until loaded. */\n trackRecord: AgentTrackRecord | null;\n /** Convenience: `trackRecord?.completionRate ?? null`. */\n completionRate: number | null;\n /** Convenience: `trackRecord?.disputeRate ?? null`. */\n disputeRate: number | null;\n /** Convenience: `trackRecord?.slashHistory ?? []`. */\n slashHistory: IndexerAgentTrackRecord[\"slashHistory\"];\n /** Convenience: `trackRecord?.recentOutcomes ?? []`. */\n recentOutcomes: TrackRecordOutcome[];\n /** True while loading. */\n isLoading: boolean;\n /** The error (e.g. `ReadTransportUnsupportedError` under gPA), or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/**\n * Project the raw indexer record into the partial track-record contract. Kept\n * exported + pure so structural tests can assert the projection directly.\n */\nexport function projectTrackRecord(\n raw: IndexerAgentTrackRecord,\n): AgentTrackRecord {\n const completions = raw.completions;\n const disputesLost = raw.disputesLost;\n // Conservative proxy denominator: settled outcomes we can SEE (completions +\n // lost disputes). This is NOT the true total-tasks denominator (P6.6); when\n // it is zero there is nothing to rate, so the rates are null.\n const settledKnown = completions + disputesLost;\n const completionRate =\n settledKnown > 0 ? completions / settledKnown : null;\n const disputeRate =\n settledKnown > 0 ? disputesLost / settledKnown : null;\n\n return {\n agent: raw.agent,\n completions,\n disputesInitiated: raw.disputesInitiated,\n disputesLost,\n completionRate,\n disputeRate,\n slashHistory: raw.slashHistory,\n recentOutcomes: raw.slashHistory.map((event) => ({\n kind: \"slash\" as const,\n event,\n })),\n // Always partial in v1: every rate is a proxy until P6.6 lands the real\n // denominators and outcome feed.\n partial: true,\n };\n}\n\n/**\n * Read an agent's (partial) track record.\n *\n * @param agentPda - The AgentRegistration PDA (falsy disables the hook).\n * @param options - `enabled` override.\n * @returns {@link UseAgentTrackRecordResult}.\n */\nexport function useAgentTrackRecord(\n agentPda: Address | string | undefined | null,\n options?: UseAgentTrackRecordOptions,\n): UseAgentTrackRecordResult {\n const { read } = useAgencContext();\n const enabled = (options?.enabled ?? true) && Boolean(agentPda);\n\n const query = useQuery<AgentTrackRecord, Error>({\n queryKey: queryKeys.agentTrackRecord(agentPda ? pdaKey(agentPda) : \"\"),\n enabled,\n queryFn: async () => {\n const raw = await read.agentTrackRecord(agentPda as Address | string);\n return projectTrackRecord(raw);\n },\n });\n\n const tr = query.data ?? null;\n return {\n trackRecord: tr,\n completionRate: tr?.completionRate ?? null,\n disputeRate: tr?.disputeRate ?? null,\n slashHistory: tr?.slashHistory ?? [],\n recentOutcomes: tr?.recentOutcomes ?? [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useTaskStatus(taskPda)` — live task status with a poll fallback.\n *\n * Tracks a Task account's {@link TaskStatus} (and optionally its submission and\n * the coordination events seen for it) after a hire. It is built to satisfy the\n * PLAN_2 A2 contract `{ task, status, submission, events }` while staying SSR-\n * and transport-agnostic.\n *\n * ## How it reads (the seam)\n *\n * The unified read transport intentionally has NO raw account fetch, and the\n * litesvm e2e harness has no RPC — so a task read cannot be assumed from\n * context. `useTaskStatus` therefore takes a **`taskReader`**: an async\n * `(pda) => Promise<Task | null>`. Callers wire it from whatever they have:\n * - a kit RPC: `(pda) => getTaskDecoder().decode(...)` over `getAccountInfo`\n * (the SDK's `waitForTaskStatus` uses exactly this `getAccountInfo` shape);\n * - litesvm e2e: `(pda) => decode(svm.getAccount(pda))`.\n * A reader-less call returns the idle state (and a clear `error` if `poll` was\n * requested) rather than guessing a transport.\n *\n * ## Polling vs. subscription (SSR-safe, cleaned up)\n *\n * - Polling: TanStack Query `refetchInterval` re-runs `taskReader` until the\n * task reaches a terminal status (`Completed`/`Cancelled`/`RejectFrozen`) or\n * the optional `targetStatus` — then stops.\n * - Subscription: when an `events` async-iterable is supplied (e.g. from the\n * SDK's `subscribeMarketplaceEvents`), a `useEffect` (browser-only; never runs\n * during SSR) drains it, appends each event to `events`, and triggers a\n * refetch so status stays fresh without tight polling. The effect aborts the\n * iterable and clears state on unmount.\n *\n * @module hooks/useTaskStatus\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { TaskStatus, type Task } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** Reads a Task account, returning the decoded {@link Task} or null if absent. */\nexport type TaskReader = (pda: Address | string) => Promise<Task | null>;\n\n/**\n * A single coordination event observed for the watched task. Kept loosely typed\n * (the SDK's `AgencEvent` union) so this hook does not pin the event schema.\n */\nexport type ObservedEvent = unknown;\n\n/**\n * An async source of coordination events for the watched task. Pass the result\n * of the SDK's `subscribeMarketplaceEvents(...)` (already address-filtered) or\n * any async iterable. Optional.\n */\nexport type TaskEventsSource = AsyncIterable<ObservedEvent>;\n\n/** Options for {@link useTaskStatus}. */\nexport interface UseTaskStatusOptions {\n /**\n * How to read the Task account. REQUIRED for any live status — without it the\n * hook stays idle. See the module doc for wiring patterns.\n */\n taskReader?: TaskReader;\n /**\n * Optional event source. When given, observed events are appended to\n * `events` and each triggers a refetch. Drained in a browser-only effect and\n * aborted on unmount.\n */\n events?: TaskEventsSource;\n /**\n * Stop polling once the task reaches this status (in addition to terminal\n * statuses). Useful to await a specific transition (e.g. `Completed`).\n */\n targetStatus?: TaskStatus;\n /** Poll interval in ms while non-terminal. Default `2000`. */\n pollIntervalMs?: number;\n /** Disable the hook entirely. Default `true` when `taskPda` + reader exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useTaskStatus}. */\nexport interface UseTaskStatusResult {\n /** The decoded Task, or null until first read. */\n task: Task | null;\n /** The task status, or null until first read. */\n status: TaskStatus | null;\n /**\n * The submission projection. v1 surfaces the task's on-chain `result` bytes\n * (the worker's submitted result) once present; a richer submission read\n * lands with the indexer projection. `null` until a result exists.\n */\n submission: Uint8Array | null;\n /** Coordination events observed for this task (chronological). */\n events: ObservedEvent[];\n /** True while the first read is in flight. */\n isLoading: boolean;\n /** The read error, or null. */\n error: Error | null;\n /** Force a refetch. */\n refetch: () => void;\n}\n\n/** Statuses after which no further transition is possible (stop polling). */\nconst TERMINAL_STATUSES: ReadonlySet<TaskStatus> = new Set([\n TaskStatus.Completed,\n TaskStatus.Cancelled,\n TaskStatus.RejectFrozen,\n]);\n\n/** True when the task's `result` bytes are present and non-empty. */\nfunction hasResult(task: Task | null): boolean {\n return task !== null && task.result.length > 0 && task.result.some((b) => b !== 0);\n}\n\n/**\n * Watch a task's status.\n *\n * @param taskPda - The Task PDA to watch (falsy disables the hook).\n * @param options - Reader, event source, target status, poll interval.\n * @returns {@link UseTaskStatusResult}.\n */\nexport function useTaskStatus(\n taskPda: Address | string | undefined | null,\n options?: UseTaskStatusOptions,\n): UseTaskStatusResult {\n // Touch context so the hook is provider-bound (and throws clearly outside it),\n // matching every other hook's contract even though reads come via the reader.\n useAgencContext();\n\n const reader = options?.taskReader;\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);\n const pollIntervalMs = options?.pollIntervalMs ?? 2000;\n\n const [events, setEvents] = useState<ObservedEvent[]>([]);\n\n const query = useQuery<Task | null, Error>({\n queryKey: queryKeys.taskStatus(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n // Poll until terminal / target reached; then stop (return `false`).\n refetchInterval: (q) => {\n const task = q.state.data ?? null;\n if (task === null) return pollIntervalMs;\n if (TERMINAL_STATUSES.has(task.status)) return false;\n if (\n options?.targetStatus !== undefined &&\n task.status === options.targetStatus\n ) {\n return false;\n }\n return pollIntervalMs;\n },\n });\n\n // Drain the optional event source in a browser-only effect (never during SSR;\n // effects don't run on the server). Abort + reset on unmount / source change.\n const refetchRef = useRef(query.refetch);\n refetchRef.current = query.refetch;\n const eventsSource = options?.events;\n useEffect(() => {\n if (!eventsSource) return;\n let cancelled = false;\n (async () => {\n try {\n for await (const ev of eventsSource) {\n if (cancelled) break;\n setEvents((prev) => [...prev, ev]);\n // A status-changing event landed — pull a fresh read.\n void refetchRef.current();\n }\n } catch {\n // A torn-down subscription (unmount) surfaces as an iterator throw;\n // swallow it — the read query owns the surfaced error channel.\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [eventsSource]);\n\n const task = query.data ?? null;\n return {\n task,\n status: task?.status ?? null,\n submission: hasResult(task) ? Uint8Array.from(task!.result) : null,\n events,\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * `useSubmissionReview(taskPda)` — buyer-side settlement actions.\n *\n * Exposes the three creator review verbs for a task in `PendingValidation`:\n * - `accept(...)` — accept the result and settle the escrow to the worker\n * (`client.acceptTaskResult`, a named client convenience);\n * - `reject(...)` — reject the result with a rejection hash\n * (`facade.rejectTaskResult` -> `client.send`);\n * - `requestChanges(...)` — return the task to the worker with a changes hash\n * (`facade.requestChanges` -> `client.send`).\n *\n * Each verb is its own mutation so a UI can show independent\n * pending/error/success per button. Typed `AgencError`s surface UNTOUCHED.\n *\n * The `task` PDA is bound at hook construction; callers pass only the per-call\n * settlement parties (worker / treasury / hashes) the SDK cannot derive.\n *\n * @module hooks/useSubmissionReview\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { facade, type facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { requireClient } from \"./internal.js\";\n\n/** Per-call input for `accept` (task auto-bound; signer defaults to the client). */\nexport type AcceptInput = Omit<\n Parameters<typeof facadeNs.acceptTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.acceptTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `reject`. */\nexport type RejectInput = Omit<\n Parameters<typeof facadeNs.rejectTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.rejectTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `requestChanges`. */\nexport type RequestChangesInput = Omit<\n Parameters<typeof facadeNs.requestChanges>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.requestChanges>[0][\"creator\"];\n};\n\n/** Lifecycle status of a review verb. */\nexport type ReviewStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** A single review verb's surface. */\nexport interface ReviewAction<TInput> {\n /** Run the action. Resolves to the tx signature; rejects with `AgencError`. */\n (input: TInput): Promise<string>;\n}\n\n/** Return value of {@link useSubmissionReview}. */\nexport interface UseSubmissionReviewResult {\n /** Accept the result and settle to the worker. */\n accept: ReviewAction<AcceptInput>;\n /** Reject the result (with a rejection hash). */\n reject: ReviewAction<RejectInput>;\n /** Request changes (with a changes hash), returning the task to the worker. */\n requestChanges: ReviewAction<RequestChangesInput>;\n /** Aggregate status: `pending` if any verb is in flight, else last settled. */\n status: ReviewStatus;\n /** The most recent error across the three verbs, or null. */\n error: Error | null;\n /** Signature of the last successful action, or null. */\n signature: string | null;\n /** Reset all three mutations to idle. */\n reset: () => void;\n}\n\nfunction statusOf(m: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): ReviewStatus {\n if (m.isPending) return \"pending\";\n if (m.isError) return \"error\";\n if (m.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/**\n * Buyer-side review actions for one task.\n *\n * @param taskPda - The Task PDA under review (bound to every verb).\n * @returns {@link UseSubmissionReviewResult}.\n */\nexport function useSubmissionReview(\n taskPda: Parameters<typeof facadeNs.acceptTaskResult>[0][\"task\"],\n): UseSubmissionReviewResult {\n const ctx = useAgencContext();\n\n const acceptMut = useMutation<string, Error, AcceptInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.acceptTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.acceptTaskResult>[0]);\n return signature;\n },\n });\n\n const rejectMut = useMutation<string, Error, RejectInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.rejectTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.rejectTaskResult>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const requestChangesMut = useMutation<string, Error, RequestChangesInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.requestChanges({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.requestChanges>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const accept = useCallback<ReviewAction<AcceptInput>>(\n (input) => acceptMut.mutateAsync(input),\n [acceptMut],\n );\n const reject = useCallback<ReviewAction<RejectInput>>(\n (input) => rejectMut.mutateAsync(input),\n [rejectMut],\n );\n const requestChanges = useCallback<ReviewAction<RequestChangesInput>>(\n (input) => requestChangesMut.mutateAsync(input),\n [requestChangesMut],\n );\n\n const anyPending =\n acceptMut.isPending || rejectMut.isPending || requestChangesMut.isPending;\n const status: ReviewStatus = anyPending\n ? \"pending\"\n : statusOf(\n // Surface the most recently-touched verb's terminal state.\n [acceptMut, rejectMut, requestChangesMut].find(\n (m) => m.isError || m.isSuccess,\n ) ?? acceptMut,\n );\n\n const error =\n acceptMut.error ?? rejectMut.error ?? requestChangesMut.error ?? null;\n const signature =\n acceptMut.data ?? rejectMut.data ?? requestChangesMut.data ?? null;\n\n return {\n accept,\n reject,\n requestChanges,\n status,\n error,\n signature,\n reset: () => {\n acceptMut.reset();\n rejectMut.reset();\n requestChangesMut.reset();\n },\n };\n}\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport {\n mutationStatusOf,\n requireClient,\n type MutationStatus,\n} from \"./internal.js\";\n\nexport type TaskActivationInput = Omit<\n Parameters<typeof facadeNs.setTaskJobSpec>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.setTaskJobSpec>[0][\"creator\"];\n};\n\nexport type TaskActivationStatus = MutationStatus;\n\nexport interface UseTaskActivationResult {\n activate: (input: TaskActivationInput) => Promise<string>;\n status: TaskActivationStatus;\n signature: string | null;\n error: Error | null;\n isPending: boolean;\n reset: () => void;\n}\n\nexport function useTaskActivation(\n taskPda: Parameters<typeof facadeNs.setTaskJobSpec>[0][\"task\"],\n): UseTaskActivationResult {\n const ctx = useAgencContext();\n const mutation = useMutation<string, Error, TaskActivationInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.setTaskJobSpec({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.setTaskJobSpec>[0]);\n return signature;\n },\n });\n\n const activate = useCallback(\n (input: TaskActivationInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n return {\n activate,\n status: mutationStatusOf(mutation),\n signature: mutation.data ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { findTaskPda } from \"@tetsuo-ai/marketplace-sdk\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport {\n mutationStatusOf,\n requireClient,\n resolveReferrerArgs,\n signerAddress,\n withoutReferrerArgs,\n type MutationStatus,\n} from \"./internal.js\";\nimport type { HumanlessHireInput } from \"./useHire.js\";\nimport type { TaskActivationInput } from \"./useTaskActivation.js\";\n\nexport type HumanlessHireFlowPhase =\n | \"idle\"\n | \"hiring\"\n | \"moderating\"\n | \"activating\"\n | \"activated\"\n | \"error\";\n\nexport type HumanlessHireFlowStatus = MutationStatus;\n\nexport type HumanlessHireFlowHireInput = Omit<\n HumanlessHireInput,\n \"humanless\" | \"creator\" | \"referrer\" | \"referrerFeeBps\"\n>;\n\nexport type HumanlessHireFlowActivationInput = Omit<\n TaskActivationInput,\n \"creator\" | \"jobSpecHash\" | \"jobSpecUri\"\n>;\n\nexport type HumanlessHireFlowCreator = HumanlessHireInput[\"creator\"];\n\nexport type HumanlessHireFlowJobSpecHash =\n Parameters<typeof facadeNs.setTaskJobSpec>[0][\"jobSpecHash\"];\n\nexport interface HumanlessHireFlowModerationResult {\n jobSpecHash: HumanlessHireFlowJobSpecHash;\n jobSpecUri: string;\n moderationAttested: boolean;\n moderation?: unknown;\n}\n\nexport interface HumanlessHireFlowHostInput<TJobSpec> {\n taskPda: Address;\n taskId: HumanlessHireFlowHireInput[\"taskId\"];\n listing: HumanlessHireFlowHireInput[\"listing\"];\n jobSpec: TJobSpec;\n hireSignature: string;\n referrerInjected: boolean;\n}\n\nexport type HumanlessHireFlowHost<TJobSpec> = (\n input: HumanlessHireFlowHostInput<TJobSpec>,\n) => Promise<HumanlessHireFlowModerationResult>;\n\nexport interface HumanlessHireFlowInput<TJobSpec = unknown> {\n hire: HumanlessHireFlowHireInput;\n jobSpec: TJobSpec;\n hostAndModerateJobSpec: HumanlessHireFlowHost<TJobSpec>;\n activation?: HumanlessHireFlowActivationInput;\n creator?: HumanlessHireFlowCreator;\n}\n\nexport interface HumanlessHireFlowProgress {\n taskPda: Address | null;\n hireSignature: string | null;\n activationSignature: string | null;\n jobSpecHash: HumanlessHireFlowJobSpecHash | null;\n jobSpecUri: string | null;\n referrerInjected: boolean;\n}\n\nexport interface HumanlessHireFlowResult {\n taskPda: Address;\n hireSignature: string;\n activationSignature: string;\n jobSpecHash: HumanlessHireFlowJobSpecHash;\n jobSpecUri: string;\n referrerInjected: boolean;\n moderation?: unknown;\n}\n\nexport interface UseHumanlessHireFlowResult<TJobSpec = unknown> {\n hireAndActivate: (\n input: HumanlessHireFlowInput<TJobSpec>,\n ) => Promise<HumanlessHireFlowResult>;\n phase: HumanlessHireFlowPhase;\n status: HumanlessHireFlowStatus;\n progress: HumanlessHireFlowProgress;\n result: HumanlessHireFlowResult | null;\n error: Error | null;\n isPending: boolean;\n reset: () => void;\n}\n\nfunction emptyProgress(): HumanlessHireFlowProgress {\n return {\n taskPda: null,\n hireSignature: null,\n activationSignature: null,\n jobSpecHash: null,\n jobSpecUri: null,\n referrerInjected: false,\n };\n}\n\nfunction validateModerationResult(\n result: HumanlessHireFlowModerationResult,\n): { jobSpecHash: HumanlessHireFlowJobSpecHash; jobSpecUri: string } {\n if (result.moderationAttested !== true) {\n throw new Error(\n \"Task moderation was not attested; activation was not signed.\",\n );\n }\n if (\n !(result.jobSpecHash instanceof Uint8Array) ||\n result.jobSpecHash.byteLength !== 32\n ) {\n throw new Error(\n \"Task moderation returned an invalid jobSpecHash; activation was not signed.\",\n );\n }\n const jobSpecUri = result.jobSpecUri.trim();\n if (!jobSpecUri) {\n throw new Error(\n \"Task moderation returned an empty jobSpecUri; activation was not signed.\",\n );\n }\n return { jobSpecHash: result.jobSpecHash, jobSpecUri };\n}\n\nexport function useHumanlessHireFlow<TJobSpec = unknown>(): UseHumanlessHireFlowResult<TJobSpec> {\n const ctx = useAgencContext();\n const [phase, setPhase] = useState<HumanlessHireFlowPhase>(\"idle\");\n const [progress, setProgress] =\n useState<HumanlessHireFlowProgress>(emptyProgress);\n const flowInFlight = useRef(false);\n\n const mutation = useMutation<\n HumanlessHireFlowResult,\n Error,\n HumanlessHireFlowInput<TJobSpec>\n >({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const creator = input.creator ?? client.signer;\n const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);\n const hireInput = withoutReferrerArgs(input.hire);\n\n setPhase(\"hiring\");\n setProgress(emptyProgress());\n\n try {\n const hireResult = await client.hireFromListingHumanless({\n ...hireInput,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListingHumanless>[0]);\n\n const [taskPda] = await findTaskPda({\n creator: signerAddress(creator),\n taskId: input.hire.taskId,\n });\n\n setProgress({\n ...emptyProgress(),\n taskPda,\n hireSignature: hireResult.signature,\n referrerInjected,\n });\n\n setPhase(\"moderating\");\n const moderation = await input.hostAndModerateJobSpec({\n taskPda,\n taskId: input.hire.taskId,\n listing: input.hire.listing,\n jobSpec: input.jobSpec,\n hireSignature: hireResult.signature,\n referrerInjected,\n });\n const { jobSpecHash, jobSpecUri } = validateModerationResult(moderation);\n\n setProgress((current) => ({\n ...current,\n jobSpecHash,\n jobSpecUri,\n }));\n\n setPhase(\"activating\");\n const activationResult = await client.setTaskJobSpec({\n ...(input.activation ?? {}),\n task: taskPda,\n creator,\n jobSpecHash,\n jobSpecUri,\n } as Parameters<typeof facadeNs.setTaskJobSpec>[0]);\n\n const result: HumanlessHireFlowResult = {\n taskPda,\n hireSignature: hireResult.signature,\n activationSignature: activationResult.signature,\n jobSpecHash,\n jobSpecUri,\n referrerInjected,\n moderation: moderation.moderation,\n };\n\n setProgress((current) => ({\n ...current,\n activationSignature: activationResult.signature,\n }));\n setPhase(\"activated\");\n return result;\n } catch (error) {\n setPhase(\"error\");\n throw error;\n }\n },\n });\n\n const hireAndActivate = useCallback(\n async (input: HumanlessHireFlowInput<TJobSpec>) => {\n if (flowInFlight.current) {\n throw new Error(\"A humanless hire flow is already in progress.\");\n }\n flowInFlight.current = true;\n try {\n return await mutation.mutateAsync(input);\n } finally {\n flowInFlight.current = false;\n }\n },\n [mutation],\n );\n\n const reset = useCallback(() => {\n mutation.reset();\n setPhase(\"idle\");\n setProgress(emptyProgress());\n }, [mutation]);\n\n return {\n hireAndActivate,\n phase,\n status: mutationStatusOf(mutation),\n progress,\n result: mutation.data ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset,\n };\n}\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport {\n mutationStatusOf,\n requireClient,\n type MutationStatus,\n} from \"./internal.js\";\n\nexport type ClaimTaskInput = Omit<\n Parameters<typeof facadeNs.claimTaskWithJobSpec>[0],\n \"task\"\n>;\nexport type SubmitTaskResultInput = Omit<\n Parameters<typeof facadeNs.submitTaskResult>[0],\n \"task\"\n>;\nexport type TaskWorkStatus = MutationStatus;\n\nexport interface UseTaskWorkResult {\n claim: (input: ClaimTaskInput) => Promise<string>;\n submit: (input: SubmitTaskResultInput) => Promise<string>;\n status: TaskWorkStatus;\n signature: string | null;\n error: Error | null;\n isPending: boolean;\n reset: () => void;\n}\n\nexport function useTaskWork(\n taskPda: Parameters<typeof facadeNs.claimTaskWithJobSpec>[0][\"task\"],\n): UseTaskWorkResult {\n const ctx = useAgencContext();\n const claimMut = useMutation<string, Error, ClaimTaskInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.claimTaskWithJobSpec({\n ...input,\n task: taskPda,\n } as Parameters<typeof facadeNs.claimTaskWithJobSpec>[0]);\n return signature;\n },\n });\n const submitMut = useMutation<string, Error, SubmitTaskResultInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.submitTaskResult({\n ...input,\n task: taskPda,\n } as Parameters<typeof facadeNs.submitTaskResult>[0]);\n return signature;\n },\n });\n\n const claim = useCallback((input: ClaimTaskInput) => claimMut.mutateAsync(input), [claimMut]);\n const submit = useCallback(\n (input: SubmitTaskResultInput) => submitMut.mutateAsync(input),\n [submitMut],\n );\n const active = claimMut.isPending || submitMut.isPending;\n const latest = [claimMut, submitMut].find((m) => m.isError || m.isSuccess) ?? claimMut;\n\n return {\n claim,\n submit,\n status: active ? \"pending\" : mutationStatusOf(latest),\n signature: latest.data ?? null,\n error: claimMut.error ?? submitMut.error ?? null,\n isPending: active,\n reset: () => {\n claimMut.reset();\n submitMut.reset();\n },\n };\n}\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport {\n mutationStatusOf,\n requireClient,\n type MutationStatus,\n} from \"./internal.js\";\n\nexport type CancelTaskInput = Omit<\n Parameters<typeof facadeNs.cancelTask>[0],\n \"task\" | \"authority\"\n> & {\n authority?: Parameters<typeof facadeNs.cancelTask>[0][\"authority\"];\n};\nexport type CloseTaskInput = Omit<\n Parameters<typeof facadeNs.closeTask>[0],\n \"task\" | \"authority\"\n> & {\n authority?: Parameters<typeof facadeNs.closeTask>[0][\"authority\"];\n};\nexport type AutoAcceptTaskResultInput = Omit<\n Parameters<typeof facadeNs.autoAcceptTaskResult>[0],\n \"task\" | \"authority\"\n> & {\n authority?: Parameters<typeof facadeNs.autoAcceptTaskResult>[0][\"authority\"];\n};\nexport type TaskLifecycleStatus = MutationStatus;\n\nexport interface UseTaskLifecycleResult {\n cancel: (input?: CancelTaskInput) => Promise<string>;\n close: (input?: CloseTaskInput) => Promise<string>;\n autoAccept: (input: AutoAcceptTaskResultInput) => Promise<string>;\n status: TaskLifecycleStatus;\n signature: string | null;\n error: Error | null;\n isPending: boolean;\n reset: () => void;\n}\n\nexport function useTaskLifecycle(\n taskPda: Parameters<typeof facadeNs.cancelTask>[0][\"task\"],\n): UseTaskLifecycleResult {\n const ctx = useAgencContext();\n const cancelMut = useMutation<string, Error, CancelTaskInput | undefined>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.cancelTask({\n ...(input ?? {}),\n task: taskPda,\n authority: input?.authority ?? client.signer,\n } as Parameters<typeof facadeNs.cancelTask>[0]);\n return signature;\n },\n });\n const closeMut = useMutation<string, Error, CloseTaskInput | undefined>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.closeTask({\n ...(input ?? {}),\n task: taskPda,\n authority: input?.authority ?? client.signer,\n } as Parameters<typeof facadeNs.closeTask>[0]);\n return signature;\n },\n });\n const autoAcceptMut = useMutation<string, Error, AutoAcceptTaskResultInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.autoAcceptTaskResult({\n ...input,\n task: taskPda,\n authority: input.authority ?? client.signer,\n } as Parameters<typeof facadeNs.autoAcceptTaskResult>[0]);\n return signature;\n },\n });\n\n const cancel = useCallback(\n (input?: CancelTaskInput) => cancelMut.mutateAsync(input),\n [cancelMut],\n );\n const close = useCallback(\n (input?: CloseTaskInput) => closeMut.mutateAsync(input),\n [closeMut],\n );\n const autoAccept = useCallback(\n (input: AutoAcceptTaskResultInput) => autoAcceptMut.mutateAsync(input),\n [autoAcceptMut],\n );\n const active = cancelMut.isPending || closeMut.isPending || autoAcceptMut.isPending;\n const latest =\n [cancelMut, closeMut, autoAcceptMut].find((m) => m.isError || m.isSuccess) ?? cancelMut;\n\n return {\n cancel,\n close,\n autoAccept,\n status: active ? \"pending\" : mutationStatusOf(latest),\n signature: latest.data ?? null,\n error: cancelMut.error ?? closeMut.error ?? autoAcceptMut.error ?? null,\n isPending: active,\n reset: () => {\n cancelMut.reset();\n closeMut.reset();\n autoAcceptMut.reset();\n },\n };\n}\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport {\n mutationStatusOf,\n requireClient,\n type MutationStatus,\n} from \"./internal.js\";\n\nexport type RateHireInput = Omit<\n Parameters<typeof facadeNs.rateHire>[0],\n \"task\" | \"buyer\"\n> & {\n buyer?: Parameters<typeof facadeNs.rateHire>[0][\"buyer\"];\n};\nexport type RateHireStatus = MutationStatus;\n\nexport interface UseRateHireResult {\n rate: (input: RateHireInput) => Promise<string>;\n status: RateHireStatus;\n signature: string | null;\n error: Error | null;\n isPending: boolean;\n reset: () => void;\n}\n\nexport function useRateHire(\n taskPda: Parameters<typeof facadeNs.rateHire>[0][\"task\"],\n): UseRateHireResult {\n const ctx = useAgencContext();\n const mutation = useMutation<string, Error, RateHireInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.rateHire({\n ...input,\n task: taskPda,\n buyer: input.buyer ?? client.signer,\n } as Parameters<typeof facadeNs.rateHire>[0]);\n return signature;\n },\n });\n const rate = useCallback((input: RateHireInput) => mutation.mutateAsync(input), [mutation]);\n return {\n rate,\n status: mutationStatusOf(mutation),\n signature: mutation.data ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","/**\n * `useDispute(taskPda)` — dispute entry point + state for one task.\n *\n * Reads the task's `Dispute` account (via an injected reader seam — same reason\n * as `useTaskStatus`: the unified read transport has no raw account fetch and\n * litesvm has no RPC) and exposes `initiate(...)` which opens a dispute through\n * the write client (`client.initiateDispute`). Typed `AgencError`s surface\n * UNTOUCHED.\n *\n * @module hooks/useDispute\n */\nimport { useMutation, useQuery } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport {\n type Dispute,\n type facade as facadeNs,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys, requireClient } from \"./internal.js\";\n\n/** Reads a Dispute account for a task, returning the decoded value or null. */\nexport type DisputeReader = (\n taskPda: Address | string,\n) => Promise<Dispute | null>;\n\n/**\n * Per-call input for `initiate(...)`. This is the SDK `facade.initiateDispute`\n * input minus the fee-payer `authority` signer (defaulted to the client's\n * signer; pass it to override). `task` is bound at hook construction.\n */\nexport type InitiateDisputeInput = Omit<\n Parameters<typeof facadeNs.initiateDispute>[0],\n \"task\" | \"authority\"\n> & {\n /** Override the initiator authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.initiateDispute>[0][\"authority\"];\n};\n\n/** Lifecycle status of the initiate mutation. */\nexport type DisputeStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link useDispute}. */\nexport interface UseDisputeOptions {\n /** How to read the Dispute account. Without it the read stays idle. */\n disputeReader?: DisputeReader;\n /** Disable the read query. Default `true` when `taskPda` + reader exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useDispute}. */\nexport interface UseDisputeResult {\n /** The decoded dispute, or null (none open / not yet read). */\n dispute: Dispute | null;\n /** Open a dispute. Resolves to the tx signature; rejects with `AgencError`. */\n initiate: (input: InitiateDisputeInput) => Promise<string>;\n /** Status of the initiate mutation. */\n status: DisputeStatus;\n /** Signature of the last successful initiate, or null. */\n signature: string | null;\n /** The read OR initiate error, or null. */\n error: Error | null;\n /** True while reading the dispute. */\n isLoading: boolean;\n /** Force a dispute refetch. */\n refetch: () => void;\n /** Reset the initiate mutation. */\n reset: () => void;\n}\n\n/**\n * Dispute entry + state for one task.\n *\n * @param taskPda - The Task PDA (falsy disables the read).\n * @param options - Reader + enabled.\n * @returns {@link UseDisputeResult}.\n */\nexport function useDispute(\n taskPda: Address | string | undefined | null,\n options?: UseDisputeOptions,\n): UseDisputeResult {\n const ctx = useAgencContext();\n const reader = options?.disputeReader;\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);\n\n const read = useQuery<Dispute | null, Error>({\n queryKey: queryKeys.dispute(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n });\n\n const mutation = useMutation<string, Error, InitiateDisputeInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.initiateDispute({\n ...input,\n task: taskPda as Address,\n authority: input.authority ?? client.signer,\n } as Parameters<typeof facadeNs.initiateDispute>[0]);\n // A new dispute exists — refresh the read.\n void read.refetch();\n return signature;\n },\n });\n\n const initiate = useCallback(\n (input: InitiateDisputeInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: DisputeStatus = mutation.isPending\n ? \"pending\"\n : mutation.isError\n ? \"error\"\n : mutation.isSuccess\n ? \"success\"\n : \"idle\";\n\n return {\n dispute: read.data ?? null,\n initiate,\n status,\n signature: mutation.data ?? null,\n error: mutation.error ?? read.error ?? null,\n isLoading: read.isLoading,\n refetch: () => void read.refetch(),\n reset: mutation.reset,\n };\n}\n","/**\n * `useReferrerEarnings(wallet)` — referrer earnings (indexer-gated).\n *\n * ## EARNINGS INDEXER GATE\n *\n * Referrer settlement is live in the protocol. Aggregated referrer earnings still\n * depend on the off-chain `GET /api/explorer/referrers/:wallet/hires` indexer\n * endpoint that sums paid referral events.\n *\n * That endpoint is not published yet. So this hook:\n * - resolves `resolveReferrerCapability()` from context;\n * - when the earnings indexer is not live: returns the documented not-live\n * state `{ live: false, totalLamports: 0n, hires: [] }` and makes NO network\n * request. It NEVER fabricates earnings and NEVER infers a non-zero total\n * from anything.\n * - the real fetch path is written but gated behind `EARNINGS_INDEXER_LIVE`, so\n * when the endpoint lands, only the gate flips — the surface does not change.\n *\n * @module hooks/useReferrerEarnings\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { t } from \"../strings/index.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\nconst EARNINGS_INDEXER_LIVE = false;\n\n/** A single referral-earning hire (shape defined now; populated once the earnings indexer ships). */\nexport interface ReferrerHire {\n /** The minted Task PDA of the referred hire. */\n taskPda: string;\n /** The HireRecord PDA carrying the snapshotted referrer fields. */\n hireRecordPda: string;\n /** Referral fee earned on this hire, in lamports. */\n feeLamports: bigint;\n /** Transaction signature of the hire. */\n signature: string;\n}\n\n/** Return value of {@link useReferrerEarnings}. */\nexport interface UseReferrerEarningsResult {\n /**\n * Whether aggregated referral earnings are live. Settlement may be live even\n * when this is false; false means the numbers below are the documented\n * not-live zero state, not real data.\n */\n live: boolean;\n /** Total lamports earned. `0n` while not live (never fabricated). */\n totalLamports: bigint;\n /** Per-hire earnings. `[]` while not live. */\n hires: ReferrerHire[];\n /** True while a fetch is in flight. Always false until the earnings indexer ships. */\n isLoading: boolean;\n /** The fetch error, or null. */\n error: Error | null;\n /**\n * Human-readable reason the data is not live (the capability reason). Present\n * while `live` is false.\n */\n reason?: string;\n /** Force a refetch (no-op while not live). */\n refetch: () => void;\n}\n\n/**\n * Read a referrer wallet's earnings.\n *\n * @param wallet - The referrer wallet (base58 / Address). Falsy disables the\n * (future) fetch; the not-live state is still returned.\n * @returns {@link UseReferrerEarningsResult} — the not-live zero state until\n * the earnings indexer ships.\n *\n * @example\n * ```tsx\n * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);\n * // until the earnings indexer ships: live === false, totalLamports === 0n, hires === []\n * ```\n */\nexport function useReferrerEarnings(\n wallet: Address | string | undefined | null,\n): UseReferrerEarningsResult {\n const ctx = useAgencContext();\n const capability = ctx.resolveReferrerCapability();\n\n // THE GATE: settlement can be live while the aggregate earnings indexer is not.\n // Keep this false until the endpoint is published.\n const enabled = capability.live && EARNINGS_INDEXER_LIVE && Boolean(wallet);\n\n const query = useQuery<{ totalLamports: bigint; hires: ReferrerHire[] }, Error>(\n {\n queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : \"\"),\n enabled,\n queryFn: async () => {\n // TODO(indexer): once `GET /api/explorer/referrers/:wallet/hires` is\n // published, fetch + sum here. Returning fabricated numbers here would\n // violate the money-surface contract.\n throw new Error(\n \"useReferrerEarnings: the referrer earnings indexer is not deployed; \" +\n \"this query must never run while EARNINGS_INDEXER_LIVE is false.\",\n );\n },\n },\n );\n\n if (!capability.live || !EARNINGS_INDEXER_LIVE) {\n // The documented not-live state. Zeroes are HONEST (no data exists), not\n // fabricated, and no request was made.\n return {\n live: false,\n totalLamports: 0n,\n hires: [],\n isLoading: false,\n error: null,\n reason: capability.live\n ? t(\"referrer.earningsNotLiveReason\")\n : (capability.reason ?? t(\"referrer.notLiveReason\")),\n refetch: () => {\n /* no-op while not live */\n },\n };\n }\n\n // --- Post-indexer path (currently unreachable; kept wired for the flip) ---\n return {\n live: true,\n totalLamports: query.data?.totalLamports ?? 0n,\n hires: query.data?.hires ?? [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { ReactNode, ButtonHTMLAttributes, HTMLAttributes, RefObject } from 'react';
2
2
  import { ListActiveListingsOptions, DecodedProgramAccount, ServiceListing, IndexerListing, IndexerHire, IndexerAgentTrackRecord, MarketplaceClient, ProgramAccountsTransport, CreateIndexerClientOptions, TaskStatus, fetchMaybeAgentVerification, AgentVerification } from '@tetsuo-ai/marketplace-sdk';
3
3
  import { Address, TransactionSigner, Rpc, GetProgramAccountsApi } from '@solana/kit';
4
- import { e as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-BLf1nrbu.js';
4
+ import { f as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-BCvRHYM2.js';
5
5
 
6
6
  /**
7
7
  * Shared types for `@tetsuo-ai/marketplace-react`.
@@ -88,8 +88,8 @@ interface CreateReadTransportConfig {
88
88
  type AgencNetwork = "localnet" | "devnet" | "mainnet";
89
89
  /**
90
90
  * Referrer configuration. Accepted + validated + stored ALWAYS; injected into
91
- * hires only when {@link ReferrerCapability.live} is true (the P6.2 gate — not
92
- * today). See {@link resolveReferrerCapability}.
91
+ * hires only when {@link ReferrerCapability.live} is true. See
92
+ * {@link resolveReferrerCapability}.
93
93
  */
94
94
  interface ReferrerConfig {
95
95
  /** Referrer wallet that earns the fee. Must be a valid base58 address. */
@@ -114,11 +114,9 @@ interface ValidatedReferrerConfig {
114
114
  * The runtime answer to "can a referral fee actually be charged on this
115
115
  * cluster?". Returned by `resolveReferrerCapability()`.
116
116
  *
117
- * THE P6.2 GATE: `live` is hardcoded `false` today because the on-chain
118
- * referrer args + 4th settlement leg (PLAN.md P6.2) are unbuilt. When it ships,
119
- * this resolver will consult P6.5 `getDeployedSurface` instead. Until then:
120
- * referrer is never injected, earnings hooks return a documented not-live
121
- * state, and disclosure UI may still show the pending-support copy.
117
+ * Referrer settlement is live on the full 84-instruction surface. `live` is true
118
+ * when a validated provider referrer is configured. Aggregated earnings remain a
119
+ * separate indexer-gated read surface.
122
120
  */
123
121
  interface ReferrerCapability {
124
122
  /** Whether referral settlement is live on the target cluster. */
@@ -144,7 +142,7 @@ interface AgencProviderConfig {
144
142
  rpcSubscriptionsUrl?: string;
145
143
  /** Indexer connection — presence of `indexer.baseUrl` selects indexer-first. */
146
144
  indexer?: IndexerConfig;
147
- /** Referrer config (accepted + validated; injected only when P6.2 is live). */
145
+ /** Referrer config (accepted + validated; injected into hire transactions). */
148
146
  referrer?: ReferrerConfig;
149
147
  /** Signer for write operations (the kit `TransactionSigner`). */
150
148
  signer?: TransactionSigner;
@@ -179,8 +177,7 @@ interface AgencContextValue {
179
177
  /** Validated referrer config, or `null` when none was supplied. */
180
178
  referrer: ValidatedReferrerConfig | null;
181
179
  /**
182
- * Resolve whether referral settlement is live on this cluster (the P6.2
183
- * gate). Today always `{ live: false, ... }`.
180
+ * Resolve whether this provider has a live referral-settlement config.
184
181
  */
185
182
  resolveReferrerCapability(): ReferrerCapability;
186
183
  }
@@ -223,8 +220,9 @@ declare const EN_STRINGS: {
223
220
  readonly "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.";
224
221
  readonly "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.";
225
222
  readonly "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.";
226
- readonly "referrer.notLive": "This site earns a referral fee (pending protocol support).";
227
- readonly "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.";
223
+ readonly "referrer.notLive": "Referral fee is not active for this hire.";
224
+ readonly "referrer.notLiveReason": "No referrer is configured for this provider.";
225
+ readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.";
228
226
  readonly "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().";
229
227
  readonly "state.loading": "Loading…";
230
228
  readonly "state.empty": "Nothing to show yet.";
@@ -481,7 +479,7 @@ declare const EN_COMPONENT_STRINGS: {
481
479
  readonly "components.hire.moderationIssues": "Moderation issues found";
482
480
  readonly "components.hire.notConnected": "Connect a wallet to hire.";
483
481
  readonly "components.referrer.disclosure": "This site earns a referral fee.";
484
- readonly "components.referrer.disclosurePending": "This site earns a referral fee (pending protocol support).";
482
+ readonly "components.referrer.disclosurePending": "Referral fee is not active for this hire.";
485
483
  readonly "components.referrer.feeBps": "{bps} bps";
486
484
  readonly "components.taskTimeline.title": "Task progress";
487
485
  readonly "components.taskTimeline.empty": "No task to track yet.";
@@ -774,8 +772,8 @@ declare function ListingGrid({ listings, isLoading, error, hasMore, onLoadMore,
774
772
  * `<HireCheckoutModal>` — the embeddable money path (PLAN_2 A3).
775
773
  *
776
774
  * The accessible, themable checkout dialog: it shows the price, the moderation
777
- * attestation badge, the escrow-funding explanation, the referrer disclosure
778
- * (P6.2-gated), and walks the buyer through idle → confirming → funded /
775
+ * attestation badge, the escrow-funding explanation, the referrer disclosure,
776
+ * and walks the buyer through idle → confirming → funded /
779
777
  * error confirmation states.
780
778
  *
781
779
  * ## Accessibility (STRUCTURAL — this is published to third parties)
@@ -785,12 +783,11 @@ declare function ListingGrid({ listings, isLoading, error, hasMore, onLoadMore,
785
783
  * transaction), ARIA dialog roles, and live-region status announcements for
786
784
  * the confirming/funded/error transitions.
787
785
  *
788
- * ## The P6.2 referrer gate
786
+ * ## Referrer disclosure
789
787
  *
790
- * The disclosure renders when a `referrer` is configured, with the pending-
791
- * support copy until `referrerLive` is true (always false today). The modal
792
- * NEVER computes or claims a fee was charged — it discloses configured intent
793
- * only. Injection/earnings stay in the hooks, blocked on P6.2.
788
+ * The disclosure renders when a `referrer` is configured. The modal never
789
+ * computes earnings; injection lives in `useHire()` and aggregate earnings live
790
+ * in `useReferrerEarnings()`.
794
791
  *
795
792
  * ## Wiring
796
793
  *
@@ -837,8 +834,8 @@ interface HireCheckoutModalProps {
837
834
  */
838
835
  referrer?: ValidatedReferrerConfig | null;
839
836
  /**
840
- * Whether referral settlement is live (P6.2). Always false today. Drives the
841
- * disclosure copy only; never implies a fee was charged.
837
+ * Whether referral settlement is active for this hire. Drives the disclosure
838
+ * copy only; never computes earnings.
842
839
  */
843
840
  referrerLive?: boolean;
844
841
  /** Whether a signer/wallet is connected (gates the confirm button). */
@@ -859,8 +856,7 @@ declare function HireCheckoutModal({ open, onClose, listing, onConfirm, status,
859
856
  * This is the one component that binds the hooks directly: it renders a price-
860
857
  * aware CTA that opens {@link HireCheckoutModal}, drives the hire through
861
858
  * `useHire()`, resolves the signer via `useWalletSigner()`, and threads the
862
- * provider's configured referrer + the P6.2 capability into the modal's
863
- * disclosure (never injecting a fee — the gate lives in `useHire`).
859
+ * provider's configured referrer + capability into the modal's disclosure.
864
860
  *
865
861
  * ## Why the caller supplies the hire input
866
862
  *
@@ -917,14 +913,11 @@ declare function HireButton({ listing, buildHireInput, onHired, onViewTask, show
917
913
  /**
918
914
  * `<ReferrerDisclosure>` — the "this site earns a referral fee" notice.
919
915
  *
920
- * ## THE P6.2 GATE (PLAN_2 §0 / the §0 referrer gate — read before editing)
916
+ * ## Referral disclosure
921
917
  *
922
- * Disclosure is the ONE referrer surface allowed to render while the on-chain
923
- * referrer leg is not live. It NEVER asserts that a fee was charged: when
924
- * `live` is false it shows the "(pending protocol support)" copy. It is purely
925
- * informational and reads no earnings. The actual injection / earnings remain
926
- * blocked on P6.2 (handled by the hooks, not here). This component only
927
- * DISCLOSES the configured intent.
918
+ * Disclosure is informational and reads no earnings. When `live` is true it can
919
+ * use the present-tense fee copy. When `live` is false it shows neutral copy and
920
+ * does not imply a fee was charged.
928
921
  *
929
922
  * Render it only when a referrer is configured on the provider.
930
923
  *
@@ -936,17 +929,16 @@ interface ReferrerDisclosureProps extends ThemableProps {
936
929
  /** The validated referrer config (from the provider context). */
937
930
  referrer: ValidatedReferrerConfig;
938
931
  /**
939
- * Whether the referral fee is actually live on-chain (the P6.2 capability).
940
- * ALWAYS false today — when false the copy shows the pending-support note and
941
- * no fee is implied as charged. Defaults to false.
932
+ * Whether the referral fee is active for this hire. When false, no fee is
933
+ * implied as charged. Defaults to false.
942
934
  */
943
935
  live?: boolean;
944
936
  /** Show the configured fee in bps alongside the disclosure. Default true. */
945
937
  showFee?: boolean;
946
938
  }
947
939
  /**
948
- * Disclose that the embedding site earns a referral fee. Honors the P6.2 gate:
949
- * shows the pending-support copy until referral settlement is live.
940
+ * Disclose that the embedding site earns a referral fee when referral settlement
941
+ * is active for the hire.
950
942
  */
951
943
  declare function ReferrerDisclosure({ referrer, live, showFee, unstyled, className, }: ReferrerDisclosureProps): ReactNode;
952
944