@tetsuo-ai/marketplace-react 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/{chunk-FAIRTAIB.js → chunk-2Y6JN2VZ.js} +3 -3
- package/dist/{chunk-FAIRTAIB.js.map → chunk-2Y6JN2VZ.js.map} +1 -1
- package/dist/{chunk-D2TDU3TJ.js → chunk-AKPPKMQ2.js} +3 -3
- package/dist/{chunk-D2TDU3TJ.js.map → chunk-AKPPKMQ2.js.map} +1 -1
- package/dist/{chunk-ECU7HGO3.js → chunk-H6PJIDQR.js} +4 -3
- package/dist/chunk-H6PJIDQR.js.map +1 -0
- package/dist/{chunk-MNJ2EQDJ.js → chunk-ON6XR4XO.js} +3 -3
- package/dist/{chunk-MNJ2EQDJ.js.map → chunk-ON6XR4XO.js.map} +1 -1
- package/dist/{chunk-WJUVTFJ7.js → chunk-ZAMIL27X.js} +4 -4
- package/dist/{chunk-WJUVTFJ7.js.map → chunk-ZAMIL27X.js.map} +1 -1
- package/dist/components/index.cjs +2 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +3 -3
- package/dist/hooks/index.cjs +86 -9
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +6 -8
- package/dist/hooks/index.d.ts +6 -8
- package/dist/hooks/index.js +89 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-C9R3B80j.d.ts → index-DQ3Xovkq.d.ts} +15 -1
- package/dist/{index-CTTh1ZPg.d.cts → index-UxuvIlmD.d.cts} +15 -1
- package/dist/index.cjs +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/signers/index.cjs +2 -1
- package/dist/signers/index.cjs.map +1 -1
- package/dist/signers/index.js +2 -2
- package/package.json +1 -1
- package/src/hooks/moderation-attestor.ts +98 -0
- package/src/hooks/useHumanlessHireFlow.ts +12 -0
- package/src/hooks/useReferrerEarnings.ts +73 -38
- package/src/hooks/useTaskActivation.ts +13 -0
- package/src/provider/AgencProvider.tsx +12 -0
- package/src/strings/index.ts +3 -1
- package/src/types.ts +13 -0
- package/dist/chunk-ECU7HGO3.js.map +0 -1
package/dist/hooks/index.js.map
CHANGED
|
@@ -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/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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;AAAA,MACE,UAAU,SAAA,CAAU,gBAAA,CAAiB,SAAS,MAAA,CAAO,MAAM,IAAI,EAAE,CAAA;AAAA,MACjE,OAAA;AAAA,MACA,SAAS,YAAY;AAInB,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SAEF;AAAA,MACF;AAAA;AACF;AAGF,EAAA,IAAI,CAAC,UAAA,CAAW,IAAA,IAAQ,CAAC,qBAAA,EAAuB;AAG9C,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,KAAA;AAAA,MACN,aAAA,EAAe,EAAA;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
|
+
{"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/moderation-attestor.ts","../../src/hooks/useTaskActivation.ts","../../src/hooks/useHumanlessHireFlow.ts","../../src/hooks/useTaskWork.ts","../../src/hooks/useTaskLifecycle.ts","../../src/hooks/useRateHire.ts","../../src/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AAA,MACL,IAAA,EAAM,KAAA;AAAA,MACN,aAAA,EAAe,EAAA;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;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,IAAA;AAAA,IACN,aAAA,EAAe,KAAA,CAAM,IAAA,EAAM,aAAA,IAAiB,EAAA;AAAA,IAC5C,KAAA,EAAO,KAAA,CAAM,IAAA,EAAM,KAAA,IAAS,EAAC;AAAA,IAC7B,WAAW,KAAA,CAAM,SAAA;AAAA,IACjB,KAAA,EAAO,MAAM,KAAA,IAAS,IAAA;AAAA,IACtB,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 * Resolve the OPTIONAL `moderation_attestor` roster account for task\n * activation (WP-A1).\n *\n * Post-A1 the on-chain publish gate (`set_task_job_spec`) accepts a task\n * moderation authored by a registered roster `ModerationAttestor` — but ONLY\n * when the transaction attaches that attestor's roster-entry PDA. Without it\n * the gate falls back to requiring `task_moderation.moderator ==\n * moderation_config.moderation_authority`, so a roster-attested task (the\n * default when the activation backend uses the public attestation service)\n * fails with `UNAUTHORIZED_TASK_MODERATOR` even though the attestation is\n * valid.\n *\n * This helper reads the recorded `TaskModeration`, compares its stored\n * moderator against the global moderation authority, and returns the roster\n * PDA exactly when they differ. Any resolution failure returns `undefined`,\n * degrading to the pre-resolution behavior — the program stays the\n * enforcement point; a read hiccup must never make activation MORE broken\n * than not resolving at all.\n *\n * @module hooks/moderation-attestor\n */\nimport { createSolanaRpc } from \"@solana/kit\";\nimport {\n fetchMaybeModerationConfig,\n fetchMaybeTaskModeration,\n findModerationAttestorPda,\n findModerationConfigPda,\n findTaskModerationPda,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport type { Address } from \"../types.js\";\n\n/** The account-read slice of a kit RPC that the resolver needs. */\ntype AccountReadRpc = Parameters<typeof fetchMaybeTaskModeration>[0];\n\n/** The job-spec hash exactly as the TaskModeration PDA seeds accept it. */\ntype JobSpecHashSeed = Parameters<typeof findTaskModerationPda>[0][\"jobSpecHash\"];\n\n/**\n * Resolve the roster-attestor account to attach to `set_task_job_spec`, or\n * `undefined` when none is needed (global-authority moderation, missing\n * moderation record, or no read endpoint).\n *\n * @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).\n * @param input.task - The task PDA being activated.\n * @param input.jobSpecHash - The 32-byte canonical job-spec hash (seeds the\n * `TaskModeration` PDA together with `task`).\n * @param input.rpc - Test seam: a pre-built account-read RPC wins over\n * `rpcUrl`.\n */\nexport async function resolveActivationModerationAttestor(input: {\n rpcUrl: string | null;\n task: Address;\n jobSpecHash: JobSpecHashSeed;\n rpc?: AccountReadRpc;\n}): Promise<Address | undefined> {\n try {\n const rpc =\n input.rpc ??\n (input.rpcUrl\n ? (createSolanaRpc(input.rpcUrl) as unknown as AccountReadRpc)\n : null);\n if (!rpc) return undefined;\n\n const [taskModerationPda] = await findTaskModerationPda({\n task: input.task,\n jobSpecHash: input.jobSpecHash,\n });\n const taskModeration = await fetchMaybeTaskModeration(\n rpc,\n taskModerationPda,\n );\n if (!taskModeration.exists) return undefined;\n\n const [moderationConfigPda] = await findModerationConfigPda();\n const moderationConfig = await fetchMaybeModerationConfig(\n rpc,\n moderationConfigPda,\n );\n if (\n moderationConfig.exists &&\n taskModeration.data.moderator ===\n moderationConfig.data.moderationAuthority\n ) {\n // Global-authority moderation: the gate needs no roster account.\n return undefined;\n }\n\n const [rosterPda] = await findModerationAttestorPda({\n attestor: taskModeration.data.moderator,\n });\n return rosterPda;\n } catch {\n // Degrade to \"no account attached\" — never block activation on a read\n // failure; the on-chain gate remains the enforcement point.\n return undefined;\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\";\nimport { resolveActivationModerationAttestor } from \"./moderation-attestor.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 // WP-A1: when the task moderation was authored by a roster attestor\n // (not the global authority), the publish gate only unlocks if the\n // attestor's roster-entry PDA is attached. Resolve it automatically\n // unless the caller supplied one.\n const moderationAttestor =\n input.moderationAttestor ??\n (await resolveActivationModerationAttestor({\n rpcUrl: ctx.rpcUrl,\n task: taskPda,\n jobSpecHash: input.jobSpecHash,\n }));\n const { signature } = await client.setTaskJobSpec({\n ...input,\n ...(moderationAttestor !== undefined ? { moderationAttestor } : {}),\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 { resolveActivationModerationAttestor } from \"./moderation-attestor.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 // WP-A1: attach the roster-attestor account when the moderation was\n // authored by a roster attestor (e.g. the public attestation\n // service) — without it the publish gate rejects the activation.\n const moderationAttestor =\n input.activation?.moderationAttestor ??\n (await resolveActivationModerationAttestor({\n rpcUrl: ctx.rpcUrl,\n task: taskPda,\n jobSpecHash,\n }));\n const activationResult = await client.setTaskJobSpec({\n ...(input.activation ?? {}),\n ...(moderationAttestor !== undefined ? { moderationAttestor } : {}),\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)` — aggregated referrer earnings (P3.8).\n *\n * ## Data source\n *\n * `GET <earningsBase>/api/explorer/referrers/:wallet/hires` — the hosted\n * explorer endpoint that sums the referrer leg over SETTLED hires with the\n * program's own split math (shipped 2026-07-03; ground-truthed against the\n * cross-node canary's on-chain legs). `earningsBase` resolves from\n * `config.indexer.baseUrl` when set, else the per-network hosted default\n * (mainnet only). When no base resolves (localnet/devnet without an indexer),\n * the hook returns the documented not-live zero state and makes NO network\n * request — it NEVER fabricates earnings; a fetch failure surfaces as\n * `error` with zero totals, never invented numbers.\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, AgencContextValue, AgencNetwork } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/**\n * Hosted explorer bases serving the earnings endpoints, per network. Only\n * mainnet has one today; an explicit `config.indexer.baseUrl` always wins.\n */\nconst EARNINGS_INDEXER_DEFAULTS: Partial<Record<AgencNetwork, string>> = {\n mainnet: \"https://api.agenc.ag\",\n};\n\n/** Resolve the earnings endpoint base, or `null` (not live) when none. */\nfunction resolveEarningsBaseUrl(ctx: AgencContextValue): string | null {\n return ctx.indexerBaseUrl ?? EARNINGS_INDEXER_DEFAULTS[ctx.network] ?? null;\n}\n\n/** A single referral-earning hire. */\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 (empty until event indexing lands). */\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. */\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/** The endpoint's wire shape (lamports as decimal strings). */\ninterface EarningsWire {\n totalLamports?: string;\n hires?: Array<{\n taskPda?: string;\n hireRecordPda?: string;\n feeLamports?: string;\n signature?: string;\n }>;\n}\n\n/**\n * Read a referrer wallet's aggregated earnings from the hosted explorer.\n *\n * @param wallet - The referrer wallet (base58 / Address). Falsy disables the\n * fetch; the not-live state is still returned.\n * @returns {@link UseReferrerEarningsResult}\n *\n * @example\n * ```tsx\n * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);\n * ```\n */\nexport function useReferrerEarnings(\n wallet: Address | string | undefined | null,\n): UseReferrerEarningsResult {\n const ctx = useAgencContext();\n const capability = ctx.resolveReferrerCapability();\n const earningsBase = resolveEarningsBaseUrl(ctx);\n\n // Live only when settlement capability holds AND an earnings endpoint base\n // resolves. No base (localnet/devnet without an indexer) = the documented\n // not-live zero state, zero network requests.\n const enabled = capability.live && earningsBase !== null && 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 const url = `${earningsBase}/api/explorer/referrers/${encodeURIComponent(\n String(wallet),\n )}/hires`;\n const response = await fetch(url, {\n headers: { accept: \"application/json\" },\n });\n if (!response.ok) {\n throw new Error(\n t(\"referrer.earningsFetchFailed\") + ` (HTTP ${response.status})`,\n );\n }\n const body = (await response.json()) as EarningsWire;\n // Lamports arrive as decimal strings; parse to bigint. Anything\n // malformed throws (surfaces as `error`) — never silently coerced.\n const hires: ReferrerHire[] = (body.hires ?? []).map((h) => ({\n taskPda: String(h.taskPda ?? \"\"),\n hireRecordPda: String(h.hireRecordPda ?? \"\"),\n feeLamports: BigInt(h.feeLamports ?? \"0\"),\n signature: String(h.signature ?? \"\"),\n }));\n return {\n totalLamports: BigInt(body.totalLamports ?? \"0\"),\n hires,\n };\n },\n },\n );\n\n if (!enabled) {\n // The documented not-live state. Zeroes are HONEST (no data was read),\n // not 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 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"]}
|
|
@@ -172,6 +172,19 @@ interface AgencContextValue {
|
|
|
172
172
|
* was supplied. Mutating hooks surface a clear error in that case.
|
|
173
173
|
*/
|
|
174
174
|
client: MarketplaceClient | null;
|
|
175
|
+
/**
|
|
176
|
+
* The resolved HTTP RPC endpoint (config override or the network default),
|
|
177
|
+
* or `null` when none resolves. Hooks use it for single-account reads —
|
|
178
|
+
* e.g. resolving the WP-A1 `moderation_attestor` roster account during
|
|
179
|
+
* activation. NOT a gPA/list-query source; the read transport owns those.
|
|
180
|
+
*/
|
|
181
|
+
rpcUrl: string | null;
|
|
182
|
+
/**
|
|
183
|
+
* The configured hosted-indexer base URL (`config.indexer.baseUrl`), or
|
|
184
|
+
* `null` when reads run over gPA/queryTransport. Earnings hooks prefer it
|
|
185
|
+
* over the per-network hosted default.
|
|
186
|
+
*/
|
|
187
|
+
indexerBaseUrl: string | null;
|
|
175
188
|
/** The configured signer, or `null`. */
|
|
176
189
|
signer: TransactionSigner | null;
|
|
177
190
|
/** Validated referrer config, or `null` when none was supplied. */
|
|
@@ -222,7 +235,8 @@ declare const EN_STRINGS: {
|
|
|
222
235
|
readonly "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.";
|
|
223
236
|
readonly "referrer.notLive": "Referral fee is not active for this hire.";
|
|
224
237
|
readonly "referrer.notLiveReason": "No referrer is configured for this provider.";
|
|
225
|
-
readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but
|
|
238
|
+
readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).";
|
|
239
|
+
readonly "referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.";
|
|
226
240
|
readonly "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().";
|
|
227
241
|
readonly "state.loading": "Loading…";
|
|
228
242
|
readonly "state.empty": "Nothing to show yet.";
|
|
@@ -172,6 +172,19 @@ interface AgencContextValue {
|
|
|
172
172
|
* was supplied. Mutating hooks surface a clear error in that case.
|
|
173
173
|
*/
|
|
174
174
|
client: MarketplaceClient | null;
|
|
175
|
+
/**
|
|
176
|
+
* The resolved HTTP RPC endpoint (config override or the network default),
|
|
177
|
+
* or `null` when none resolves. Hooks use it for single-account reads —
|
|
178
|
+
* e.g. resolving the WP-A1 `moderation_attestor` roster account during
|
|
179
|
+
* activation. NOT a gPA/list-query source; the read transport owns those.
|
|
180
|
+
*/
|
|
181
|
+
rpcUrl: string | null;
|
|
182
|
+
/**
|
|
183
|
+
* The configured hosted-indexer base URL (`config.indexer.baseUrl`), or
|
|
184
|
+
* `null` when reads run over gPA/queryTransport. Earnings hooks prefer it
|
|
185
|
+
* over the per-network hosted default.
|
|
186
|
+
*/
|
|
187
|
+
indexerBaseUrl: string | null;
|
|
175
188
|
/** The configured signer, or `null`. */
|
|
176
189
|
signer: TransactionSigner | null;
|
|
177
190
|
/** Validated referrer config, or `null` when none was supplied. */
|
|
@@ -222,7 +235,8 @@ declare const EN_STRINGS: {
|
|
|
222
235
|
readonly "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.";
|
|
223
236
|
readonly "referrer.notLive": "Referral fee is not active for this hire.";
|
|
224
237
|
readonly "referrer.notLiveReason": "No referrer is configured for this provider.";
|
|
225
|
-
readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but
|
|
238
|
+
readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).";
|
|
239
|
+
readonly "referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.";
|
|
226
240
|
readonly "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().";
|
|
227
241
|
readonly "state.loading": "Loading…";
|
|
228
242
|
readonly "state.empty": "Nothing to show yet.";
|
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,8 @@ var EN_STRINGS = {
|
|
|
19
19
|
"referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
|
|
20
20
|
"referrer.notLive": "Referral fee is not active for this hire.",
|
|
21
21
|
"referrer.notLiveReason": "No referrer is configured for this provider.",
|
|
22
|
-
"referrer.earningsNotLiveReason": "Referral settlement is live, but
|
|
22
|
+
"referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
|
|
23
|
+
"referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
|
|
23
24
|
// Read transport.
|
|
24
25
|
"transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
|
|
25
26
|
// Generic loading / empty / error states (components extend these).
|
|
@@ -241,10 +242,17 @@ function AgencProvider(props) {
|
|
|
241
242
|
const referrer = config.referrer ? validateReferrerConfig(config.referrer) : null;
|
|
242
243
|
const read = buildReadTransport(config);
|
|
243
244
|
const client = buildWriteClient(config, network);
|
|
245
|
+
const { rpcUrl } = resolveEndpoints(
|
|
246
|
+
network,
|
|
247
|
+
config.rpcUrl,
|
|
248
|
+
config.rpcSubscriptionsUrl
|
|
249
|
+
);
|
|
244
250
|
return {
|
|
245
251
|
network,
|
|
246
252
|
read,
|
|
247
253
|
client,
|
|
254
|
+
rpcUrl: rpcUrl ?? null,
|
|
255
|
+
indexerBaseUrl: config.indexer?.baseUrl ?? null,
|
|
248
256
|
signer: config.signer ?? null,
|
|
249
257
|
referrer,
|
|
250
258
|
resolveReferrerCapability: () => resolveReferrerCapability(referrer)
|