@tetsuo-ai/marketplace-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +172 -0
  4. package/dist/chunk-5OTKSRHM.js +128 -0
  5. package/dist/chunk-5OTKSRHM.js.map +1 -0
  6. package/dist/chunk-ABS77JB2.js +94 -0
  7. package/dist/chunk-ABS77JB2.js.map +1 -0
  8. package/dist/chunk-GN5DYVN5.js +35 -0
  9. package/dist/chunk-GN5DYVN5.js.map +1 -0
  10. package/dist/chunk-KJMR6OGC.js +1198 -0
  11. package/dist/chunk-KJMR6OGC.js.map +1 -0
  12. package/dist/chunk-YORZNYZZ.js +107 -0
  13. package/dist/chunk-YORZNYZZ.js.map +1 -0
  14. package/dist/components/agenc-components.css +570 -0
  15. package/dist/components/index.cjs +1335 -0
  16. package/dist/components/index.cjs.map +1 -0
  17. package/dist/components/index.d.cts +5 -0
  18. package/dist/components/index.d.ts +5 -0
  19. package/dist/components/index.js +5 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/hooks/index.cjs +493 -0
  22. package/dist/hooks/index.cjs.map +1 -0
  23. package/dist/hooks/index.d.cts +294 -0
  24. package/dist/hooks/index.d.ts +294 -0
  25. package/dist/hooks/index.js +339 -0
  26. package/dist/hooks/index.js.map +1 -0
  27. package/dist/index-BLrlBVj-.d.cts +1129 -0
  28. package/dist/index-CKTYsNPH.d.ts +1129 -0
  29. package/dist/index.cjs +1690 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.d.cts +235 -0
  32. package/dist/index.d.ts +235 -0
  33. package/dist/index.js +127 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/signers/index.cjs +166 -0
  36. package/dist/signers/index.cjs.map +1 -0
  37. package/dist/signers/index.d.cts +136 -0
  38. package/dist/signers/index.d.ts +136 -0
  39. package/dist/signers/index.js +4 -0
  40. package/dist/signers/index.js.map +1 -0
  41. package/dist/testing/index.cjs +62 -0
  42. package/dist/testing/index.cjs.map +1 -0
  43. package/dist/testing/index.d.cts +71 -0
  44. package/dist/testing/index.d.ts +71 -0
  45. package/dist/testing/index.js +60 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/dist/theme/agenc-tailwind-preset.cjs +184 -0
  48. package/dist/theme/agenc-tokens.css +132 -0
  49. package/dist/types-jvISR6bc.d.cts +135 -0
  50. package/dist/types-jvISR6bc.d.ts +135 -0
  51. package/dist/useAgentTrackRecord-BLf1nrbu.d.cts +249 -0
  52. package/dist/useAgentTrackRecord-BLf1nrbu.d.ts +249 -0
  53. package/package.json +139 -0
  54. package/src/components/DisputeBanner.stories.tsx +39 -0
  55. package/src/components/DisputeBanner.tsx +110 -0
  56. package/src/components/HireButton.stories.tsx +72 -0
  57. package/src/components/HireButton.tsx +151 -0
  58. package/src/components/HireCheckoutModal.stories.tsx +107 -0
  59. package/src/components/HireCheckoutModal.tsx +284 -0
  60. package/src/components/ListingCard.stories.tsx +55 -0
  61. package/src/components/ListingCard.tsx +148 -0
  62. package/src/components/ListingGrid.stories.tsx +44 -0
  63. package/src/components/ListingGrid.tsx +137 -0
  64. package/src/components/Modal.tsx +121 -0
  65. package/src/components/PoweredByAgenC.tsx +85 -0
  66. package/src/components/ProviderCard.stories.tsx +61 -0
  67. package/src/components/ProviderCard.tsx +154 -0
  68. package/src/components/ReferrerDisclosure.tsx +67 -0
  69. package/src/components/ReviewPanel.stories.tsx +65 -0
  70. package/src/components/ReviewPanel.tsx +141 -0
  71. package/src/components/TaskTimeline.stories.tsx +43 -0
  72. package/src/components/TaskTimeline.tsx +156 -0
  73. package/src/components/__fixtures__/index.tsx +173 -0
  74. package/src/components/agenc-components.css +570 -0
  75. package/src/components/badges.tsx +115 -0
  76. package/src/components/format.ts +150 -0
  77. package/src/components/index.ts +102 -0
  78. package/src/components/primitives.tsx +236 -0
  79. package/src/components/strings.ts +131 -0
  80. package/src/components/useFocusTrap.ts +122 -0
  81. package/src/hooks/index.ts +90 -0
  82. package/src/hooks/internal.ts +70 -0
  83. package/src/hooks/useAgentTrackRecord.ts +166 -0
  84. package/src/hooks/useDispute.ts +130 -0
  85. package/src/hooks/useHire.ts +198 -0
  86. package/src/hooks/useListing.ts +138 -0
  87. package/src/hooks/useListings.ts +133 -0
  88. package/src/hooks/useReferrerEarnings.ts +134 -0
  89. package/src/hooks/useSubmissionReview.ts +179 -0
  90. package/src/hooks/useTaskStatus.ts +192 -0
  91. package/src/hooks/useWalletSigner.ts +99 -0
  92. package/src/index.ts +170 -0
  93. package/src/provider/AgencProvider.tsx +169 -0
  94. package/src/provider/context.ts +35 -0
  95. package/src/provider/index.ts +17 -0
  96. package/src/provider/network.ts +68 -0
  97. package/src/provider/referrer.ts +97 -0
  98. package/src/signers/README.md +130 -0
  99. package/src/signers/embedded-wallet-mock.ts +158 -0
  100. package/src/signers/embedded-wallet.ts +64 -0
  101. package/src/signers/index.ts +48 -0
  102. package/src/signers/strings.ts +39 -0
  103. package/src/signers/types.ts +158 -0
  104. package/src/signers/wallet-account.ts +128 -0
  105. package/src/signers/wallet-adapter.ts +149 -0
  106. package/src/strings/index.ts +119 -0
  107. package/src/testing/index.ts +24 -0
  108. package/src/theme/agenc-tailwind-preset.cjs +184 -0
  109. package/src/theme/agenc-tokens.css +132 -0
  110. package/src/theme/index.ts +94 -0
  111. package/src/transport/index.ts +164 -0
  112. package/src/types.ts +224 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/strings/index.ts","../../src/provider/context.ts","../../src/hooks/internal.ts","../../src/hooks/useListings.ts","../../src/transport/index.ts","../../src/hooks/useListing.ts","../../src/hooks/useAgentTrackRecord.ts","../../src/hooks/useTaskStatus.ts","../../src/hooks/useHire.ts","../../src/hooks/useSubmissionReview.ts","../../src/hooks/useDispute.ts","../../src/hooks/useWalletSigner.ts","../../src/hooks/useReferrerEarnings.ts"],"names":["createContext","useContext","useQuery","useState","useMem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,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.cjs","sourcesContent":["/**\n * Minimal English string catalog + a `t(id, vars?)` resolver.\n *\n * Every user-facing string in this package and its downstream hooks/components\n * routes through this module so a future `{ locale }` can resolve translations\n * **without an API break** (PLAN_2 Part A design constraint). v1 ships English\n * only; the resolver signature is already locale-shaped.\n *\n * ## Why a catalog and not inline literals\n *\n * Components published to third parties cannot assume the host's language. By\n * keying every literal here:\n * - adding a locale is a data change (a new {@link StringCatalog}), not a code\n * change to every component;\n * - the message ids are a stable contract the components agent binds to;\n * - `{var}` interpolation is centralized and SSR-safe (pure string ops, no\n * `Intl` global assumptions at module scope).\n *\n * @module strings\n */\n\n/**\n * The catalog shape: every message id maps to an English template. `{name}`\n * placeholders are filled by {@link t} from the `vars` argument.\n */\nexport interface StringCatalog {\n readonly [id: string]: string;\n}\n\n/**\n * Default English catalog. Keep ids namespaced by surface\n * (`provider.*`, `referrer.*`, `transport.*`, `hire.*`, ...) so the components\n * agent can extend it without collisions.\n */\nexport const EN_STRINGS = {\n // Provider / context wiring errors (developer-facing, but routed for parity).\n \"provider.missingContext\":\n \"useAgencContext must be used within <AgencProvider>.\",\n \"provider.missingWriteClient\":\n \"No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.\",\n \"provider.missingSigner\":\n \"No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.\",\n\n // Referrer config validation (the P6.2 gate surface).\n \"referrer.invalidWallet\":\n \"Referrer wallet is not a valid base58 Solana address: {wallet}.\",\n \"referrer.invalidFeeBps\":\n \"Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.\",\n \"referrer.notLive\":\n \"This site earns a referral fee (pending protocol support).\",\n \"referrer.notLiveReason\":\n \"Referral settlement is not yet deployed on this cluster (PLAN.md P6.2). Referrer config is accepted and validated but not injected into hires.\",\n\n // Read transport.\n \"transport.noReadSource\":\n \"No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().\",\n\n // Generic loading / empty / error states (components extend these).\n \"state.loading\": \"Loading…\",\n \"state.empty\": \"Nothing to show yet.\",\n \"state.error\": \"Something went wrong.\",\n\n // Hire flow shells (components fill out the rest).\n \"hire.cta\": \"Hire\",\n \"hire.pending\": \"Confirming…\",\n \"hire.funded\": \"Escrow funded.\",\n} as const satisfies StringCatalog;\n\n/** A message id present in the default English catalog. */\nexport type StringId = keyof typeof EN_STRINGS;\n\n/** Interpolation variables for {@link t}: `{name}` → `vars.name`. */\nexport type StringVars = Record<string, string | number | bigint>;\n\n/**\n * Options for {@link t}. `locale` is accepted today (English-only) so adding\n * real locales later does not break the call signature; `catalog` lets a host\n * inject an override/extension catalog.\n */\nexport interface TranslateOptions {\n /** BCP-47 locale tag. v1 resolves everything to English regardless. */\n locale?: string;\n /** Override catalog (e.g. a future locale, or host-supplied copy). */\n catalog?: StringCatalog;\n}\n\n/**\n * Resolve a message id to its localized string with `{var}` interpolation.\n *\n * Unknown ids and unmatched placeholders are returned verbatim (the id itself,\n * or the `{placeholder}` left intact) rather than throwing — a missing string\n * must never crash a money-handling UI.\n *\n * @param id - The message id (a {@link StringId}, or any string for host\n * catalogs).\n * @param vars - Values for `{name}` placeholders in the template.\n * @param options - Optional `locale` (forward-compatible) and `catalog`\n * override.\n * @returns The interpolated string.\n *\n * @example\n * ```ts\n * t(\"referrer.invalidFeeBps\", { min: 0, max: 10000, feeBps: 99999 });\n * // -> \"Referrer feeBps must be an integer between 0 and 10000 ...; got 99999.\"\n * ```\n */\nexport function t(\n id: StringId | (string & {}),\n vars?: StringVars,\n options?: TranslateOptions,\n): string {\n const catalog: StringCatalog = options?.catalog ?? EN_STRINGS;\n const template = catalog[id] ?? id;\n if (vars === undefined) return template;\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => {\n const value = vars[key];\n return value === undefined ? match : String(value);\n });\n}\n","/**\n * The React context object + the internal `useAgencContext()` hook.\n *\n * Split from the component file so the context identity is stable and so hooks\n * can import the context without pulling the JSX provider into their module\n * graph. SSR-safe: this module only calls `createContext` at import time, never\n * touches `window`.\n *\n * @module provider/context\n */\nimport { createContext, useContext } from \"react\";\nimport { t } from \"../strings/index.js\";\nimport type { AgencContextValue } from \"../types.js\";\n\n/**\n * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer\n * — {@link useAgencContext} turns that into a clear developer error.\n */\nexport const AgencContext = createContext<AgencContextValue | null>(null);\nAgencContext.displayName = \"AgencContext\";\n\n/**\n * Read the AgenC context. INTERNAL hook the package's own hooks build on; also\n * exported from the package root so downstream hooks (components agent) can\n * reach the resolved transport/client/referrer.\n *\n * @throws Error when called outside a `<AgencProvider>`.\n */\nexport function useAgencContext(): AgencContextValue {\n const ctx = useContext(AgencContext);\n if (ctx === null) {\n throw new Error(t(\"provider.missingContext\"));\n }\n return ctx;\n}\n","/**\n * Internal helpers shared by the headless hooks.\n *\n * - A namespaced TanStack Query key factory so every hook's cache entries are\n * stable, collision-free, and individually invalidatable.\n * - Tiny guards that turn a missing write client / signer into a clear,\n * catalog-routed error (never a `null.method()` crash) BEFORE a mutation runs.\n *\n * SSR-safe: pure functions, no `window`/`document`, no module-scope side\n * effects.\n *\n * @module hooks/internal\n */\nimport { t } from \"../strings/index.js\";\nimport type { Address, MarketplaceClient } from \"../types.js\";\n\n/** Root namespace for every cache key this package writes. */\nexport const QUERY_KEY_ROOT = \"agenc\" as const;\n\n/**\n * Stable, hierarchical TanStack Query keys. Hooks build their keys ONLY through\n * this factory so a consumer (or a hook) can invalidate a whole sub-tree\n * (`[\"agenc\", \"listings\"]`) or one entity (`[\"agenc\", \"listing\", pda]`).\n *\n * `JSON.stringify` is intentionally NOT used — TanStack compares keys\n * structurally, so passing the raw filter object keeps equality correct for\n * `bigint`/`Address` values without a serialization step.\n */\nexport const queryKeys = {\n /** All listings list queries (with their filter object as the leaf). */\n listings: (filter?: unknown) =>\n [QUERY_KEY_ROOT, \"listings\", filter ?? null] as const,\n /** One listing + its joined provider/track-record/moderation. */\n listing: (pda: string) => [QUERY_KEY_ROOT, \"listing\", pda] as const,\n /** One agent's indexer track record. */\n agentTrackRecord: (agentPda: string) =>\n [QUERY_KEY_ROOT, \"agentTrackRecord\", agentPda] as const,\n /** One task's status (read via transport / svm decode). */\n taskStatus: (taskPda: string) =>\n [QUERY_KEY_ROOT, \"taskStatus\", taskPda] as const,\n /** One task's dispute record. */\n dispute: (taskPda: string) => [QUERY_KEY_ROOT, \"dispute\", taskPda] as const,\n /** One referrer wallet's earnings (P6.2-gated; see useReferrerEarnings). */\n referrerEarnings: (wallet: string) =>\n [QUERY_KEY_ROOT, \"referrerEarnings\", wallet] as const,\n} as const;\n\n/**\n * Assert a write client exists, returning it narrowed to non-null. Throws a\n * clear, catalog-routed error when the provider was configured read-only (no\n * `client` and no resolvable `rpcUrl` + `signer`).\n *\n * Mutating hooks call this at the top of their `mutationFn` so the failure is a\n * descriptive Error in the mutation's `error` channel — never a crash.\n *\n * @throws Error (`provider.missingWriteClient`) when `client` is null.\n */\nexport function requireClient(\n client: MarketplaceClient | null,\n): MarketplaceClient {\n if (client === null) {\n throw new Error(t(\"provider.missingWriteClient\"));\n }\n return client;\n}\n\n/** Coerce an `Address | string` to its string form for use as a cache key. */\nexport function pdaKey(pda: Address | string): string {\n return String(pda);\n}\n","/**\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 * The read-transport abstraction — indexer-first with RPC/gPA fallback.\n *\n * `createReadTransport({ indexer?, rpc?, queryTransport? })` returns one\n * {@link ReadTransport}. When an indexer `baseUrl` is set it routes through the\n * SDK's `createIndexerClient` (the scale path); otherwise it falls back to the\n * SDK's gPA `listActiveListings` / account fetch (the trustless path). The two\n * backends return parity shapes BY SDK DESIGN, so callers never branch on which\n * one is live.\n *\n * `queryTransport` is a full override slot — pass a mock/pre-built transport\n * (tests, SSR fixtures) and it is used verbatim.\n *\n * SSR-safe: no `window`/`document` and no Node built-ins at module scope; the\n * SDK's indexer client is browser-safe (fetch + kit codecs only).\n *\n * @module transport\n */\nimport { address, isAddress } from \"@solana/kit\";\nimport {\n createIndexerClient,\n getServiceListingDecoder,\n listActiveListings as gpaListActiveListings,\n type IndexerClient,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n CreateReadTransportConfig,\n GpaReadSource,\n IndexerConfig,\n ReadListingResult,\n ReadTransport,\n} from \"../types.js\";\nimport type { CreateIndexerClientOptions } from \"@tetsuo-ai/marketplace-sdk\";\n\n/**\n * Thrown when a gPA-fallback transport is asked for an indexer-only capability\n * (aggregated hires / track record have no trustless gPA equivalent).\n */\nexport class ReadTransportUnsupportedError extends Error {\n /** The unsupported operation name. */\n readonly operation: string;\n constructor(operation: string) {\n super(\n `Read operation \"${operation}\" requires the indexer backend; the gPA ` +\n `fallback has no trustless equivalent. Configure an indexer baseUrl on ` +\n `<AgencProvider> to use it.`,\n );\n this.name = \"ReadTransportUnsupportedError\";\n this.operation = operation;\n }\n}\n\n/** Coerce a string|Address PDA into a kit Address (validates base58). */\nfunction toAddress(pda: Address | string): Address {\n if (typeof pda !== \"string\") return pda;\n if (!isAddress(pda)) {\n throw new TypeError(`Not a valid base58 Solana address: ${pda}`);\n }\n return address(pda);\n}\n\n/** Build the indexer-backed read transport. */\nfunction indexerReadTransport(\n config: IndexerConfig,\n indexerClientOptions?: Partial<CreateIndexerClientOptions>,\n): ReadTransport {\n const client: IndexerClient = createIndexerClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n ...(indexerClientOptions ?? {}),\n });\n return {\n kind: \"indexer\",\n listActiveListings: (options) => client.listActiveListings(options),\n async getListing(pda): Promise<ReadListingResult> {\n const listing = await client.getListing(pda);\n const account = getServiceListingDecoder().decode(\n base64ToBytes(listing.accountData),\n );\n return {\n address: toAddress(listing.pda),\n account,\n indexer: listing,\n };\n },\n listingHires: (pda) => client.listingHires(pda),\n agentTrackRecord: (pda) => client.agentTrackRecord(pda),\n };\n}\n\n/** Build the gPA-fallback read transport over a kit RPC / ProgramAccountsTransport. */\nfunction gpaReadTransport(rpc: GpaReadSource): ReadTransport {\n return {\n kind: \"gpa\",\n listActiveListings: (options) => gpaListActiveListings(rpc, options),\n async getListing(pda): Promise<ReadListingResult> {\n // No single-account decode helper crosses the transport seam here, so we\n // scope the active-listings query down to the one PDA. (The indexer path\n // is the efficient one; this fallback is the trustless escape hatch.)\n const target = toAddress(pda);\n const all = await gpaListActiveListings(rpc, {});\n const hit = all.find((entry) => entry.address === target);\n if (hit === undefined) {\n throw new Error(\n `Listing ${pda} not found among active listings via the gPA ` +\n `fallback (it may be inactive, or your RPC restricts ` +\n `getProgramAccounts — use an indexer baseUrl for single-listing ` +\n `lookups).`,\n );\n }\n return { address: hit.address, account: hit.account };\n },\n listingHires() {\n return Promise.reject(new ReadTransportUnsupportedError(\"listingHires\"));\n },\n agentTrackRecord() {\n return Promise.reject(\n new ReadTransportUnsupportedError(\"agentTrackRecord\"),\n );\n },\n };\n}\n\n/** Browser-safe base64 → bytes (atob in browsers, Buffer in Node). */\nfunction base64ToBytes(b64: string): Uint8Array {\n if (typeof atob === \"function\") {\n const binary = atob(b64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n // Node fallback — Buffer is always present there.\n return Uint8Array.from(Buffer.from(b64, \"base64\"));\n}\n\n/**\n * Create the unified read transport.\n *\n * Resolution order:\n * 1. `queryTransport` override (wins — tests/mocks/SSR fixtures);\n * 2. `indexer.baseUrl` present → indexer-first transport;\n * 3. `rpc` present → gPA fallback transport;\n * 4. nothing configured → throws a descriptive error.\n *\n * @param config - See {@link CreateReadTransportConfig}.\n * @returns A {@link ReadTransport}.\n * @throws Error when no read source is configured.\n */\nexport function createReadTransport(\n config: CreateReadTransportConfig,\n): ReadTransport {\n if (config.queryTransport) return config.queryTransport;\n if (config.indexer?.baseUrl) {\n return indexerReadTransport(config.indexer, config.indexerClientOptions);\n }\n if (config.rpc) return gpaReadTransport(config.rpc);\n throw new Error(t(\"transport.noReadSource\"));\n}\n\nexport type { ReadTransport } from \"../types.js\";\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 * `useHire()` — the hire mutation hook (the embeddable money path).\n *\n * Drives `client.hireFromListing(...)` through the provider's write client and\n * surfaces the resulting transaction signature + minted Task PDA. Typed\n * `AgencError`s from the runtime client are surfaced UNTOUCHED in `error`.\n *\n * ## THE P6.2 REFERRER GATE (PLAN_2 §0, MANDATORY — read before editing)\n *\n * The on-chain referrer args + 4th settlement leg (PLAN.md P6.2) are UNBUILT.\n * The SDK `facade.hireFromListing` has NO referrer parameter. So this hook:\n * - reads `resolveReferrerCapability()` from context BEFORE building the hire;\n * - when `live === false` (ALWAYS, today): it injects NO referrer argument into\n * the hire input. The referrer config is still accepted/validated/stored on\n * the provider and disclosure UI may show the pending-support copy — but the\n * transaction the user signs is a plain hire with no referral leg.\n * - the `referrerInjected` flag in the result is the audit signal: it is `false`\n * today and would only become `true` once P6.2 is live AND a referrer is\n * configured. We NEVER fabricate it.\n *\n * When P6.2 ships, the ONLY change here is: under `capability.live === true`,\n * spread the referrer fields (`referrer`, `referrerFeeBps`) into the hire input\n * below. Nothing else moves.\n *\n * @module hooks/useHire\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useMemo } from \"react\";\nimport { facade, 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 { requireClient } from \"./internal.js\";\n\n/**\n * Input to a standard `hire(...)` — a buyer that has a registered marketplace\n * agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the\n * worker calls `complete_task`). This is the SDK `facade.hireFromListing` input\n * MINUS the fee-payer signers, which default to the provider's write-client\n * signer (authority == creator == buyer). Pass them only to override.\n *\n * NOTE: deliberately NO referrer field — the referrer is provider-level config,\n * gated by P6.2, and is never threaded through a per-call hire input.\n */\nexport type HireInput = Omit<\n Parameters<typeof facadeNs.hireFromListing>[0],\n \"authority\" | \"creator\"\n> & {\n /** Standard hire (default). */\n humanless?: false;\n /** Override the buyer authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.hireFromListing>[0][\"authority\"];\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListing>[0][\"creator\"];\n};\n\n/**\n * Input to a HUMANLESS `hire(...)` — a plain-wallet buyer with NO registered\n * agent (the storefront-visitor path). The task is pinned to CreatorReview, so\n * it settles via the BUYER REVIEW path (`useSubmissionReview` accept/reject) —\n * the human reviews before funds release. This is the SDK\n * `facade.hireFromListingHumanless` input minus the `creator` signer (defaulted\n * to the client signer).\n */\nexport type HumanlessHireInput = Omit<\n Parameters<typeof facadeNs.hireFromListingHumanless>[0],\n \"creator\"\n> & {\n /** Discriminates the humanless storefront-visitor hire. */\n humanless: true;\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListingHumanless>[0][\"creator\"];\n};\n\n/** The union of standard and humanless hire inputs. */\nexport type AnyHireInput = HireInput | HumanlessHireInput;\n\n/** Lifecycle status of the hire mutation. */\nexport type HireStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Result of a settled hire. */\nexport interface HireResult {\n /** The confirmed transaction signature. */\n signature: string;\n /** The minted Task PDA (derived from creator + taskId). */\n taskPda: Address;\n /**\n * Whether a referrer fee leg was injected into THIS hire. Always `false`\n * today (the P6.2 gate). Audit signal — never fabricated.\n */\n referrerInjected: boolean;\n}\n\n/** Return value of {@link useHire}. */\nexport interface UseHireResult {\n /** Execute a hire. Resolves to {@link HireResult}; rejects with `AgencError`. */\n hire: (input: AnyHireInput) => Promise<HireResult>;\n /** Current mutation status. */\n status: HireStatus;\n /** The minted Task PDA from the last successful hire, or null. */\n taskPda: Address | null;\n /** The signature from the last successful hire, or null. */\n signature: string | null;\n /** The error from the last hire (typed `AgencError` untouched), or null. */\n error: Error | null;\n /** Whether a hire is currently in flight. */\n isPending: boolean;\n /** Reset the mutation back to idle. */\n reset: () => void;\n}\n\n/**\n * The hire hook.\n *\n * @returns {@link UseHireResult}.\n *\n * @example\n * ```tsx\n * const { hire, status, taskPda, error } = useHire();\n * await hire({\n * listing, creatorAgent, taskId, expectedPrice: price, expectedVersion: 1n,\n * listingSpecHash,\n * });\n * ```\n */\nexport function useHire(): UseHireResult {\n const ctx = useAgencContext();\n\n const mutation = useMutation<HireResult, Error, AnyHireInput>({\n mutationFn: async (input: AnyHireInput): Promise<HireResult> => {\n const client = requireClient(ctx.client);\n\n // --- THE P6.2 GATE ---\n // Capability is resolved fresh per hire. Today it is ALWAYS not-live, so\n // we build a referrer-free hire. When P6.2 lands, the `capability.live`\n // branch is where the referrer fields get spread in (for BOTH paths).\n const capability = ctx.resolveReferrerCapability();\n const referrerInjected = capability.live && ctx.referrer !== null;\n\n const creator = input.creator ?? client.signer;\n let signature: string;\n\n if (input.humanless === true) {\n // Storefront-visitor hire: no creator agent; CreatorReview-pinned, so\n // it settles via the buyer review path (useSubmissionReview).\n const ix = await facade.hireFromListingHumanless({\n ...input,\n creator,\n // NOTE: P6.2 referrer fields would spread here under capability.live.\n } as Parameters<typeof facadeNs.hireFromListingHumanless>[0]);\n ({ signature } = await client.send([ix]));\n } else {\n // Standard hire: authority == creator == buyer (the buyer has an agent).\n const authority = input.authority ?? client.signer;\n const result = await client.hireFromListing({\n ...input,\n authority,\n creator,\n // NOTE: P6.2 referrer fields would spread here under capability.live.\n } as Parameters<typeof facadeNs.hireFromListing>[0]);\n signature = result.signature;\n }\n\n // Derive the minted Task PDA from (creator, taskId).\n const [taskPda] = await findTaskPda({\n creator:\n typeof creator === \"object\" && creator !== null && \"address\" in creator\n ? creator.address\n : (creator as Address),\n taskId: input.taskId,\n });\n\n return { signature, taskPda, referrerInjected };\n },\n });\n\n const hire = useCallback(\n (input: AnyHireInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: HireStatus = useMemo(() => {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n }, [mutation.isPending, mutation.isError, mutation.isSuccess]);\n\n return {\n hire,\n status,\n taskPda: mutation.data?.taskPda ?? null,\n signature: mutation.data?.signature ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","/**\n * `useSubmissionReview(taskPda)` — buyer-side settlement actions.\n *\n * Exposes the three creator review verbs for a task in `PendingValidation`:\n * - `accept(...)` — accept the result and settle the escrow to the worker\n * (`client.acceptTaskResult`, a named client convenience);\n * - `reject(...)` — reject the result with a rejection hash\n * (`facade.rejectTaskResult` -> `client.send`);\n * - `requestChanges(...)` — return the task to the worker with a changes hash\n * (`facade.requestChanges` -> `client.send`).\n *\n * Each verb is its own mutation so a UI can show independent\n * pending/error/success per button. Typed `AgencError`s surface UNTOUCHED.\n *\n * The `task` PDA is bound at hook construction; callers pass only the per-call\n * settlement parties (worker / treasury / hashes) the SDK cannot derive.\n *\n * @module hooks/useSubmissionReview\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { facade, type facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { requireClient } from \"./internal.js\";\n\n/** Per-call input for `accept` (task auto-bound; signer defaults to the client). */\nexport type AcceptInput = Omit<\n Parameters<typeof facadeNs.acceptTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.acceptTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `reject`. */\nexport type RejectInput = Omit<\n Parameters<typeof facadeNs.rejectTaskResult>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.rejectTaskResult>[0][\"creator\"];\n};\n\n/** Per-call input for `requestChanges`. */\nexport type RequestChangesInput = Omit<\n Parameters<typeof facadeNs.requestChanges>[0],\n \"task\" | \"creator\"\n> & {\n creator?: Parameters<typeof facadeNs.requestChanges>[0][\"creator\"];\n};\n\n/** Lifecycle status of a review verb. */\nexport type ReviewStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** A single review verb's surface. */\nexport interface ReviewAction<TInput> {\n /** Run the action. Resolves to the tx signature; rejects with `AgencError`. */\n (input: TInput): Promise<string>;\n}\n\n/** Return value of {@link useSubmissionReview}. */\nexport interface UseSubmissionReviewResult {\n /** Accept the result and settle to the worker. */\n accept: ReviewAction<AcceptInput>;\n /** Reject the result (with a rejection hash). */\n reject: ReviewAction<RejectInput>;\n /** Request changes (with a changes hash), returning the task to the worker. */\n requestChanges: ReviewAction<RequestChangesInput>;\n /** Aggregate status: `pending` if any verb is in flight, else last settled. */\n status: ReviewStatus;\n /** The most recent error across the three verbs, or null. */\n error: Error | null;\n /** Signature of the last successful action, or null. */\n signature: string | null;\n /** Reset all three mutations to idle. */\n reset: () => void;\n}\n\nfunction statusOf(m: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): ReviewStatus {\n if (m.isPending) return \"pending\";\n if (m.isError) return \"error\";\n if (m.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/**\n * Buyer-side review actions for one task.\n *\n * @param taskPda - The Task PDA under review (bound to every verb).\n * @returns {@link UseSubmissionReviewResult}.\n */\nexport function useSubmissionReview(\n taskPda: Parameters<typeof facadeNs.acceptTaskResult>[0][\"task\"],\n): UseSubmissionReviewResult {\n const ctx = useAgencContext();\n\n const acceptMut = useMutation<string, Error, AcceptInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.acceptTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.acceptTaskResult>[0]);\n return signature;\n },\n });\n\n const rejectMut = useMutation<string, Error, RejectInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.rejectTaskResult({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.rejectTaskResult>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const requestChangesMut = useMutation<string, Error, RequestChangesInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const ix = await facade.requestChanges({\n ...input,\n task: taskPda,\n creator: input.creator ?? client.signer,\n } as Parameters<typeof facadeNs.requestChanges>[0]);\n const { signature } = await client.send([ix]);\n return signature;\n },\n });\n\n const accept = useCallback<ReviewAction<AcceptInput>>(\n (input) => acceptMut.mutateAsync(input),\n [acceptMut],\n );\n const reject = useCallback<ReviewAction<RejectInput>>(\n (input) => rejectMut.mutateAsync(input),\n [rejectMut],\n );\n const requestChanges = useCallback<ReviewAction<RequestChangesInput>>(\n (input) => requestChangesMut.mutateAsync(input),\n [requestChangesMut],\n );\n\n const anyPending =\n acceptMut.isPending || rejectMut.isPending || requestChangesMut.isPending;\n const status: ReviewStatus = anyPending\n ? \"pending\"\n : statusOf(\n // Surface the most recently-touched verb's terminal state.\n [acceptMut, rejectMut, requestChangesMut].find(\n (m) => m.isError || m.isSuccess,\n ) ?? acceptMut,\n );\n\n const error =\n acceptMut.error ?? rejectMut.error ?? requestChangesMut.error ?? null;\n const signature =\n acceptMut.data ?? rejectMut.data ?? requestChangesMut.data ?? null;\n\n return {\n accept,\n reject,\n requestChanges,\n status,\n error,\n signature,\n reset: () => {\n acceptMut.reset();\n rejectMut.reset();\n requestChangesMut.reset();\n },\n };\n}\n","/**\n * `useDispute(taskPda)` — dispute entry point + state for one task.\n *\n * Reads the task's `Dispute` account (via an injected reader seam — same reason\n * as `useTaskStatus`: the unified read transport has no raw account fetch and\n * litesvm has no RPC) and exposes `initiate(...)` which opens a dispute through\n * the write client (`client.initiateDispute`). Typed `AgencError`s surface\n * UNTOUCHED.\n *\n * @module hooks/useDispute\n */\nimport { useMutation, useQuery } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport {\n type Dispute,\n type facade as facadeNs,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys, requireClient } from \"./internal.js\";\n\n/** Reads a Dispute account for a task, returning the decoded value or null. */\nexport type DisputeReader = (\n taskPda: Address | string,\n) => Promise<Dispute | null>;\n\n/**\n * Per-call input for `initiate(...)`. This is the SDK `facade.initiateDispute`\n * input minus the fee-payer `authority` signer (defaulted to the client's\n * signer; pass it to override). `task` is bound at hook construction.\n */\nexport type InitiateDisputeInput = Omit<\n Parameters<typeof facadeNs.initiateDispute>[0],\n \"task\" | \"authority\"\n> & {\n /** Override the initiator authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.initiateDispute>[0][\"authority\"];\n};\n\n/** Lifecycle status of the initiate mutation. */\nexport type DisputeStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link useDispute}. */\nexport interface UseDisputeOptions {\n /** How to read the Dispute account. Without it the read stays idle. */\n disputeReader?: DisputeReader;\n /** Disable the read query. Default `true` when `taskPda` + reader exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useDispute}. */\nexport interface UseDisputeResult {\n /** The decoded dispute, or null (none open / not yet read). */\n dispute: Dispute | null;\n /** Open a dispute. Resolves to the tx signature; rejects with `AgencError`. */\n initiate: (input: InitiateDisputeInput) => Promise<string>;\n /** Status of the initiate mutation. */\n status: DisputeStatus;\n /** Signature of the last successful initiate, or null. */\n signature: string | null;\n /** The read OR initiate error, or null. */\n error: Error | null;\n /** True while reading the dispute. */\n isLoading: boolean;\n /** Force a dispute refetch. */\n refetch: () => void;\n /** Reset the initiate mutation. */\n reset: () => void;\n}\n\n/**\n * Dispute entry + state for one task.\n *\n * @param taskPda - The Task PDA (falsy disables the read).\n * @param options - Reader + enabled.\n * @returns {@link UseDisputeResult}.\n */\nexport function useDispute(\n taskPda: Address | string | undefined | null,\n options?: UseDisputeOptions,\n): UseDisputeResult {\n const ctx = useAgencContext();\n const reader = options?.disputeReader;\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);\n\n const read = useQuery<Dispute | null, Error>({\n queryKey: queryKeys.dispute(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n });\n\n const mutation = useMutation<string, Error, InitiateDisputeInput>({\n mutationFn: async (input) => {\n const client = requireClient(ctx.client);\n const { signature } = await client.initiateDispute({\n ...input,\n task: taskPda as Address,\n authority: input.authority ?? client.signer,\n } as Parameters<typeof facadeNs.initiateDispute>[0]);\n // A new dispute exists — refresh the read.\n void read.refetch();\n return signature;\n },\n });\n\n const initiate = useCallback(\n (input: InitiateDisputeInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: DisputeStatus = mutation.isPending\n ? \"pending\"\n : mutation.isError\n ? \"error\"\n : mutation.isSuccess\n ? \"success\"\n : \"idle\";\n\n return {\n dispute: read.data ?? null,\n initiate,\n status,\n signature: mutation.data ?? null,\n error: mutation.error ?? read.error ?? null,\n isLoading: read.isLoading,\n refetch: () => void read.refetch(),\n reset: mutation.reset,\n };\n}\n","/**\n * `useWalletSigner()` — bridges a browser wallet into the kit `TransactionSigner`\n * the SDK write client expects.\n *\n * ## Adapter seam (the signer-adapters package is not built yet)\n *\n * The dedicated `@tetsuo-ai/signer-adapters` package (the signers agent, PLAN.md\n * P4.1) — which wraps `@solana/react`'s\n * `useWalletAccountTransactionSendingSigner` (Wallet Standard) and the legacy\n * `@solana/wallet-adapter` shim into a kit `TransactionSigner` — does not exist\n * at this hook's build time. So this hook is defined against a **documented\n * adapter interface** ({@link WalletSignerAdapter}) rather than importing that\n * package. A caller passes an adapter (today: a thin wrapper they write, or the\n * signer-adapters hook once it ships) and this hook normalizes it to the\n * `{ signer, connected, connect() }` contract every other hook expects.\n *\n * With NO adapter passed, the hook falls back to the provider's configured\n * `signer` (the `AgencProvider config.signer` slot), so a server-supplied or\n * test signer just works and `connect()` is a no-op.\n *\n * SSR-safe: no `window`/`document`; the adapter (which may touch wallet globals)\n * is the caller's responsibility to gate to the client. This hook only reads\n * what the adapter already resolved.\n *\n * @module hooks/useWalletSigner\n */\nimport { useCallback } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { TransactionSigner } from \"../types.js\";\n\n/**\n * The minimal adapter shape this hook bridges. The forthcoming\n * `@tetsuo-ai/signer-adapters` hook is expected to return exactly this shape\n * (its `signerFromWalletAccount(...)` resolves the `signer`); until it ships,\n * any object matching this interface works.\n */\nexport interface WalletSignerAdapter {\n /** The resolved kit signer, or null when no wallet is connected. */\n signer: TransactionSigner | null;\n /** Whether a wallet is currently connected. */\n connected?: boolean;\n /** Trigger the wallet connect flow (browser-only). Optional. */\n connect?: () => void | Promise<void>;\n}\n\n/** Options for {@link useWalletSigner}. */\nexport interface UseWalletSignerOptions {\n /**\n * A wallet adapter (e.g. the signer-adapters hook's result). When omitted the\n * hook falls back to the provider's `config.signer`.\n */\n adapter?: WalletSignerAdapter;\n}\n\n/** Return value of {@link useWalletSigner}. */\nexport interface UseWalletSignerResult {\n /** The resolved kit `TransactionSigner`, or null. */\n signer: TransactionSigner | null;\n /** Whether a signer is available (adapter-connected or provider-configured). */\n connected: boolean;\n /** Trigger the wallet connect flow. No-op when no adapter `connect` exists. */\n connect: () => void | Promise<void>;\n}\n\n/**\n * Resolve the active signer for write operations.\n *\n * @param options - Optional wallet adapter; falls back to the provider signer.\n * @returns {@link UseWalletSignerResult}.\n *\n * @example\n * ```tsx\n * // Once @tetsuo-ai/signer-adapters ships:\n * const adapter = useWalletStandardSigner(); // returns WalletSignerAdapter\n * const { signer, connected, connect } = useWalletSigner({ adapter });\n * ```\n */\nexport function useWalletSigner(\n options?: UseWalletSignerOptions,\n): UseWalletSignerResult {\n const ctx = useAgencContext();\n const adapter = options?.adapter;\n\n // Adapter wins when present; otherwise the provider's configured signer.\n const signer: TransactionSigner | null =\n adapter?.signer ?? ctx.signer ?? null;\n const connected =\n adapter !== undefined\n ? (adapter.connected ?? adapter.signer !== null)\n : ctx.signer !== null;\n\n const connect = useCallback(() => {\n // No adapter (or no connect on it) => provider-supplied signer is already\n // \"connected\"; connecting is a no-op rather than an error.\n return adapter?.connect ? adapter.connect() : undefined;\n }, [adapter]);\n\n return { signer, connected, connect };\n}\n","/**\n * `useReferrerEarnings(wallet)` — referrer earnings (STRICTLY P6.2-GATED).\n *\n * ## THE P6.2 GATE (PLAN_2 §0, MANDATORY — this hook is the canonical example)\n *\n * Referrer earnings depend on TWO unbuilt things:\n * 1. the on-chain P6.2 referrer fields snapshotted on `HireRecord` (the 4th\n * settlement leg), and\n * 2. the off-chain `GET /api/explorer/referrers/:wallet/hires` indexer endpoint\n * that aggregates them.\n *\n * NEITHER exists today. So this hook:\n * - resolves `resolveReferrerCapability()` from context;\n * - when `live === false` (ALWAYS, today): returns the documented not-live\n * state `{ live: false, totalLamports: 0n, hires: [] }` and makes NO network\n * request. It NEVER fabricates earnings and NEVER infers a non-zero total\n * from anything.\n * - the real fetch path is written but DEAD-CODE-GATED behind `capability.live`\n * with a clear TODO, so when P6.2 + the endpoint land, only the gate flips —\n * the surface does not change.\n *\n * @module hooks/useReferrerEarnings\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport { t } from \"../strings/index.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** A single referral-earning hire (shape defined now; populated post-P6.2). */\nexport interface ReferrerHire {\n /** The minted Task PDA of the referred hire. */\n taskPda: string;\n /** The HireRecord PDA carrying the snapshotted referrer fields. */\n hireRecordPda: string;\n /** Referral fee earned on this hire, in lamports. */\n feeLamports: bigint;\n /** Transaction signature of the hire. */\n signature: string;\n}\n\n/** Return value of {@link useReferrerEarnings}. */\nexport interface UseReferrerEarningsResult {\n /**\n * Whether referral settlement is live on this cluster. ALWAYS `false` today\n * (the P6.2 gate). When false, the numbers below are the documented not-live\n * zero state, not real data.\n */\n live: boolean;\n /** Total lamports earned. `0n` while not live (never fabricated). */\n totalLamports: bigint;\n /** Per-hire earnings. `[]` while not live. */\n hires: ReferrerHire[];\n /** True while a (post-P6.2) fetch is in flight. Always false today. */\n isLoading: boolean;\n /** The fetch error, or null. */\n error: Error | null;\n /**\n * Human-readable reason the data is not live (the capability reason). Present\n * while `live` is false.\n */\n reason?: string;\n /** Force a refetch (no-op while not live). */\n refetch: () => void;\n}\n\n/**\n * Read a referrer wallet's earnings.\n *\n * @param wallet - The referrer wallet (base58 / Address). Falsy disables the\n * (future) fetch; the not-live state is still returned.\n * @returns {@link UseReferrerEarningsResult} — the not-live zero state today.\n *\n * @example\n * ```tsx\n * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);\n * // today: live === false, totalLamports === 0n, hires === []\n * ```\n */\nexport function useReferrerEarnings(\n wallet: Address | string | undefined | null,\n): UseReferrerEarningsResult {\n const ctx = useAgencContext();\n const capability = ctx.resolveReferrerCapability();\n\n // THE GATE: the query is enabled ONLY when referral settlement is live. Today\n // `capability.live` is hardcoded false, so this query never runs and we\n // return the not-live zero state below. NEVER remove this gate.\n const enabled = capability.live && Boolean(wallet);\n\n const query = useQuery<{ totalLamports: bigint; hires: ReferrerHire[] }, Error>(\n {\n queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : \"\"),\n enabled,\n queryFn: async () => {\n // TODO(P6.2 / indexer): once the referrer fields exist on HireRecord\n // AND the indexer exposes `GET /api/explorer/referrers/:wallet/hires`,\n // fetch + sum here. Unreachable today because `enabled` is gated on\n // `capability.live` (hardcoded false). Returning fabricated numbers\n // here would violate PLAN_2 §0 — do not.\n throw new Error(\n \"useReferrerEarnings: the P6.2 referrer earnings path is not \" +\n \"deployed; this query must never run while capability.live is false.\",\n );\n },\n },\n );\n\n if (!capability.live) {\n // The documented not-live state. Zeroes are HONEST (no data exists), not\n // fabricated, and no request was made.\n return {\n live: false,\n totalLamports: 0n,\n hires: [],\n isLoading: false,\n error: null,\n reason: capability.reason ?? t(\"referrer.notLiveReason\"),\n refetch: () => {\n /* no-op while not live */\n },\n };\n }\n\n // --- Post-P6.2 path (currently unreachable; kept wired for the flip) ---\n return {\n live: true,\n totalLamports: query.data?.totalLamports ?? 0n,\n hires: query.data?.hires ?? [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n"]}
@@ -0,0 +1,294 @@
1
+ import { DecodedProgramAccount, ServiceListing, ListActiveListingsOptions, IndexerAgentTrackRecord, IndexerListing, Task, TaskStatus } from '@tetsuo-ai/marketplace-sdk';
2
+ import { Address, TransactionSigner } from '@solana/kit';
3
+ export { A as AcceptInput, a as AgentTrackRecord, b as AnyHireInput, D as DisputeReader, c as DisputeStatus, H as HireInput, d as HireResult, e as HireStatus, f as HumanlessHireInput, I as InitiateDisputeInput, R as RejectInput, g as RequestChangesInput, h as ReviewAction, i as ReviewStatus, T as TrackRecordOutcome, U as UseAgentTrackRecordOptions, j as UseAgentTrackRecordResult, k as UseDisputeOptions, l as UseDisputeResult, m as UseHireResult, n as UseSubmissionReviewResult, p as projectTrackRecord, u as useAgentTrackRecord, o as useDispute, q as useHire, r as useSubmissionReview } from '../useAgentTrackRecord-BLf1nrbu.cjs';
4
+
5
+ /** A decoded active listing row (address + decoded account). */
6
+ type ListingRow = DecodedProgramAccount<ServiceListing>;
7
+ /** Filter for {@link useListings}. Mirrors the SDK's `ListActiveListingsOptions`. */
8
+ type UseListingsFilter = ListActiveListingsOptions;
9
+ /** Options for {@link useListings}. */
10
+ interface UseListingsOptions {
11
+ /** Rows revealed per page / per `fetchMore()` call. Default `12`. */
12
+ pageSize?: number;
13
+ /**
14
+ * Disable the query (e.g. until a filter is ready). When `false` the hook
15
+ * returns the idle state and makes no request. Default `true`.
16
+ */
17
+ enabled?: boolean;
18
+ }
19
+ /** Return value of {@link useListings}. */
20
+ interface UseListingsResult {
21
+ /** The currently-revealed window of listings (grows via `fetchMore`). */
22
+ listings: ListingRow[];
23
+ /** Total active listings the transport returned (the full fetched set). */
24
+ total: number;
25
+ /** True while the underlying fetch is in flight (first load / refetch). */
26
+ isLoading: boolean;
27
+ /** The fetch error (typed `AgencError` for on-chain failures), or null. */
28
+ error: Error | null;
29
+ /** Whether more rows remain in the fetched set to reveal. */
30
+ hasMore: boolean;
31
+ /** Reveal the next `pageSize` rows from the fetched set. No-op when exhausted. */
32
+ fetchMore: () => void;
33
+ /** Force a fresh fetch from the transport. */
34
+ refetch: () => void;
35
+ }
36
+ /**
37
+ * Read active service listings for a grid.
38
+ *
39
+ * @param filter - Optional provider/category/state filter (SDK semantics).
40
+ * @param options - Page size + enabled flag.
41
+ * @returns {@link UseListingsResult}.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * const { listings, isLoading, fetchMore, hasMore } = useListings({
46
+ * category: "code-generation",
47
+ * });
48
+ * ```
49
+ */
50
+ declare function useListings(filter?: UseListingsFilter, options?: UseListingsOptions): UseListingsResult;
51
+
52
+ /** The joined detail payload {@link useListing} resolves. */
53
+ interface ListingDetail {
54
+ /** The listing PDA. */
55
+ address: Address;
56
+ /** The decoded on-chain `ServiceListing`. */
57
+ listing: ServiceListing;
58
+ /** The provider's agent PDA (`ServiceListing.providerAgent`). */
59
+ provider: Address;
60
+ /**
61
+ * The provider's indexer track record, or `null` when unavailable (the gPA
62
+ * fallback has no trustless aggregated equivalent).
63
+ */
64
+ trackRecord: IndexerAgentTrackRecord | null;
65
+ /**
66
+ * The listing's indexer projection (carries `metadataValid`,
67
+ * `metadataIssues`, the pinned `specHash`), or `null` under the gPA fallback.
68
+ * The v1 read model does not yet project a standalone attestation verdict.
69
+ */
70
+ moderation: IndexerListing | null;
71
+ }
72
+ /** Options for {@link useListing}. */
73
+ interface UseListingOptions {
74
+ /** Disable the query (no `pda` yet, etc.). Default `true` when `pda` is set. */
75
+ enabled?: boolean;
76
+ }
77
+ /** Return value of {@link useListing}. */
78
+ interface UseListingResult {
79
+ /** The joined detail, or null until loaded. */
80
+ detail: ListingDetail | null;
81
+ /** The decoded listing, or null until loaded (convenience projection). */
82
+ listing: ServiceListing | null;
83
+ /** The provider agent PDA, or null until loaded. */
84
+ provider: Address | null;
85
+ /** The provider's track record, or null (unavailable / not yet loaded). */
86
+ trackRecord: IndexerAgentTrackRecord | null;
87
+ /** The listing's indexer/moderation projection, or null. */
88
+ moderation: IndexerListing | null;
89
+ /** True while loading. */
90
+ isLoading: boolean;
91
+ /** The error, or null. */
92
+ error: Error | null;
93
+ /** Force a refetch. */
94
+ refetch: () => void;
95
+ }
96
+ /**
97
+ * Read one listing and join its provider track record + moderation projection.
98
+ *
99
+ * @param pda - The ServiceListing PDA (string or Address). When falsy the query
100
+ * is disabled.
101
+ * @param options - `enabled` override.
102
+ * @returns {@link UseListingResult}.
103
+ */
104
+ declare function useListing(pda: Address | string | undefined | null, options?: UseListingOptions): UseListingResult;
105
+
106
+ /** Reads a Task account, returning the decoded {@link Task} or null if absent. */
107
+ type TaskReader = (pda: Address | string) => Promise<Task | null>;
108
+ /**
109
+ * A single coordination event observed for the watched task. Kept loosely typed
110
+ * (the SDK's `AgencEvent` union) so this hook does not pin the event schema.
111
+ */
112
+ type ObservedEvent = unknown;
113
+ /**
114
+ * An async source of coordination events for the watched task. Pass the result
115
+ * of the SDK's `subscribeMarketplaceEvents(...)` (already address-filtered) or
116
+ * any async iterable. Optional.
117
+ */
118
+ type TaskEventsSource = AsyncIterable<ObservedEvent>;
119
+ /** Options for {@link useTaskStatus}. */
120
+ interface UseTaskStatusOptions {
121
+ /**
122
+ * How to read the Task account. REQUIRED for any live status — without it the
123
+ * hook stays idle. See the module doc for wiring patterns.
124
+ */
125
+ taskReader?: TaskReader;
126
+ /**
127
+ * Optional event source. When given, observed events are appended to
128
+ * `events` and each triggers a refetch. Drained in a browser-only effect and
129
+ * aborted on unmount.
130
+ */
131
+ events?: TaskEventsSource;
132
+ /**
133
+ * Stop polling once the task reaches this status (in addition to terminal
134
+ * statuses). Useful to await a specific transition (e.g. `Completed`).
135
+ */
136
+ targetStatus?: TaskStatus;
137
+ /** Poll interval in ms while non-terminal. Default `2000`. */
138
+ pollIntervalMs?: number;
139
+ /** Disable the hook entirely. Default `true` when `taskPda` + reader exist. */
140
+ enabled?: boolean;
141
+ }
142
+ /** Return value of {@link useTaskStatus}. */
143
+ interface UseTaskStatusResult {
144
+ /** The decoded Task, or null until first read. */
145
+ task: Task | null;
146
+ /** The task status, or null until first read. */
147
+ status: TaskStatus | null;
148
+ /**
149
+ * The submission projection. v1 surfaces the task's on-chain `result` bytes
150
+ * (the worker's submitted result) once present; a richer submission read
151
+ * lands with the indexer projection. `null` until a result exists.
152
+ */
153
+ submission: Uint8Array | null;
154
+ /** Coordination events observed for this task (chronological). */
155
+ events: ObservedEvent[];
156
+ /** True while the first read is in flight. */
157
+ isLoading: boolean;
158
+ /** The read error, or null. */
159
+ error: Error | null;
160
+ /** Force a refetch. */
161
+ refetch: () => void;
162
+ }
163
+ /**
164
+ * Watch a task's status.
165
+ *
166
+ * @param taskPda - The Task PDA to watch (falsy disables the hook).
167
+ * @param options - Reader, event source, target status, poll interval.
168
+ * @returns {@link UseTaskStatusResult}.
169
+ */
170
+ declare function useTaskStatus(taskPda: Address | string | undefined | null, options?: UseTaskStatusOptions): UseTaskStatusResult;
171
+
172
+ /**
173
+ * The minimal adapter shape this hook bridges. The forthcoming
174
+ * `@tetsuo-ai/signer-adapters` hook is expected to return exactly this shape
175
+ * (its `signerFromWalletAccount(...)` resolves the `signer`); until it ships,
176
+ * any object matching this interface works.
177
+ */
178
+ interface WalletSignerAdapter {
179
+ /** The resolved kit signer, or null when no wallet is connected. */
180
+ signer: TransactionSigner | null;
181
+ /** Whether a wallet is currently connected. */
182
+ connected?: boolean;
183
+ /** Trigger the wallet connect flow (browser-only). Optional. */
184
+ connect?: () => void | Promise<void>;
185
+ }
186
+ /** Options for {@link useWalletSigner}. */
187
+ interface UseWalletSignerOptions {
188
+ /**
189
+ * A wallet adapter (e.g. the signer-adapters hook's result). When omitted the
190
+ * hook falls back to the provider's `config.signer`.
191
+ */
192
+ adapter?: WalletSignerAdapter;
193
+ }
194
+ /** Return value of {@link useWalletSigner}. */
195
+ interface UseWalletSignerResult {
196
+ /** The resolved kit `TransactionSigner`, or null. */
197
+ signer: TransactionSigner | null;
198
+ /** Whether a signer is available (adapter-connected or provider-configured). */
199
+ connected: boolean;
200
+ /** Trigger the wallet connect flow. No-op when no adapter `connect` exists. */
201
+ connect: () => void | Promise<void>;
202
+ }
203
+ /**
204
+ * Resolve the active signer for write operations.
205
+ *
206
+ * @param options - Optional wallet adapter; falls back to the provider signer.
207
+ * @returns {@link UseWalletSignerResult}.
208
+ *
209
+ * @example
210
+ * ```tsx
211
+ * // Once @tetsuo-ai/signer-adapters ships:
212
+ * const adapter = useWalletStandardSigner(); // returns WalletSignerAdapter
213
+ * const { signer, connected, connect } = useWalletSigner({ adapter });
214
+ * ```
215
+ */
216
+ declare function useWalletSigner(options?: UseWalletSignerOptions): UseWalletSignerResult;
217
+
218
+ /** A single referral-earning hire (shape defined now; populated post-P6.2). */
219
+ interface ReferrerHire {
220
+ /** The minted Task PDA of the referred hire. */
221
+ taskPda: string;
222
+ /** The HireRecord PDA carrying the snapshotted referrer fields. */
223
+ hireRecordPda: string;
224
+ /** Referral fee earned on this hire, in lamports. */
225
+ feeLamports: bigint;
226
+ /** Transaction signature of the hire. */
227
+ signature: string;
228
+ }
229
+ /** Return value of {@link useReferrerEarnings}. */
230
+ interface UseReferrerEarningsResult {
231
+ /**
232
+ * Whether referral settlement is live on this cluster. ALWAYS `false` today
233
+ * (the P6.2 gate). When false, the numbers below are the documented not-live
234
+ * zero state, not real data.
235
+ */
236
+ live: boolean;
237
+ /** Total lamports earned. `0n` while not live (never fabricated). */
238
+ totalLamports: bigint;
239
+ /** Per-hire earnings. `[]` while not live. */
240
+ hires: ReferrerHire[];
241
+ /** True while a (post-P6.2) fetch is in flight. Always false today. */
242
+ isLoading: boolean;
243
+ /** The fetch error, or null. */
244
+ error: Error | null;
245
+ /**
246
+ * Human-readable reason the data is not live (the capability reason). Present
247
+ * while `live` is false.
248
+ */
249
+ reason?: string;
250
+ /** Force a refetch (no-op while not live). */
251
+ refetch: () => void;
252
+ }
253
+ /**
254
+ * Read a referrer wallet's earnings.
255
+ *
256
+ * @param wallet - The referrer wallet (base58 / Address). Falsy disables the
257
+ * (future) fetch; the not-live state is still returned.
258
+ * @returns {@link UseReferrerEarningsResult} — the not-live zero state today.
259
+ *
260
+ * @example
261
+ * ```tsx
262
+ * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);
263
+ * // today: live === false, totalLamports === 0n, hires === []
264
+ * ```
265
+ */
266
+ declare function useReferrerEarnings(wallet: Address | string | undefined | null): UseReferrerEarningsResult;
267
+
268
+ /** Root namespace for every cache key this package writes. */
269
+ declare const QUERY_KEY_ROOT: "agenc";
270
+ /**
271
+ * Stable, hierarchical TanStack Query keys. Hooks build their keys ONLY through
272
+ * this factory so a consumer (or a hook) can invalidate a whole sub-tree
273
+ * (`["agenc", "listings"]`) or one entity (`["agenc", "listing", pda]`).
274
+ *
275
+ * `JSON.stringify` is intentionally NOT used — TanStack compares keys
276
+ * structurally, so passing the raw filter object keeps equality correct for
277
+ * `bigint`/`Address` values without a serialization step.
278
+ */
279
+ declare const queryKeys: {
280
+ /** All listings list queries (with their filter object as the leaf). */
281
+ readonly listings: (filter?: unknown) => readonly ["agenc", "listings", {} | null];
282
+ /** One listing + its joined provider/track-record/moderation. */
283
+ readonly listing: (pda: string) => readonly ["agenc", "listing", string];
284
+ /** One agent's indexer track record. */
285
+ readonly agentTrackRecord: (agentPda: string) => readonly ["agenc", "agentTrackRecord", string];
286
+ /** One task's status (read via transport / svm decode). */
287
+ readonly taskStatus: (taskPda: string) => readonly ["agenc", "taskStatus", string];
288
+ /** One task's dispute record. */
289
+ readonly dispute: (taskPda: string) => readonly ["agenc", "dispute", string];
290
+ /** One referrer wallet's earnings (P6.2-gated; see useReferrerEarnings). */
291
+ readonly referrerEarnings: (wallet: string) => readonly ["agenc", "referrerEarnings", string];
292
+ };
293
+
294
+ export { type ListingDetail, type ListingRow, type ObservedEvent, QUERY_KEY_ROOT, type ReferrerHire, type TaskEventsSource, type TaskReader, type UseListingOptions, type UseListingResult, type UseListingsFilter, type UseListingsOptions, type UseListingsResult, type UseReferrerEarningsResult, type UseTaskStatusOptions, type UseTaskStatusResult, type UseWalletSignerOptions, type UseWalletSignerResult, type WalletSignerAdapter, queryKeys, useListing, useListings, useReferrerEarnings, useTaskStatus, useWalletSigner };