@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,235 @@
1
+ import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
4
+ import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-BLrlBVj-.cjs';
5
+ export { B as Badge, e as BadgeProps, f as BadgeTone, g as Button, h as ButtonProps, i as ButtonVariant, j as COMPONENT_CATALOG, k as ComponentStringId, D as DEFAULT_TRUST_HREF, l as DisputeBanner, m as DisputeBannerProps, E as EN_COMPONENT_STRINGS, n as EN_STRINGS, G as GpaReadSource, H as HireButton, o as HireButtonProps, p as HireCheckoutListing, q as HireCheckoutModal, r as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, s as ListingCardData, t as ListingCardProps, u as ListingGrid, v as ListingGridProps, M as Modal, w as ModalProps, x as ModerationBadge, y as ModerationBadgeProps, z as ModerationState, P as PoweredByAgenC, F as PoweredByAgenCProps, J as ProviderCard, K as ProviderCardProps, N as ReadListingResult, O as ReferrerDisclosure, Q as ReferrerDisclosureProps, S as ReviewPanel, T as ReviewPanelProps, U as Spinner, W as SpinnerProps, X as StateKind, Y as StateMessage, Z as StateMessageProps, _ as StringCatalog, $ as StringId, a0 as StringVars, a1 as TaskTimeline, a2 as TaskTimelineProps, a3 as ThemableProps, a4 as TranslateOptions, a5 as VerifiedBadge, a6 as VerifiedBadgeProps, a7 as cx, a8 as decodeListingCategory, a9 as decodeListingName, aa as decodeListingTags, ab as elementClass, ac as formatPriceSol, ad as formatRate, ae as formatSol, af as moderationStateOf, ag as rootClass, ah as t, ai as tc, aj as toHex, ak as truncateAddress, al as useFocusTrap } from './index-BLrlBVj-.cjs';
6
+ export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.cjs';
7
+ export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike, b as WalletStandardSignTransaction } from './types-jvISR6bc.cjs';
8
+ export { Address, TransactionSigner } from '@solana/kit';
9
+ export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
10
+ import './useAgentTrackRecord-BLf1nrbu.cjs';
11
+
12
+ /**
13
+ * `<AgencProvider>` — the one context that wires reads, writes, and the
14
+ * (P6.2-gated) referrer config for every AgenC hook/component beneath it.
15
+ *
16
+ * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get
17
+ * caching/refetch/optimistic states with no consumer config. The
18
+ * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}
19
+ * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight
20
+ * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into
21
+ * `queryTransport`.
22
+ *
23
+ * SSR-safe: no `window`/`document` access at module scope or during render; all
24
+ * resolution is pure. The provider memoizes the context value and the
25
+ * QueryClient on config identity so SSR + hydration stay stable.
26
+ *
27
+ * @module provider/AgencProvider
28
+ */
29
+
30
+ /** Props for {@link AgencProvider}. */
31
+ interface AgencProviderProps {
32
+ /** Provider configuration. See {@link AgencProviderConfig}. */
33
+ config: AgencProviderConfig;
34
+ /**
35
+ * Optional pre-built TanStack QueryClient. When omitted, the provider creates
36
+ * one lazily (stable across renders). Pass your own to share a cache with the
37
+ * rest of your app.
38
+ */
39
+ queryClient?: QueryClient;
40
+ /** Override config for the lazily-created QueryClient (ignored if you pass one). */
41
+ queryClientConfig?: QueryClientConfig;
42
+ children: ReactNode;
43
+ }
44
+ /**
45
+ * The AgenC provider. Place at the root of any tree that uses AgenC hooks or
46
+ * components.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <AgencProvider config={{ network: "devnet", indexer: { baseUrl } }}>
51
+ * <App />
52
+ * </AgencProvider>
53
+ * ```
54
+ */
55
+ declare function AgencProvider(props: AgencProviderProps): ReactNode;
56
+
57
+ /**
58
+ * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer
59
+ * — {@link useAgencContext} turns that into a clear developer error.
60
+ */
61
+ declare const AgencContext: react.Context<AgencContextValue | null>;
62
+ /**
63
+ * Read the AgenC context. INTERNAL hook the package's own hooks build on; also
64
+ * exported from the package root so downstream hooks (components agent) can
65
+ * reach the resolved transport/client/referrer.
66
+ *
67
+ * @throws Error when called outside a `<AgencProvider>`.
68
+ */
69
+ declare function useAgencContext(): AgencContextValue;
70
+
71
+ /** Minimum referral fee, in basis points. */
72
+ declare const REFERRER_FEE_BPS_MIN = 0;
73
+ /**
74
+ * Maximum referral fee, in basis points. 10000 bps = 100%. The on-chain P6.2
75
+ * leg will enforce its own cap; this client-side bound is a sane outer guard so
76
+ * an obviously-wrong config (e.g. a typo'd 99999) is rejected at provider
77
+ * construction rather than silently stored.
78
+ */
79
+ declare const REFERRER_FEE_BPS_MAX = 10000;
80
+ /**
81
+ * Validate + normalize a raw {@link ReferrerConfig} into a
82
+ * {@link ValidatedReferrerConfig}.
83
+ *
84
+ * @throws TypeError when `wallet` is not a valid base58 Solana address.
85
+ * @throws RangeError when `feeBps` is not an integer in
86
+ * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.
87
+ */
88
+ declare function validateReferrerConfig(config: ReferrerConfig): ValidatedReferrerConfig;
89
+ /**
90
+ * Resolve whether a referral fee can actually be charged on the target cluster.
91
+ *
92
+ * THE P6.2 GATE — returns `live: false` UNCONDITIONALLY today.
93
+ *
94
+ * TODO(P6.2 / P6.5): once the on-chain referrer args + 4th settlement leg
95
+ * (PLAN.md P6.2) are deployed, replace the hardcoded `false` with a real check
96
+ * against P6.5 `getDeployedSurface` for the target cluster. Until then, returning
97
+ * a truthy `live` here would cause silent fee injection against a program that
98
+ * cannot honor it — strictly forbidden by PLAN_2 §0.
99
+ *
100
+ * @param referrer - The validated referrer config under the provider, or null.
101
+ * @returns A {@link ReferrerCapability} (always `{ live: false, ... }` today).
102
+ */
103
+ declare function resolveReferrerCapability(referrer: ValidatedReferrerConfig | null): ReferrerCapability;
104
+
105
+ /**
106
+ * Network → endpoint defaults.
107
+ *
108
+ * Reuses the resolution philosophy of the SDK sandbox env seam
109
+ * (`resolveSandboxEnvironment`): explicit config beats a per-network default,
110
+ * and the WebSocket endpoint is derived from the HTTP one when not given. This
111
+ * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs
112
+ * no `process`/`fs` access and the sandbox seam's async file-reading path.
113
+ *
114
+ * @module provider/network
115
+ */
116
+
117
+ /** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */
118
+ declare function deriveSubscriptionsUrl(rpcUrl: string): string;
119
+ /** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */
120
+ interface ResolvedEndpoints {
121
+ rpcUrl: string | null;
122
+ rpcSubscriptionsUrl: string | null;
123
+ }
124
+ /**
125
+ * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit
126
+ * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default
127
+ * exists (mainnet with no `rpcUrl`) — the provider treats that as "no write
128
+ * client buildable from URLs", not a throw, so a read-only/indexer-only or
129
+ * `client`-override setup still works.
130
+ */
131
+ declare function resolveEndpoints(network: AgencNetwork, rpcUrl?: string, rpcSubscriptionsUrl?: string): ResolvedEndpoints;
132
+
133
+ /**
134
+ * Thrown when a gPA-fallback transport is asked for an indexer-only capability
135
+ * (aggregated hires / track record have no trustless gPA equivalent).
136
+ */
137
+ declare class ReadTransportUnsupportedError extends Error {
138
+ /** The unsupported operation name. */
139
+ readonly operation: string;
140
+ constructor(operation: string);
141
+ }
142
+ /**
143
+ * Create the unified read transport.
144
+ *
145
+ * Resolution order:
146
+ * 1. `queryTransport` override (wins — tests/mocks/SSR fixtures);
147
+ * 2. `indexer.baseUrl` present → indexer-first transport;
148
+ * 3. `rpc` present → gPA fallback transport;
149
+ * 4. nothing configured → throws a descriptive error.
150
+ *
151
+ * @param config - See {@link CreateReadTransportConfig}.
152
+ * @returns A {@link ReadTransport}.
153
+ * @throws Error when no read source is configured.
154
+ */
155
+ declare function createReadTransport(config: CreateReadTransportConfig): ReadTransport;
156
+
157
+ /**
158
+ * AgenC theme — the `--agenc-*` CSS custom-property contract.
159
+ *
160
+ * ## How theming works (no CSS-in-JS runtime)
161
+ *
162
+ * Every prebuilt component (shipped by the components agent) styles itself
163
+ * **only** through CSS custom properties named `--agenc-*` (e.g.
164
+ * `--agenc-violet`, `--agenc-surface`, `--agenc-radius`). They are declared in
165
+ * the vendored {@link AGENC_TOKENS_CSS_PATH} stylesheet under `:root, .agenc`.
166
+ * To restyle, override any of those variables on an ancestor element — no
167
+ * recompile, no Tailwind, no JS.
168
+ *
169
+ * ## Three ways to load the tokens
170
+ *
171
+ * 1. **Side-effect CSS import** (recommended for bundler apps):
172
+ * ```ts
173
+ * import "@tetsuo-ai/marketplace-react/theme.css";
174
+ * ```
175
+ * Pulls in the full vendored token sheet as a side effect. This is the only
176
+ * CSS this package ships, and it is fully optional: headless hook usage
177
+ * needs no CSS at all.
178
+ *
179
+ * 2. **`<link>` / framework asset pipeline:** point at the resolved package
180
+ * path `@tetsuo-ai/marketplace-react/theme.css`.
181
+ *
182
+ * 3. **Inline injection** via {@link agencThemeStyleTag} — returns the token
183
+ * CSS as a string you can drop into a `<style>` tag (handy for the embed
184
+ * widget / iframe where a separate stylesheet request is undesirable).
185
+ * NOTE: this returns only the small base token set, not the full vendored
186
+ * sheet; prefer (1) or (2) for the canonical theme.
187
+ *
188
+ * ## The `unstyled` escape hatch (white-label)
189
+ *
190
+ * Per PLAN_2 A3, every prebuilt component accepts an `unstyled` prop. When set,
191
+ * the component renders semantic markup and ARIA wiring but emits **none** of
192
+ * the default `--agenc-*`-driven classes, so a host app can style it from
193
+ * scratch. This module owns the convention so components stay consistent:
194
+ * - the default class root is {@link AGENC_THEME_CLASS} (`"agenc"`), the scope
195
+ * under which `--agenc-*` tokens are defined;
196
+ * - {@link resolveThemeClassName} returns `undefined` when `unstyled` is true,
197
+ * so a component can spread it onto its root without branching.
198
+ *
199
+ * @module theme
200
+ */
201
+ /**
202
+ * The root class scope under which the vendored sheet declares `--agenc-*`
203
+ * tokens (`:root, .agenc`). Components default their outermost element to this
204
+ * class so the tokens resolve even when the sheet is scoped rather than global.
205
+ */
206
+ declare const AGENC_THEME_CLASS = "agenc";
207
+ /**
208
+ * Package-relative specifier for the vendored token stylesheet, exposed for
209
+ * documentation/tooling. Import it for its side effect via the package's
210
+ * `./theme.css` export: `import "@tetsuo-ai/marketplace-react/theme.css"`.
211
+ */
212
+ declare const AGENC_TOKENS_CSS_PATH = "@tetsuo-ai/marketplace-react/theme.css";
213
+ /**
214
+ * Resolve the class name a themable component should put on its root element.
215
+ *
216
+ * @param unstyled - When true (white-label mode), returns `undefined` so the
217
+ * component emits no default theme class.
218
+ * @param extra - An optional caller-supplied `className` to append.
219
+ * @returns The composed class string, or `undefined` when there is nothing to
220
+ * apply.
221
+ */
222
+ declare function resolveThemeClassName(unstyled?: boolean, extra?: string): string | undefined;
223
+ /**
224
+ * The minimal base `--agenc-*` token set as inline CSS text, for the embed /
225
+ * iframe surface where a separate stylesheet request is undesirable. This is a
226
+ * SUBSET of the full vendored sheet (the most load-bearing surface, brand,
227
+ * text, semantic, and radius tokens) — for the canonical, complete theme
228
+ * import `@tetsuo-ai/marketplace-react/theme.css` instead.
229
+ *
230
+ * SSR-safe: returns a string and never touches `document`. The caller decides
231
+ * how to inject it (a `<style>` element, a `dangerouslySetInnerHTML`, etc.).
232
+ */
233
+ declare function agencThemeStyleTag(): string;
234
+
235
+ export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, AgencContext, AgencContextValue, AgencNetwork, AgencProvider, AgencProviderConfig, type AgencProviderProps, CreateReadTransportConfig, REFERRER_FEE_BPS_MAX, REFERRER_FEE_BPS_MIN, ReadTransport, ReadTransportUnsupportedError, ReferrerCapability, ReferrerConfig, type ResolvedEndpoints, ValidatedReferrerConfig, agencThemeStyleTag, createReadTransport, deriveSubscriptionsUrl, resolveEndpoints, resolveReferrerCapability, resolveThemeClassName, useAgencContext, validateReferrerConfig };
@@ -0,0 +1,235 @@
1
+ import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
4
+ import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-CKTYsNPH.js';
5
+ export { B as Badge, e as BadgeProps, f as BadgeTone, g as Button, h as ButtonProps, i as ButtonVariant, j as COMPONENT_CATALOG, k as ComponentStringId, D as DEFAULT_TRUST_HREF, l as DisputeBanner, m as DisputeBannerProps, E as EN_COMPONENT_STRINGS, n as EN_STRINGS, G as GpaReadSource, H as HireButton, o as HireButtonProps, p as HireCheckoutListing, q as HireCheckoutModal, r as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, s as ListingCardData, t as ListingCardProps, u as ListingGrid, v as ListingGridProps, M as Modal, w as ModalProps, x as ModerationBadge, y as ModerationBadgeProps, z as ModerationState, P as PoweredByAgenC, F as PoweredByAgenCProps, J as ProviderCard, K as ProviderCardProps, N as ReadListingResult, O as ReferrerDisclosure, Q as ReferrerDisclosureProps, S as ReviewPanel, T as ReviewPanelProps, U as Spinner, W as SpinnerProps, X as StateKind, Y as StateMessage, Z as StateMessageProps, _ as StringCatalog, $ as StringId, a0 as StringVars, a1 as TaskTimeline, a2 as TaskTimelineProps, a3 as ThemableProps, a4 as TranslateOptions, a5 as VerifiedBadge, a6 as VerifiedBadgeProps, a7 as cx, a8 as decodeListingCategory, a9 as decodeListingName, aa as decodeListingTags, ab as elementClass, ac as formatPriceSol, ad as formatRate, ae as formatSol, af as moderationStateOf, ag as rootClass, ah as t, ai as tc, aj as toHex, ak as truncateAddress, al as useFocusTrap } from './index-CKTYsNPH.js';
6
+ export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.js';
7
+ export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike, b as WalletStandardSignTransaction } from './types-jvISR6bc.js';
8
+ export { Address, TransactionSigner } from '@solana/kit';
9
+ export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
10
+ import './useAgentTrackRecord-BLf1nrbu.js';
11
+
12
+ /**
13
+ * `<AgencProvider>` — the one context that wires reads, writes, and the
14
+ * (P6.2-gated) referrer config for every AgenC hook/component beneath it.
15
+ *
16
+ * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get
17
+ * caching/refetch/optimistic states with no consumer config. The
18
+ * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}
19
+ * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight
20
+ * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into
21
+ * `queryTransport`.
22
+ *
23
+ * SSR-safe: no `window`/`document` access at module scope or during render; all
24
+ * resolution is pure. The provider memoizes the context value and the
25
+ * QueryClient on config identity so SSR + hydration stay stable.
26
+ *
27
+ * @module provider/AgencProvider
28
+ */
29
+
30
+ /** Props for {@link AgencProvider}. */
31
+ interface AgencProviderProps {
32
+ /** Provider configuration. See {@link AgencProviderConfig}. */
33
+ config: AgencProviderConfig;
34
+ /**
35
+ * Optional pre-built TanStack QueryClient. When omitted, the provider creates
36
+ * one lazily (stable across renders). Pass your own to share a cache with the
37
+ * rest of your app.
38
+ */
39
+ queryClient?: QueryClient;
40
+ /** Override config for the lazily-created QueryClient (ignored if you pass one). */
41
+ queryClientConfig?: QueryClientConfig;
42
+ children: ReactNode;
43
+ }
44
+ /**
45
+ * The AgenC provider. Place at the root of any tree that uses AgenC hooks or
46
+ * components.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <AgencProvider config={{ network: "devnet", indexer: { baseUrl } }}>
51
+ * <App />
52
+ * </AgencProvider>
53
+ * ```
54
+ */
55
+ declare function AgencProvider(props: AgencProviderProps): ReactNode;
56
+
57
+ /**
58
+ * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer
59
+ * — {@link useAgencContext} turns that into a clear developer error.
60
+ */
61
+ declare const AgencContext: react.Context<AgencContextValue | null>;
62
+ /**
63
+ * Read the AgenC context. INTERNAL hook the package's own hooks build on; also
64
+ * exported from the package root so downstream hooks (components agent) can
65
+ * reach the resolved transport/client/referrer.
66
+ *
67
+ * @throws Error when called outside a `<AgencProvider>`.
68
+ */
69
+ declare function useAgencContext(): AgencContextValue;
70
+
71
+ /** Minimum referral fee, in basis points. */
72
+ declare const REFERRER_FEE_BPS_MIN = 0;
73
+ /**
74
+ * Maximum referral fee, in basis points. 10000 bps = 100%. The on-chain P6.2
75
+ * leg will enforce its own cap; this client-side bound is a sane outer guard so
76
+ * an obviously-wrong config (e.g. a typo'd 99999) is rejected at provider
77
+ * construction rather than silently stored.
78
+ */
79
+ declare const REFERRER_FEE_BPS_MAX = 10000;
80
+ /**
81
+ * Validate + normalize a raw {@link ReferrerConfig} into a
82
+ * {@link ValidatedReferrerConfig}.
83
+ *
84
+ * @throws TypeError when `wallet` is not a valid base58 Solana address.
85
+ * @throws RangeError when `feeBps` is not an integer in
86
+ * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.
87
+ */
88
+ declare function validateReferrerConfig(config: ReferrerConfig): ValidatedReferrerConfig;
89
+ /**
90
+ * Resolve whether a referral fee can actually be charged on the target cluster.
91
+ *
92
+ * THE P6.2 GATE — returns `live: false` UNCONDITIONALLY today.
93
+ *
94
+ * TODO(P6.2 / P6.5): once the on-chain referrer args + 4th settlement leg
95
+ * (PLAN.md P6.2) are deployed, replace the hardcoded `false` with a real check
96
+ * against P6.5 `getDeployedSurface` for the target cluster. Until then, returning
97
+ * a truthy `live` here would cause silent fee injection against a program that
98
+ * cannot honor it — strictly forbidden by PLAN_2 §0.
99
+ *
100
+ * @param referrer - The validated referrer config under the provider, or null.
101
+ * @returns A {@link ReferrerCapability} (always `{ live: false, ... }` today).
102
+ */
103
+ declare function resolveReferrerCapability(referrer: ValidatedReferrerConfig | null): ReferrerCapability;
104
+
105
+ /**
106
+ * Network → endpoint defaults.
107
+ *
108
+ * Reuses the resolution philosophy of the SDK sandbox env seam
109
+ * (`resolveSandboxEnvironment`): explicit config beats a per-network default,
110
+ * and the WebSocket endpoint is derived from the HTTP one when not given. This
111
+ * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs
112
+ * no `process`/`fs` access and the sandbox seam's async file-reading path.
113
+ *
114
+ * @module provider/network
115
+ */
116
+
117
+ /** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */
118
+ declare function deriveSubscriptionsUrl(rpcUrl: string): string;
119
+ /** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */
120
+ interface ResolvedEndpoints {
121
+ rpcUrl: string | null;
122
+ rpcSubscriptionsUrl: string | null;
123
+ }
124
+ /**
125
+ * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit
126
+ * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default
127
+ * exists (mainnet with no `rpcUrl`) — the provider treats that as "no write
128
+ * client buildable from URLs", not a throw, so a read-only/indexer-only or
129
+ * `client`-override setup still works.
130
+ */
131
+ declare function resolveEndpoints(network: AgencNetwork, rpcUrl?: string, rpcSubscriptionsUrl?: string): ResolvedEndpoints;
132
+
133
+ /**
134
+ * Thrown when a gPA-fallback transport is asked for an indexer-only capability
135
+ * (aggregated hires / track record have no trustless gPA equivalent).
136
+ */
137
+ declare class ReadTransportUnsupportedError extends Error {
138
+ /** The unsupported operation name. */
139
+ readonly operation: string;
140
+ constructor(operation: string);
141
+ }
142
+ /**
143
+ * Create the unified read transport.
144
+ *
145
+ * Resolution order:
146
+ * 1. `queryTransport` override (wins — tests/mocks/SSR fixtures);
147
+ * 2. `indexer.baseUrl` present → indexer-first transport;
148
+ * 3. `rpc` present → gPA fallback transport;
149
+ * 4. nothing configured → throws a descriptive error.
150
+ *
151
+ * @param config - See {@link CreateReadTransportConfig}.
152
+ * @returns A {@link ReadTransport}.
153
+ * @throws Error when no read source is configured.
154
+ */
155
+ declare function createReadTransport(config: CreateReadTransportConfig): ReadTransport;
156
+
157
+ /**
158
+ * AgenC theme — the `--agenc-*` CSS custom-property contract.
159
+ *
160
+ * ## How theming works (no CSS-in-JS runtime)
161
+ *
162
+ * Every prebuilt component (shipped by the components agent) styles itself
163
+ * **only** through CSS custom properties named `--agenc-*` (e.g.
164
+ * `--agenc-violet`, `--agenc-surface`, `--agenc-radius`). They are declared in
165
+ * the vendored {@link AGENC_TOKENS_CSS_PATH} stylesheet under `:root, .agenc`.
166
+ * To restyle, override any of those variables on an ancestor element — no
167
+ * recompile, no Tailwind, no JS.
168
+ *
169
+ * ## Three ways to load the tokens
170
+ *
171
+ * 1. **Side-effect CSS import** (recommended for bundler apps):
172
+ * ```ts
173
+ * import "@tetsuo-ai/marketplace-react/theme.css";
174
+ * ```
175
+ * Pulls in the full vendored token sheet as a side effect. This is the only
176
+ * CSS this package ships, and it is fully optional: headless hook usage
177
+ * needs no CSS at all.
178
+ *
179
+ * 2. **`<link>` / framework asset pipeline:** point at the resolved package
180
+ * path `@tetsuo-ai/marketplace-react/theme.css`.
181
+ *
182
+ * 3. **Inline injection** via {@link agencThemeStyleTag} — returns the token
183
+ * CSS as a string you can drop into a `<style>` tag (handy for the embed
184
+ * widget / iframe where a separate stylesheet request is undesirable).
185
+ * NOTE: this returns only the small base token set, not the full vendored
186
+ * sheet; prefer (1) or (2) for the canonical theme.
187
+ *
188
+ * ## The `unstyled` escape hatch (white-label)
189
+ *
190
+ * Per PLAN_2 A3, every prebuilt component accepts an `unstyled` prop. When set,
191
+ * the component renders semantic markup and ARIA wiring but emits **none** of
192
+ * the default `--agenc-*`-driven classes, so a host app can style it from
193
+ * scratch. This module owns the convention so components stay consistent:
194
+ * - the default class root is {@link AGENC_THEME_CLASS} (`"agenc"`), the scope
195
+ * under which `--agenc-*` tokens are defined;
196
+ * - {@link resolveThemeClassName} returns `undefined` when `unstyled` is true,
197
+ * so a component can spread it onto its root without branching.
198
+ *
199
+ * @module theme
200
+ */
201
+ /**
202
+ * The root class scope under which the vendored sheet declares `--agenc-*`
203
+ * tokens (`:root, .agenc`). Components default their outermost element to this
204
+ * class so the tokens resolve even when the sheet is scoped rather than global.
205
+ */
206
+ declare const AGENC_THEME_CLASS = "agenc";
207
+ /**
208
+ * Package-relative specifier for the vendored token stylesheet, exposed for
209
+ * documentation/tooling. Import it for its side effect via the package's
210
+ * `./theme.css` export: `import "@tetsuo-ai/marketplace-react/theme.css"`.
211
+ */
212
+ declare const AGENC_TOKENS_CSS_PATH = "@tetsuo-ai/marketplace-react/theme.css";
213
+ /**
214
+ * Resolve the class name a themable component should put on its root element.
215
+ *
216
+ * @param unstyled - When true (white-label mode), returns `undefined` so the
217
+ * component emits no default theme class.
218
+ * @param extra - An optional caller-supplied `className` to append.
219
+ * @returns The composed class string, or `undefined` when there is nothing to
220
+ * apply.
221
+ */
222
+ declare function resolveThemeClassName(unstyled?: boolean, extra?: string): string | undefined;
223
+ /**
224
+ * The minimal base `--agenc-*` token set as inline CSS text, for the embed /
225
+ * iframe surface where a separate stylesheet request is undesirable. This is a
226
+ * SUBSET of the full vendored sheet (the most load-bearing surface, brand,
227
+ * text, semantic, and radius tokens) — for the canonical, complete theme
228
+ * import `@tetsuo-ai/marketplace-react/theme.css` instead.
229
+ *
230
+ * SSR-safe: returns a string and never touches `document`. The caller decides
231
+ * how to inject it (a `<style>` element, a `dangerouslySetInnerHTML`, etc.).
232
+ */
233
+ declare function agencThemeStyleTag(): string;
234
+
235
+ export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, AgencContext, AgencContextValue, AgencNetwork, AgencProvider, AgencProviderConfig, type AgencProviderProps, CreateReadTransportConfig, REFERRER_FEE_BPS_MAX, REFERRER_FEE_BPS_MIN, ReadTransport, ReadTransportUnsupportedError, ReferrerCapability, ReferrerConfig, type ResolvedEndpoints, ValidatedReferrerConfig, agencThemeStyleTag, createReadTransport, deriveSubscriptionsUrl, resolveEndpoints, resolveReferrerCapability, resolveThemeClassName, useAgencContext, validateReferrerConfig };
package/dist/index.js ADDED
@@ -0,0 +1,127 @@
1
+ import { createReadTransport } from './chunk-ABS77JB2.js';
2
+ export { ReadTransportUnsupportedError, createReadTransport } from './chunk-ABS77JB2.js';
3
+ export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './chunk-5OTKSRHM.js';
4
+ export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, VerifiedBadge, agencThemeStyleTag, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, formatPriceSol, formatRate, formatSol, moderationStateOf, resolveThemeClassName, rootClass, tc, toHex, truncateAddress, useFocusTrap } from './chunk-KJMR6OGC.js';
5
+ import { AgencContext } from './chunk-YORZNYZZ.js';
6
+ export { AgencContext, useAgencContext } from './chunk-YORZNYZZ.js';
7
+ import { t } from './chunk-GN5DYVN5.js';
8
+ export { EN_STRINGS, t } from './chunk-GN5DYVN5.js';
9
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
10
+ import { createMarketplaceClient } from '@tetsuo-ai/marketplace-sdk';
11
+ import { useState, useMemo } from 'react';
12
+ import { isAddress } from '@solana/kit';
13
+ import { jsx } from 'react/jsx-runtime';
14
+
15
+ // src/provider/network.ts
16
+ var NETWORK_HTTP_DEFAULTS = {
17
+ localnet: "http://127.0.0.1:8899",
18
+ devnet: "https://api.devnet.solana.com",
19
+ // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).
20
+ mainnet: null
21
+ };
22
+ var NETWORK_WS_DEFAULTS = {
23
+ localnet: "ws://127.0.0.1:8900",
24
+ devnet: "wss://api.devnet.solana.com",
25
+ mainnet: null
26
+ };
27
+ function deriveSubscriptionsUrl(rpcUrl) {
28
+ if (/^https:\/\//i.test(rpcUrl)) {
29
+ return `wss://${rpcUrl.slice("https://".length)}`;
30
+ }
31
+ if (/^http:\/\//i.test(rpcUrl)) {
32
+ return `ws://${rpcUrl.slice("http://".length)}`;
33
+ }
34
+ return rpcUrl;
35
+ }
36
+ function resolveEndpoints(network, rpcUrl, rpcSubscriptionsUrl) {
37
+ const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];
38
+ const resolvedWs = rpcSubscriptionsUrl ?? (rpcUrl !== void 0 ? deriveSubscriptionsUrl(rpcUrl) : NETWORK_WS_DEFAULTS[network]);
39
+ return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };
40
+ }
41
+ var REFERRER_FEE_BPS_MIN = 0;
42
+ var REFERRER_FEE_BPS_MAX = 1e4;
43
+ function validateReferrerConfig(config) {
44
+ const { wallet, feeBps } = config;
45
+ if (typeof wallet !== "string" || !isAddress(wallet)) {
46
+ throw new TypeError(t("referrer.invalidWallet", { wallet: String(wallet) }));
47
+ }
48
+ if (typeof feeBps !== "number" || !Number.isInteger(feeBps) || feeBps < REFERRER_FEE_BPS_MIN || feeBps > REFERRER_FEE_BPS_MAX) {
49
+ throw new RangeError(
50
+ t("referrer.invalidFeeBps", {
51
+ min: REFERRER_FEE_BPS_MIN,
52
+ max: REFERRER_FEE_BPS_MAX,
53
+ feeBps: String(feeBps)
54
+ })
55
+ );
56
+ }
57
+ return { wallet, feeBps };
58
+ }
59
+ function resolveReferrerCapability(referrer) {
60
+ return {
61
+ live: false,
62
+ reason: t("referrer.notLiveReason"),
63
+ ...referrer ? { referrer } : {}
64
+ };
65
+ }
66
+ var DEFAULT_QUERY_CLIENT_CONFIG = {
67
+ defaultOptions: {
68
+ queries: {
69
+ // Marketplace listings change on-chain slowly relative to a UI session;
70
+ // a short stale window avoids refetch storms while staying fresh.
71
+ staleTime: 15e3,
72
+ retry: 1,
73
+ refetchOnWindowFocus: false
74
+ }
75
+ }
76
+ };
77
+ function buildReadTransport(config) {
78
+ return createReadTransport({
79
+ indexer: config.indexer,
80
+ queryTransport: config.queryTransport
81
+ // The gPA read source is provided only via queryTransport in v1 (a kit RPC
82
+ // or ProgramAccountsTransport). A future revision can derive a kit RPC from
83
+ // the resolved rpcUrl; for now indexer-first is the supported read path and
84
+ // queryTransport is the test/mocks seam.
85
+ });
86
+ }
87
+ function buildWriteClient(config, network) {
88
+ if (config.client) return config.client;
89
+ if (!config.signer) return null;
90
+ const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(
91
+ network,
92
+ config.rpcUrl,
93
+ config.rpcSubscriptionsUrl
94
+ );
95
+ if (rpcUrl === null) return null;
96
+ return createMarketplaceClient({
97
+ rpcUrl,
98
+ ...rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {},
99
+ signer: config.signer
100
+ });
101
+ }
102
+ function AgencProvider(props) {
103
+ const { config, children } = props;
104
+ const [internalQueryClient] = useState(
105
+ () => props.queryClient ?? new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG)
106
+ );
107
+ const queryClient = props.queryClient ?? internalQueryClient;
108
+ const value = useMemo(() => {
109
+ const network = config.network ?? "mainnet";
110
+ const referrer = config.referrer ? validateReferrerConfig(config.referrer) : null;
111
+ const read = buildReadTransport(config);
112
+ const client = buildWriteClient(config, network);
113
+ return {
114
+ network,
115
+ read,
116
+ client,
117
+ signer: config.signer ?? null,
118
+ referrer,
119
+ resolveReferrerCapability: () => resolveReferrerCapability(referrer)
120
+ };
121
+ }, [config]);
122
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(AgencContext.Provider, { value, children }) });
123
+ }
124
+
125
+ export { AgencProvider, REFERRER_FEE_BPS_MAX, REFERRER_FEE_BPS_MIN, deriveSubscriptionsUrl, resolveEndpoints, resolveReferrerCapability, validateReferrerConfig };
126
+ //# sourceMappingURL=index.js.map
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider/network.ts","../src/provider/referrer.ts","../src/provider/AgencProvider.tsx"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["/**\n * Network → endpoint defaults.\n *\n * Reuses the resolution philosophy of the SDK sandbox env seam\n * (`resolveSandboxEnvironment`): explicit config beats a per-network default,\n * and the WebSocket endpoint is derived from the HTTP one when not given. This\n * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs\n * no `process`/`fs` access and the sandbox seam's async file-reading path.\n *\n * @module provider/network\n */\nimport type { AgencNetwork } from \"../types.js\";\n\n/** Per-network default HTTP RPC endpoints. `mainnet` has no public default. */\nconst NETWORK_HTTP_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"http://127.0.0.1:8899\",\n devnet: \"https://api.devnet.solana.com\",\n // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).\n mainnet: null,\n};\n\n/**\n * `solana-test-validator` serves PubSub on RPC port + 1 (8900), so localnet's\n * WS endpoint is NOT derivable from the HTTP URL by scheme swap alone.\n */\nconst NETWORK_WS_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"ws://127.0.0.1:8900\",\n devnet: \"wss://api.devnet.solana.com\",\n mainnet: null,\n};\n\n/** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */\nexport function deriveSubscriptionsUrl(rpcUrl: string): string {\n if (/^https:\\/\\//i.test(rpcUrl)) {\n return `wss://${rpcUrl.slice(\"https://\".length)}`;\n }\n if (/^http:\\/\\//i.test(rpcUrl)) {\n return `ws://${rpcUrl.slice(\"http://\".length)}`;\n }\n return rpcUrl;\n}\n\n/** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */\nexport interface ResolvedEndpoints {\n rpcUrl: string | null;\n rpcSubscriptionsUrl: string | null;\n}\n\n/**\n * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit\n * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default\n * exists (mainnet with no `rpcUrl`) — the provider treats that as \"no write\n * client buildable from URLs\", not a throw, so a read-only/indexer-only or\n * `client`-override setup still works.\n */\nexport function resolveEndpoints(\n network: AgencNetwork,\n rpcUrl?: string,\n rpcSubscriptionsUrl?: string,\n): ResolvedEndpoints {\n const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];\n const resolvedWs =\n rpcSubscriptionsUrl ??\n (rpcUrl !== undefined\n ? deriveSubscriptionsUrl(rpcUrl)\n : NETWORK_WS_DEFAULTS[network]);\n return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };\n}\n","/**\n * Referrer config validation + the P6.2 capability gate.\n *\n * ## THE P6.2 GATE (PLAN_2 §0, MANDATORY)\n *\n * Referrer args + the 4th settlement leg are an UNBUILT Phase-6 on-chain change\n * (PLAN.md P6.2). The SDK `facade.hireFromListing` has NO referrer params yet.\n * So this module:\n * - ACCEPTS + VALIDATES `referrer: { wallet, feeBps }` and stores the normalized\n * form (validation is real: bad base58 throws, out-of-range bps rejected);\n * - exposes {@link resolveReferrerCapability}, which currently returns\n * `{ live: false, reason: \"P6.2 not deployed\" }` — HARDCODED false today, with\n * a clear TODO citing P6.2 / P6.5 `getDeployedSurface` as the future signal.\n *\n * When NOT live (today, always): referrer is NEVER injected into a hire, the\n * earnings hook returns a documented not-live state, and disclosure UI may still\n * SHOW \"this site earns a referral fee (pending protocol support)\". We NEVER\n * fake earnings or silently inject.\n *\n * @module provider/referrer\n */\nimport { isAddress } from \"@solana/kit\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n ReferrerCapability,\n ReferrerConfig,\n ValidatedReferrerConfig,\n} from \"../types.js\";\n\n/** Minimum referral fee, in basis points. */\nexport const REFERRER_FEE_BPS_MIN = 0;\n/**\n * Maximum referral fee, in basis points. 10000 bps = 100%. The on-chain P6.2\n * leg will enforce its own cap; this client-side bound is a sane outer guard so\n * an obviously-wrong config (e.g. a typo'd 99999) is rejected at provider\n * construction rather than silently stored.\n */\nexport const REFERRER_FEE_BPS_MAX = 10_000;\n\n/**\n * Validate + normalize a raw {@link ReferrerConfig} into a\n * {@link ValidatedReferrerConfig}.\n *\n * @throws TypeError when `wallet` is not a valid base58 Solana address.\n * @throws RangeError when `feeBps` is not an integer in\n * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.\n */\nexport function validateReferrerConfig(\n config: ReferrerConfig,\n): ValidatedReferrerConfig {\n const { wallet, feeBps } = config;\n if (typeof wallet !== \"string\" || !isAddress(wallet)) {\n throw new TypeError(t(\"referrer.invalidWallet\", { wallet: String(wallet) }));\n }\n if (\n typeof feeBps !== \"number\" ||\n !Number.isInteger(feeBps) ||\n feeBps < REFERRER_FEE_BPS_MIN ||\n feeBps > REFERRER_FEE_BPS_MAX\n ) {\n throw new RangeError(\n t(\"referrer.invalidFeeBps\", {\n min: REFERRER_FEE_BPS_MIN,\n max: REFERRER_FEE_BPS_MAX,\n feeBps: String(feeBps),\n }),\n );\n }\n return { wallet: wallet as Address, feeBps };\n}\n\n/**\n * Resolve whether a referral fee can actually be charged on the target cluster.\n *\n * THE P6.2 GATE — returns `live: false` UNCONDITIONALLY today.\n *\n * TODO(P6.2 / P6.5): once the on-chain referrer args + 4th settlement leg\n * (PLAN.md P6.2) are deployed, replace the hardcoded `false` with a real check\n * against P6.5 `getDeployedSurface` for the target cluster. Until then, returning\n * a truthy `live` here would cause silent fee injection against a program that\n * cannot honor it — strictly forbidden by PLAN_2 §0.\n *\n * @param referrer - The validated referrer config under the provider, or null.\n * @returns A {@link ReferrerCapability} (always `{ live: false, ... }` today).\n */\nexport function resolveReferrerCapability(\n referrer: ValidatedReferrerConfig | null,\n): ReferrerCapability {\n // P6.2 GATE: hardcoded not-live. Do NOT make this conditionally true until\n // P6.2 is deployed AND P6.5 getDeployedSurface confirms it on the cluster.\n return {\n live: false,\n reason: t(\"referrer.notLiveReason\"),\n ...(referrer ? { referrer } : {}),\n };\n}\n","/**\n * `<AgencProvider>` — the one context that wires reads, writes, and the\n * (P6.2-gated) referrer config for every AgenC hook/component beneath it.\n *\n * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get\n * caching/refetch/optimistic states with no consumer config. The\n * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}\n * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight\n * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into\n * `queryTransport`.\n *\n * SSR-safe: no `window`/`document` access at module scope or during render; all\n * resolution is pure. The provider memoizes the context value and the\n * QueryClient on config identity so SSR + hydration stay stable.\n *\n * @module provider/AgencProvider\n */\nimport {\n QueryClient,\n QueryClientProvider,\n type QueryClientConfig,\n} from \"@tanstack/react-query\";\nimport { createMarketplaceClient } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { createReadTransport } from \"../transport/index.js\";\nimport type {\n AgencContextValue,\n AgencNetwork,\n AgencProviderConfig,\n MarketplaceClient,\n ReadTransport,\n ValidatedReferrerConfig,\n} from \"../types.js\";\nimport { AgencContext } from \"./context.js\";\nimport { resolveEndpoints } from \"./network.js\";\nimport {\n resolveReferrerCapability as resolveReferrerCapabilityImpl,\n validateReferrerConfig,\n} from \"./referrer.js\";\n\n/** Props for {@link AgencProvider}. */\nexport interface AgencProviderProps {\n /** Provider configuration. See {@link AgencProviderConfig}. */\n config: AgencProviderConfig;\n /**\n * Optional pre-built TanStack QueryClient. When omitted, the provider creates\n * one lazily (stable across renders). Pass your own to share a cache with the\n * rest of your app.\n */\n queryClient?: QueryClient;\n /** Override config for the lazily-created QueryClient (ignored if you pass one). */\n queryClientConfig?: QueryClientConfig;\n children: ReactNode;\n}\n\n/** Default QueryClient tuning for marketplace reads (sane, overridable). */\nconst DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {\n defaultOptions: {\n queries: {\n // Marketplace listings change on-chain slowly relative to a UI session;\n // a short stale window avoids refetch storms while staying fresh.\n staleTime: 15_000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n};\n\n/**\n * Build the read transport from config. The `queryTransport` override wins;\n * otherwise indexer-first (when `indexer.baseUrl` is set) with a gPA fallback\n * over the resolved RPC URL.\n *\n * NOTE: the gPA fallback needs a kit `Rpc<GetProgramAccountsApi>`, which we do\n * NOT build here from a bare URL — the SDK write client owns RPC construction.\n * When only a URL (no indexer, no queryTransport) is available, reads require\n * an indexer; the transport factory throws a descriptive error on first use.\n */\nfunction buildReadTransport(\n config: AgencProviderConfig,\n): ReadTransport {\n return createReadTransport({\n indexer: config.indexer,\n queryTransport: config.queryTransport,\n // The gPA read source is provided only via queryTransport in v1 (a kit RPC\n // or ProgramAccountsTransport). A future revision can derive a kit RPC from\n // the resolved rpcUrl; for now indexer-first is the supported read path and\n // queryTransport is the test/mocks seam.\n });\n}\n\n/**\n * Build the write client from config. The `client` override wins. Otherwise a\n * client is built only when BOTH a resolvable `rpcUrl` and a `signer` exist;\n * absent either, the provider exposes `client: null` and mutating hooks surface\n * a clear error (read-only / indexer-only setups are valid).\n */\nfunction buildWriteClient(\n config: AgencProviderConfig,\n network: AgencNetwork,\n): MarketplaceClient | null {\n if (config.client) return config.client;\n if (!config.signer) return null;\n const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n if (rpcUrl === null) return null;\n return createMarketplaceClient({\n rpcUrl,\n ...(rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {}),\n signer: config.signer,\n });\n}\n\n/**\n * The AgenC provider. Place at the root of any tree that uses AgenC hooks or\n * components.\n *\n * @example\n * ```tsx\n * <AgencProvider config={{ network: \"devnet\", indexer: { baseUrl } }}>\n * <App />\n * </AgencProvider>\n * ```\n */\nexport function AgencProvider(props: AgencProviderProps): ReactNode {\n const { config, children } = props;\n\n // Lazily create (and keep stable) the QueryClient. useState initializer runs\n // once; passing your own `queryClient` overrides it.\n const [internalQueryClient] = useState<QueryClient>(\n () =>\n props.queryClient ??\n new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG),\n );\n const queryClient = props.queryClient ?? internalQueryClient;\n\n const value = useMemo<AgencContextValue>(() => {\n const network: AgencNetwork = config.network ?? \"mainnet\";\n\n // Validate + normalize referrer ALWAYS (the P6.2 gate decides injection,\n // not validation). A bad config throws here, at provider construction.\n const referrer: ValidatedReferrerConfig | null = config.referrer\n ? validateReferrerConfig(config.referrer)\n : null;\n\n const read = buildReadTransport(config);\n const client = buildWriteClient(config, network);\n\n return {\n network,\n read,\n client,\n signer: config.signer ?? null,\n referrer,\n resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),\n };\n // Re-resolve when any wiring input changes. Referrer object identity is\n // intentionally part of the deps (a new referrer config must re-validate).\n }, [config]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <AgencContext.Provider value={value}>{children}</AgencContext.Provider>\n </QueryClientProvider>\n );\n}\n"]}