@lunora/react 1.0.0-alpha.25 → 1.0.0-alpha.250

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 (78) hide show
  1. package/README.md +28 -18
  2. package/dist/index.d.mts +991 -555
  3. package/dist/index.d.ts +991 -555
  4. package/dist/index.mjs +1 -24
  5. package/dist/packem_shared/AuthLoading-024-XH0I.mjs +2 -0
  6. package/dist/packem_shared/LunoraProvider-Cge6aAOa.mjs +1 -0
  7. package/dist/packem_shared/hydratePreloaded-qs8nspKB.mjs +2 -0
  8. package/dist/packem_shared/lunora-provider-_WqSuvf9.mjs +2 -0
  9. package/dist/packem_shared/lunoraQueryOptions-IJB_aFzi.mjs +1 -0
  10. package/dist/packem_shared/query-core-DRzrn3qJ.mjs +2 -0
  11. package/dist/packem_shared/query-key-BysXrewF.mjs +1 -0
  12. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +38 -0
  13. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +38 -0
  14. package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
  15. package/dist/packem_shared/use-paginated-core-Bf9xLRSk.mjs +2 -0
  16. package/dist/packem_shared/useAction-jJl4KPEw.mjs +2 -0
  17. package/dist/packem_shared/useAgent-CO523Dot.mjs +2 -0
  18. package/dist/packem_shared/useAgentChat-51qFVjQW.mjs +2 -0
  19. package/dist/packem_shared/useAgentState-CwsVpvmD.mjs +2 -0
  20. package/dist/packem_shared/useAgentToolEvents-YQl2HgR6.mjs +2 -0
  21. package/dist/packem_shared/useAuth-CpGKVRsv.mjs +2 -0
  22. package/dist/packem_shared/useAuthSessions-jJWdw8Zw.mjs +2 -0
  23. package/dist/packem_shared/useAuthState-CqN1F2FM.mjs +2 -0
  24. package/dist/packem_shared/useClientQuery-DUEUAqPh.mjs +2 -0
  25. package/dist/packem_shared/useConnectionStatus-Dtx_OWez.mjs +2 -0
  26. package/dist/packem_shared/useFlag-A7XPHExt.mjs +2 -0
  27. package/dist/packem_shared/useHttpStream-CzryjxVH.mjs +2 -0
  28. package/dist/packem_shared/useInfiniteQuery-D_AG59dX.mjs +2 -0
  29. package/dist/packem_shared/useLiveTopic-UYAE2s4R.mjs +2 -0
  30. package/dist/packem_shared/useMutation-29nXea_s.mjs +2 -0
  31. package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
  32. package/dist/packem_shared/usePaginatedQuery-DhQAsxgX.mjs +2 -0
  33. package/dist/packem_shared/usePresence-X5Ax04Cf.mjs +2 -0
  34. package/dist/packem_shared/useQuery-Cek_oF7t.mjs +2 -0
  35. package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
  36. package/dist/packem_shared/useStream-D8GB__4j.mjs +2 -0
  37. package/dist/packem_shared/useSubscription-D9QkGhO3.mjs +2 -0
  38. package/dist/packem_shared/useSuspenseQuery-CZTk7Kch.mjs +2 -0
  39. package/dist/packem_shared/useVoiceAgent-ixfjauAR.mjs +2 -0
  40. package/dist/payment.d.mts +105 -0
  41. package/dist/payment.d.ts +105 -0
  42. package/dist/payment.mjs +2 -0
  43. package/dist/server.d.mts +47 -29
  44. package/dist/server.d.ts +47 -29
  45. package/dist/server.mjs +1 -31
  46. package/dist/upload.d.mts +24 -0
  47. package/dist/upload.d.ts +24 -0
  48. package/dist/upload.mjs +2 -0
  49. package/package.json +14 -4
  50. package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
  51. package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
  52. package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
  53. package/dist/packem_shared/cache-D1O_xfAe.mjs +0 -80
  54. package/dist/packem_shared/hydratePreloaded-uMDH_xA9.mjs +0 -54
  55. package/dist/packem_shared/lunoraQueryOptions-C3uwOTMW.mjs +0 -16
  56. package/dist/packem_shared/query-key-BmCbgidV.mjs +0 -13
  57. package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +0 -38
  58. package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +0 -38
  59. package/dist/packem_shared/stable-key-CGp4e2Ux.mjs +0 -38
  60. package/dist/packem_shared/use-paginated-core-DafedU4l.mjs +0 -179
  61. package/dist/packem_shared/useAgent-DwLxTc3P.mjs +0 -101
  62. package/dist/packem_shared/useAgentChat-WPm5iHgR.mjs +0 -283
  63. package/dist/packem_shared/useAgentState-Cikdlomg.mjs +0 -37
  64. package/dist/packem_shared/useAgentToolEvents-BM7ERo00.mjs +0 -129
  65. package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
  66. package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
  67. package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
  68. package/dist/packem_shared/useFlag-C2Pkghli.mjs +0 -128
  69. package/dist/packem_shared/useInfiniteQuery-BeaehE9f.mjs +0 -97
  70. package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
  71. package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
  72. package/dist/packem_shared/usePaginatedQuery-_6ETVUmf.mjs +0 -46
  73. package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
  74. package/dist/packem_shared/useQuery-D3_ZxMYs.mjs +0 -54
  75. package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
  76. package/dist/packem_shared/useStream-CGC26afa.mjs +0 -128
  77. package/dist/packem_shared/useSubscription-D38Jdyr8.mjs +0 -139
  78. package/dist/packem_shared/useVoiceAgent-sC5_ADB8.mjs +0 -416
@@ -1,80 +0,0 @@
1
- import { k as keyHash } from './query-key-BmCbgidV.mjs';
2
-
3
- class LunoraSubscriptionRegistry {
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- client;
8
- entries = /* @__PURE__ */ new Map();
9
- /**
10
- * Hash a TanStack `queryKey` to the internal registry index. Exposed so a
11
- * hook can look up the registry without re-implementing the hash.
12
- */
13
- // eslint-disable-next-line class-methods-use-this -- instance method by design: callers reach the hash through a registry handle rather than importing the module-level helper.
14
- keyOf(queryKey) {
15
- return keyHash(queryKey);
16
- }
17
- /**
18
- * Attach a consumer to the live subscription for `queryKey`. The first
19
- * attach opens the underlying WS subscription; subsequent attaches reuse
20
- * it (refcount-bumped). Returns the detach function — call it exactly once
21
- * per attach.
22
- */
23
- attach(queryClient, queryKey, function_, args, shardKey, options = {}) {
24
- const key = keyHash(queryKey);
25
- let entry = this.entries.get(key);
26
- if (!entry) {
27
- entry = {
28
- pollTimer: void 0,
29
- refCount: 0,
30
- unsubscribe: void 0
31
- };
32
- this.entries.set(key, entry);
33
- try {
34
- entry.unsubscribe = this.client.subscribe(function_, args, (value) => {
35
- queryClient.setQueryData(queryKey, value);
36
- }, {
37
- shardKey
38
- });
39
- } catch {
40
- entry.pollTimer = setInterval(() => {
41
- queryClient.invalidateQueries({
42
- queryKey
43
- }).catch(() => {
44
- });
45
- }, options.pollIntervalMs ?? 5e3);
46
- }
47
- }
48
- entry.refCount += 1;
49
- let detached = false;
50
- return () => {
51
- if (detached) {
52
- return;
53
- }
54
- detached = true;
55
- const current = this.entries.get(key);
56
- if (!current) {
57
- return;
58
- }
59
- current.refCount -= 1;
60
- if (current.refCount <= 0) {
61
- current.unsubscribe?.();
62
- if (current.pollTimer) {
63
- clearInterval(current.pollTimer);
64
- }
65
- this.entries.delete(key);
66
- }
67
- };
68
- }
69
- }
70
- const registryByClient = /* @__PURE__ */ new WeakMap();
71
- const getSubscriptionRegistry = (client) => {
72
- let registry = registryByClient.get(client);
73
- if (!registry) {
74
- registry = new LunoraSubscriptionRegistry(client);
75
- registryByClient.set(client, registry);
76
- }
77
- return registry;
78
- };
79
-
80
- export { getSubscriptionRegistry as g };
@@ -1,54 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useQueryClient, useQuery } from '@tanstack/react-query';
4
- import { useEffect } from 'react';
5
- import { g as getSubscriptionRegistry } from './cache-D1O_xfAe.mjs';
6
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
7
- import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-BmCbgidV.mjs';
8
-
9
- const usePreloadedQuery = function(preloaded) {
10
- const $ = c(4);
11
- const client = useLunora();
12
- const queryClient = useQueryClient();
13
- const {
14
- args,
15
- functionPath,
16
- shardKey,
17
- value
18
- } = preloaded;
19
- const functionRef = {
20
- __lunoraRef: functionPath
21
- };
22
- const queryKey = lunoraQueryKey(functionRef, args, shardKey);
23
- const {
24
- data
25
- } = useQuery({
26
- initialData: value,
27
- queryFn: () => client.query(functionRef, args, {
28
- shardKey
29
- }),
30
- queryKey,
31
- staleTime: Number.POSITIVE_INFINITY
32
- });
33
- const t0 = serializeQueryKey(queryKey);
34
- let t1;
35
- if ($[0] !== client || $[1] !== queryClient || $[2] !== t0) {
36
- t1 = [client, queryClient, t0];
37
- $[0] = client;
38
- $[1] = queryClient;
39
- $[2] = t0;
40
- $[3] = t1;
41
- } else {
42
- t1 = $[3];
43
- }
44
- useEffect(() => {
45
- const registry = getSubscriptionRegistry(client);
46
- return registry.attach(queryClient, queryKey, functionRef, args, shardKey);
47
- }, t1);
48
- return data === void 0 ? value : data;
49
- };
50
- const hydratePreloaded = function(preloaded) {
51
- return usePreloadedQuery(preloaded);
52
- };
53
-
54
- export { usePreloadedQuery as default, hydratePreloaded };
@@ -1,16 +0,0 @@
1
- import { l as lunoraQueryKey } from './query-key-BmCbgidV.mjs';
2
-
3
- const lunoraQueryOptions = (client, function_, args, options = {}) => {
4
- const argsRecord = args ?? {};
5
- return {
6
- queryFn: () => client.query(function_, argsRecord, {
7
- shardKey: options.shardKey
8
- }),
9
- queryKey: lunoraQueryKey(function_, argsRecord, options.shardKey),
10
- // Lunora is push-driven: the value never goes stale on a timer. For
11
- // reactivity use `useQuery`; this adapter is a one-shot/suspense read.
12
- staleTime: Number.POSITIVE_INFINITY
13
- };
14
- };
15
-
16
- export { lunoraQueryOptions };
@@ -1,13 +0,0 @@
1
- import { s as stableStringify } from './stable-key-CGp4e2Ux.mjs';
2
-
3
- const keyHash = (queryKey) => stableStringify(queryKey);
4
- const lunoraQueryKey = (function_, args, shardKey) => [
5
- "lunora",
6
- function_.__lunoraRef,
7
- args,
8
- // eslint-disable-next-line unicorn/no-null -- this literal is part of the JSON-serialized query key TanStack hashes for dedup; `null` keeps a stable, distinct slot from an absent shardKey across renders.
9
- shardKey ?? null
10
- ];
11
- const serializeQueryKey = (queryKey) => keyHash(queryKey);
12
-
13
- export { keyHash as k, lunoraQueryKey as l, serializeQueryKey as s };
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -1,38 +0,0 @@
1
- import { FunctionReference, ReturnOf, LunoraClient, ArgsOf } from '@lunora/client';
2
- import { QueryKey } from '@tanstack/react-query';
3
- /**
4
- * Pure, transport-free adapter between a Lunora function reference and a
5
- * TanStack Query options object. No `"use client"` directive and only a
6
- * type-level `@lunora/client` import, so it is safe to use on either side of an
7
- * RSC boundary (the runtime transport is the `LunoraClient` you pass in).
8
- *
9
- * Use it when you want to drive a Lunora query through TanStack's own hooks —
10
- * `useSuspenseQuery`, `useQueries`, or the server-side
11
- * `queryClient.ensureQueryData` / `prefetchQuery` — rather than the first-class
12
- * `useQuery` from `@lunora/react`.
13
- */
14
- /** Shape returned by `lunoraQueryOptions`, spread into a TanStack hook. */
15
- interface LunoraQueryOptions<F extends FunctionReference> {
16
- queryFn: () => Promise<ReturnOf<F>>;
17
- queryKey: QueryKey;
18
- staleTime: number;
19
- }
20
- /**
21
- * Build a TanStack Query options object for a Lunora query, keyed identically
22
- * to the first-class hooks (see `lunoraQueryKey`) so a value fetched through
23
- * this adapter shares cache identity with anything `useQuery` /
24
- * `prefetchQuery` reads or writes for the same `(fn, args, shardKey)` triple.
25
- *
26
- * ```ts
27
- * const { data } = useSuspenseQuery(lunoraQueryOptions(client, api.posts.list, {}));
28
- * ```
29
- *
30
- * This is a one-shot fetch: it resolves once and `staleTime` is infinite, so
31
- * TanStack never refetches on its own. It does not open a WebSocket — for live
32
- * updates that re-render on every server push, use `useQuery` from
33
- * `@lunora/react`, which attaches a shared subscription to the same cache key.
34
- */
35
- declare const lunoraQueryOptions: <F extends FunctionReference>(client: LunoraClient, function_: F, args: ArgsOf<F>, options?: {
36
- shardKey?: string;
37
- }) => LunoraQueryOptions<F>;
38
- export { LunoraQueryOptions as L, lunoraQueryOptions as l };
@@ -1,38 +0,0 @@
1
- const compareKeys = (a, b) => {
2
- if (a < b) {
3
- return -1;
4
- }
5
- return a > b ? 1 : 0;
6
- };
7
- const stableStringify = (value) => {
8
- if (value === void 0) {
9
- return "null";
10
- }
11
- if (typeof value === "bigint") {
12
- throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) — pass it as a string");
13
- }
14
- if (value === null || typeof value !== "object") {
15
- return JSON.stringify(value);
16
- }
17
- if (Array.isArray(value)) {
18
- return `[${value.map((item) => stableStringify(item)).join(",")}]`;
19
- }
20
- const proto = Object.getPrototypeOf(value);
21
- if (proto !== null && proto !== Object.prototype) {
22
- const name = value.constructor?.name ?? "value";
23
- throw new TypeError(`stableStringify: cannot use a ${name} in a cache key (query/subscription/shape args) — only plain objects, arrays, and JSON primitives are supported`);
24
- }
25
- const record = value;
26
- const keys = Object.keys(record).toSorted(compareKeys);
27
- const parts = [];
28
- for (const key of keys) {
29
- const raw = record[key];
30
- if (raw === void 0) {
31
- continue;
32
- }
33
- parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
34
- }
35
- return `{${parts.join(",")}}`;
36
- };
37
-
38
- export { stableStringify as s };
@@ -1,179 +0,0 @@
1
- 'use client';
2
- import { initialPages, rebalance, derivePaginationStatus, applyLoadMore } from '@lunora/client/pagination';
3
- import { useQueryClient } from '@tanstack/react-query';
4
- import { useRef, useReducer, useState, useEffect, useCallback } from 'react';
5
- import { g as getSubscriptionRegistry } from './cache-D1O_xfAe.mjs';
6
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
7
- import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-BmCbgidV.mjs';
8
-
9
- const useLazyRef = function(create) {
10
- const reference = useRef(void 0);
11
- reference.current ??= create();
12
- return reference;
13
- };
14
-
15
- const usePaginatedCore = function(function_, args, options) {
16
- const client = useLunora();
17
- const queryClient = useQueryClient();
18
- const {
19
- initialNumItems,
20
- shardKey
21
- } = options;
22
- const skipped = args === "skip";
23
- const baseArgs = skipped ? {} : args;
24
- const [, forceRender] = useReducer((tick) => tick + 1, 0);
25
- const [pages, setPages] = useState(() => initialPages(initialNumItems));
26
- const resetKey = `${serializeQueryKey(lunoraQueryKey(function_, baseArgs, shardKey))}::${String(initialNumItems)}`;
27
- const resetKeyRef = useRef(resetKey);
28
- if (resetKeyRef.current !== resetKey) {
29
- resetKeyRef.current = resetKey;
30
- setPages(initialPages(initialNumItems));
31
- }
32
- const pageEntries = pages.map((page) => {
33
- const pageArgs = {
34
- ...baseArgs,
35
- paginationOpts: {
36
- cursor: page.lower,
37
- endCursor: page.upper,
38
- numItems: page.numItems
39
- }
40
- };
41
- const key = lunoraQueryKey(function_, pageArgs, shardKey);
42
- return {
43
- args: pageArgs,
44
- key
45
- };
46
- });
47
- const pageKeysHash = pageEntries.map(({
48
- key: key_0
49
- }) => serializeQueryKey(key_0)).join("|");
50
- const desiredRef = useRef({
51
- baseArgs,
52
- entries: [],
53
- fn: function_,
54
- shardKey
55
- });
56
- useEffect(() => {
57
- desiredRef.current = {
58
- baseArgs,
59
- entries: pageEntries,
60
- fn: function_,
61
- shardKey
62
- };
63
- });
64
- const detachesRef = useLazyRef(() => /* @__PURE__ */ new Map());
65
- const detachClientRef = useRef(client);
66
- useEffect(() => {
67
- const detaches = detachesRef.current;
68
- if (detachClientRef.current !== client) {
69
- for (const detach of detaches.values()) {
70
- detach();
71
- }
72
- detaches.clear();
73
- detachClientRef.current = client;
74
- }
75
- if (skipped) {
76
- for (const detach_0 of detaches.values()) {
77
- detach_0();
78
- }
79
- detaches.clear();
80
- return;
81
- }
82
- const desired = desiredRef.current;
83
- const registry = getSubscriptionRegistry(client);
84
- const wanted = new Set(desired.entries.map(({
85
- key: key_1
86
- }) => serializeQueryKey(key_1)));
87
- for (const [hash, detach_1] of detaches) {
88
- if (!wanted.has(hash)) {
89
- detach_1();
90
- detaches.delete(hash);
91
- }
92
- }
93
- for (const entry of desired.entries) {
94
- const hash_0 = serializeQueryKey(entry.key);
95
- if (detaches.has(hash_0)) {
96
- continue;
97
- }
98
- const initialFetch = queryClient.fetchQuery({
99
- queryFn: () => client.query(desired.fn, entry.args, {
100
- shardKey: desired.shardKey
101
- }),
102
- queryKey: entry.key,
103
- staleTime: 0
104
- });
105
- initialFetch.catch(() => {
106
- });
107
- detaches.set(hash_0, registry.attach(queryClient, entry.key, desired.fn, entry.args, desired.shardKey));
108
- }
109
- }, [client, queryClient, pageKeysHash, skipped]);
110
- useEffect(
111
- () => () => {
112
- for (const detach_2 of detachesRef.current.values()) {
113
- detach_2();
114
- }
115
- detachesRef.current.clear();
116
- },
117
- // react-doctor-disable-next-line react-doctor/exhaustive-deps -- intentional: unmount-only cleanup. `detachesRef` is a stable ref, so the empty dep array is correct — the teardown must run once on unmount, not every render.
118
- []
119
- );
120
- useEffect(() => {
121
- const cache = queryClient.getQueryCache();
122
- const unsubscribe = cache.subscribe((event) => {
123
- if (event.type !== "updated") {
124
- return;
125
- }
126
- const hash_1 = serializeQueryKey(event.query.queryKey);
127
- if (pageEntries.some(({
128
- key: key_2
129
- }) => serializeQueryKey(key_2) === hash_1)) {
130
- forceRender();
131
- }
132
- });
133
- return unsubscribe;
134
- }, [queryClient, pageKeysHash]);
135
- const pageResults = skipped ? [] : pageEntries.map(({
136
- key: key_3
137
- }) => queryClient.getQueryData(key_3));
138
- useEffect(() => {
139
- if (skipped) {
140
- return;
141
- }
142
- const next = rebalance(pages, pageResults);
143
- if (next) {
144
- setPages(next);
145
- }
146
- });
147
- const {
148
- status
149
- } = derivePaginationStatus(skipped, pageResults);
150
- const loadMore = useCallback((numberItems) => {
151
- setPages((current) => {
152
- const desired_0 = desiredRef.current;
153
- const results = current.map((page_0) => {
154
- const pageArgs_0 = {
155
- ...desired_0.baseArgs,
156
- paginationOpts: {
157
- cursor: page_0.lower,
158
- endCursor: page_0.upper,
159
- numItems: page_0.numItems
160
- }
161
- };
162
- return queryClient.getQueryData(lunoraQueryKey(desired_0.fn, pageArgs_0, desired_0.shardKey));
163
- });
164
- const {
165
- nextCursor,
166
- status: liveStatus
167
- } = derivePaginationStatus(false, results);
168
- const cursor = liveStatus === "CanLoadMore" ? nextCursor : void 0;
169
- return applyLoadMore(current, cursor, numberItems) ?? current;
170
- });
171
- }, [queryClient]);
172
- return {
173
- loadMore,
174
- pageResults,
175
- status
176
- };
177
- };
178
-
179
- export { usePaginatedCore as u };
@@ -1,101 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useMutation } from './useMutation-BeqeIjTr.mjs';
4
- import useSubscription from './useSubscription-D38Jdyr8.mjs';
5
-
6
- const NO_MUTATION_REF = {
7
- __lunoraRef: ""
8
- };
9
- const useAgent = (options) => {
10
- const $ = c(17);
11
- const {
12
- api,
13
- cancel: cancelReference,
14
- run: runReference,
15
- runArgs,
16
- threadKey
17
- } = options;
18
- const runMutation = useMutation(runReference);
19
- const cancelMutation = useMutation(cancelReference ?? NO_MUTATION_REF);
20
- let t0;
21
- if ($[0] !== threadKey) {
22
- t0 = {
23
- key: threadKey
24
- };
25
- $[0] = threadKey;
26
- $[1] = t0;
27
- } else {
28
- t0 = $[1];
29
- }
30
- const {
31
- data: threadData
32
- } = useSubscription(api.agents.agentThread, t0);
33
- const thread = threadData;
34
- const status = thread?.status;
35
- const instanceId = thread?.instanceId;
36
- const {
37
- mutate: runMutate
38
- } = runMutation;
39
- const {
40
- mutate: cancelMutate
41
- } = cancelMutation;
42
- let t1;
43
- if ($[2] !== runArgs || $[3] !== runMutate || $[4] !== threadKey) {
44
- t1 = async (input, args) => {
45
- await runMutate({
46
- input,
47
- threadKey,
48
- ...runArgs,
49
- ...args
50
- });
51
- };
52
- $[2] = runArgs;
53
- $[3] = runMutate;
54
- $[4] = threadKey;
55
- $[5] = t1;
56
- } else {
57
- t1 = $[5];
58
- }
59
- const run = t1;
60
- let t2;
61
- if ($[6] !== cancelMutate || $[7] !== cancelReference || $[8] !== instanceId || $[9] !== threadKey) {
62
- t2 = async () => {
63
- if (cancelReference === void 0 || instanceId === void 0) {
64
- return;
65
- }
66
- await cancelMutate({
67
- instanceId,
68
- threadKey
69
- });
70
- };
71
- $[6] = cancelMutate;
72
- $[7] = cancelReference;
73
- $[8] = instanceId;
74
- $[9] = threadKey;
75
- $[10] = t2;
76
- } else {
77
- t2 = $[10];
78
- }
79
- const cancel = t2;
80
- let t3;
81
- if ($[11] !== cancel || $[12] !== run || $[13] !== runMutation.pending || $[14] !== status || $[15] !== thread) {
82
- t3 = {
83
- cancel,
84
- pending: runMutation.pending,
85
- run,
86
- status,
87
- thread
88
- };
89
- $[11] = cancel;
90
- $[12] = run;
91
- $[13] = runMutation.pending;
92
- $[14] = status;
93
- $[15] = thread;
94
- $[16] = t3;
95
- } else {
96
- t3 = $[16];
97
- }
98
- return t3;
99
- };
100
-
101
- export { useAgent };