@rozenite/tanstack-query-plugin 2.0.0 → 2.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.
@@ -32,17 +32,10 @@ type CursorState = {
32
32
  };
33
33
 
34
34
  const isPlainObject = (value: unknown): value is Record<string, unknown> => {
35
- return (
36
- !!value &&
37
- typeof value === 'object' &&
38
- Object.getPrototypeOf(value) === Object.prototype
39
- );
35
+ return !!value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype;
40
36
  };
41
37
 
42
- export const serializeForAgent = (
43
- value: unknown,
44
- seen = new WeakSet<object>(),
45
- ): AgentSafeValue => {
38
+ export const serializeForAgent = (value: unknown, seen = new WeakSet<object>()): AgentSafeValue => {
46
39
  if (value == null) {
47
40
  return null;
48
41
  }
@@ -72,10 +65,7 @@ export const serializeForAgent = (
72
65
  name: value.name,
73
66
  message: value.message,
74
67
  stack: value.stack ?? null,
75
- cause: serializeForAgent(
76
- (value as Error & { cause?: unknown }).cause,
77
- seen,
78
- ),
68
+ cause: serializeForAgent((value as Error & { cause?: unknown }).cause, seen),
79
69
  };
80
70
  }
81
71
 
@@ -128,33 +118,21 @@ const sanitizeLimit = (limit?: number) => {
128
118
  return Math.min(limit, MAX_PAGE_LIMIT);
129
119
  };
130
120
 
131
- const encodeCursor = (
132
- kind: CursorKind,
133
- generation: number,
134
- offset: number,
135
- ): string => {
121
+ const encodeCursor = (kind: CursorKind, generation: number, offset: number): string => {
136
122
  return `${kind}:${generation}:${offset}`;
137
123
  };
138
124
 
139
- const decodeCursor = (
140
- cursor: string,
141
- kind: CursorKind,
142
- generation: number,
143
- ): number => {
125
+ const decodeCursor = (cursor: string, kind: CursorKind, generation: number): number => {
144
126
  const [cursorKind, rawGeneration, rawOffset] = cursor.split(':', 3);
145
127
  if (cursorKind !== kind || !rawGeneration || !rawOffset) {
146
- throw new Error(
147
- 'Cursor does not match the requested listing. Run the command again.',
148
- );
128
+ throw new Error('Cursor does not match the requested listing. Run the command again.');
149
129
  }
150
130
 
151
131
  const cursorGeneration = Number(rawGeneration);
152
132
  const offset = Number(rawOffset);
153
133
 
154
134
  if (!Number.isInteger(cursorGeneration) || cursorGeneration !== generation) {
155
- throw new Error(
156
- 'Cursor does not match the requested listing. Run the command again.',
157
- );
135
+ throw new Error('Cursor does not match the requested listing. Run the command again.');
158
136
  }
159
137
 
160
138
  if (!Number.isInteger(offset) || offset < 0) {
@@ -164,16 +142,9 @@ const decodeCursor = (
164
142
  return offset;
165
143
  };
166
144
 
167
- const paginate = <T>(
168
- rows: T[],
169
- kind: CursorKind,
170
- generation: number,
171
- input: PaginationInput,
172
- ) => {
145
+ const paginate = <T>(rows: T[], kind: CursorKind, generation: number, input: PaginationInput) => {
173
146
  const limit = sanitizeLimit(input.limit);
174
- const startIndex = input.cursor
175
- ? decodeCursor(input.cursor, kind, generation)
176
- : 0;
147
+ const startIndex = input.cursor ? decodeCursor(input.cursor, kind, generation) : 0;
177
148
  const endIndex = Math.min(startIndex + limit, rows.length);
178
149
  const hasMore = endIndex < rows.length;
179
150
 
@@ -182,9 +153,7 @@ const paginate = <T>(
182
153
  page: {
183
154
  limit,
184
155
  hasMore,
185
- ...(hasMore
186
- ? { nextCursor: encodeCursor(kind, generation, endIndex) }
187
- : {}),
156
+ ...(hasMore ? { nextCursor: encodeCursor(kind, generation, endIndex) } : {}),
188
157
  },
189
158
  };
190
159
  };
@@ -202,13 +171,9 @@ export const resetQueryTool = tanstackQueryToolDefinitions.resetQuery;
202
171
  export const removeQueryTool = tanstackQueryToolDefinitions.removeQuery;
203
172
  export const clearQueryCacheTool = tanstackQueryToolDefinitions.clearQueryCache;
204
173
  export const listMutationsTool = tanstackQueryToolDefinitions.listMutations;
205
- export const getMutationDetailsTool =
206
- tanstackQueryToolDefinitions.getMutationDetails;
207
- export const clearMutationCacheTool =
208
- tanstackQueryToolDefinitions.clearMutationCache;
209
- export const TANSTACK_QUERY_AGENT_TOOLS = Object.values(
210
- tanstackQueryToolDefinitions,
211
- );
174
+ export const getMutationDetailsTool = tanstackQueryToolDefinitions.getMutationDetails;
175
+ export const clearMutationCacheTool = tanstackQueryToolDefinitions.clearMutationCache;
176
+ export const TANSTACK_QUERY_AGENT_TOOLS = Object.values(tanstackQueryToolDefinitions);
212
177
 
213
178
  const pickObserverOptionsSummary = (
214
179
  options: Record<string, unknown> | undefined,
@@ -272,9 +237,7 @@ const compareMutations = (
272
237
  a: Mutation<unknown, Error, unknown, unknown>,
273
238
  b: Mutation<unknown, Error, unknown, unknown>,
274
239
  ) => {
275
- return (
276
- b.state.submittedAt - a.state.submittedAt || b.mutationId - a.mutationId
277
- );
240
+ return b.state.submittedAt - a.state.submittedAt || b.mutationId - a.mutationId;
278
241
  };
279
242
 
280
243
  const getQuerySummary = (query: Query) => {
@@ -292,15 +255,11 @@ const getQuerySummary = (query: Query) => {
292
255
  };
293
256
  };
294
257
 
295
- const getMutationStatus = (
296
- state: MutationState<unknown, Error, unknown, unknown>,
297
- ) => {
258
+ const getMutationStatus = (state: MutationState<unknown, Error, unknown, unknown>) => {
298
259
  return state.status;
299
260
  };
300
261
 
301
- const getMutationSummary = (
302
- mutation: Mutation<unknown, Error, unknown, unknown>,
303
- ) => {
262
+ const getMutationSummary = (mutation: Mutation<unknown, Error, unknown, unknown>) => {
304
263
  return {
305
264
  mutationId: mutation.mutationId,
306
265
  mutationKey: serializeForAgent(mutation.options.mutationKey),
@@ -321,9 +280,7 @@ const resolveQuery = (queryClient: QueryClient, queryHash: string) => {
321
280
  .getAll()
322
281
  .map((entry) => entry.queryHash)
323
282
  .join(', ');
324
- throw new Error(
325
- `Unknown queryHash "${queryHash}". Available: ${available || '(none)'}`,
326
- );
283
+ throw new Error(`Unknown queryHash "${queryHash}". Available: ${available || '(none)'}`);
327
284
  }
328
285
 
329
286
  return query;
@@ -341,9 +298,7 @@ const resolveMutation = (queryClient: QueryClient, mutationId: number) => {
341
298
  .getAll()
342
299
  .map((entry) => entry.mutationId)
343
300
  .join(', ');
344
- throw new Error(
345
- `Unknown mutationId "${mutationId}". Available: ${available || '(none)'}`,
346
- );
301
+ throw new Error(`Unknown mutationId "${mutationId}". Available: ${available || '(none)'}`);
347
302
  }
348
303
 
349
304
  return mutation;
@@ -358,34 +313,23 @@ export const buildTanStackQueryCacheSummary = (queryClient: QueryClient) => {
358
313
  queries: {
359
314
  total: queries.length,
360
315
  active: queries.filter((query) => query.getObserversCount() > 0).length,
361
- fetching: queries.filter(
362
- (query) => query.state.fetchStatus === 'fetching',
363
- ).length,
364
- pending: queries.filter((query) => query.state.status === 'pending')
365
- .length,
366
- success: queries.filter((query) => query.state.status === 'success')
367
- .length,
316
+ fetching: queries.filter((query) => query.state.fetchStatus === 'fetching').length,
317
+ pending: queries.filter((query) => query.state.status === 'pending').length,
318
+ success: queries.filter((query) => query.state.status === 'success').length,
368
319
  error: queries.filter((query) => query.state.status === 'error').length,
369
320
  invalidated: queries.filter((query) => query.state.isInvalidated).length,
370
321
  },
371
322
  mutations: {
372
323
  total: mutations.length,
373
- pending: mutations.filter(
374
- (mutation) => mutation.state.status === 'pending',
375
- ).length,
376
- success: mutations.filter(
377
- (mutation) => mutation.state.status === 'success',
378
- ).length,
379
- error: mutations.filter((mutation) => mutation.state.status === 'error')
380
- .length,
324
+ pending: mutations.filter((mutation) => mutation.state.status === 'pending').length,
325
+ success: mutations.filter((mutation) => mutation.state.status === 'success').length,
326
+ error: mutations.filter((mutation) => mutation.state.status === 'error').length,
381
327
  paused: mutations.filter((mutation) => mutation.state.isPaused).length,
382
328
  },
383
329
  };
384
330
  };
385
331
 
386
- export const createTanStackQueryAgentController = (
387
- queryClient: QueryClient,
388
- ) => {
332
+ export const createTanStackQueryAgentController = (queryClient: QueryClient) => {
389
333
  const cursorState: CursorState = {
390
334
  queriesGeneration: 0,
391
335
  mutationsGeneration: 0,
@@ -422,18 +366,11 @@ export const createTanStackQueryAgentController = (
422
366
  },
423
367
 
424
368
  listQueries(input: PaginationInput = {}) {
425
- const queries = [...queryClient.getQueryCache().getAll()].sort(
426
- compareQueries,
427
- );
369
+ const queries = [...queryClient.getQueryCache().getAll()].sort(compareQueries);
428
370
  return {
429
371
  ...buildTanStackQueryCacheSummary(queryClient),
430
372
  total: queries.length,
431
- ...paginate(
432
- queries.map(getQuerySummary),
433
- 'queries',
434
- cursorState.queriesGeneration,
435
- input,
436
- ),
373
+ ...paginate(queries.map(getQuerySummary), 'queries', cursorState.queriesGeneration, input),
437
374
  };
438
375
  },
439
376
 
@@ -505,9 +442,7 @@ export const createTanStackQueryAgentController = (
505
442
  },
506
443
 
507
444
  listMutations(input: PaginationInput = {}) {
508
- const mutations = [...queryClient.getMutationCache().getAll()].sort(
509
- compareMutations,
510
- );
445
+ const mutations = [...queryClient.getMutationCache().getAll()].sort(compareMutations);
511
446
 
512
447
  return {
513
448
  ...buildTanStackQueryCacheSummary(queryClient),
@@ -546,6 +481,4 @@ export const createTanStackQueryAgentController = (
546
481
  };
547
482
  };
548
483
 
549
- export type TanStackQueryAgentController = ReturnType<
550
- typeof createTanStackQueryAgentController
551
- >;
484
+ export type TanStackQueryAgentController = ReturnType<typeof createTanStackQueryAgentController>;
@@ -8,10 +8,7 @@ import {
8
8
  } from '../../shared/agent-tools';
9
9
 
10
10
  export const useTanStackQueryAgentTools = (queryClient: QueryClient) => {
11
- const controller = useMemo(
12
- () => createTanStackQueryAgentController(queryClient),
13
- [queryClient],
14
- );
11
+ const controller = useMemo(() => createTanStackQueryAgentController(queryClient), [queryClient]);
15
12
 
16
13
  useEffect(() => {
17
14
  const unsubscribeQueryCache = queryClient
@@ -2,10 +2,7 @@ import { QueryClient } from '@tanstack/react-query';
2
2
  import { DevToolsActionType } from '../shared/types';
3
3
 
4
4
  type QueryScopedActionInput = {
5
- type: Exclude<
6
- DevToolsActionType,
7
- 'CLEAR_MUTATION_CACHE' | 'CLEAR_QUERY_CACHE'
8
- >;
5
+ type: Exclude<DevToolsActionType, 'CLEAR_MUTATION_CACHE' | 'CLEAR_QUERY_CACHE'>;
9
6
  queryHash: string;
10
7
  metadata?: {
11
8
  data?: unknown;
@@ -17,9 +14,7 @@ type CacheScopedActionInput = {
17
14
  queryHash?: string;
18
15
  };
19
16
 
20
- export type TanStackQueryDevtoolsActionInput =
21
- | QueryScopedActionInput
22
- | CacheScopedActionInput;
17
+ export type TanStackQueryDevtoolsActionInput = QueryScopedActionInput | CacheScopedActionInput;
23
18
 
24
19
  const getActiveQuery = (queryClient: QueryClient, queryHash?: string) => {
25
20
  if (!queryHash) {
@@ -52,9 +47,7 @@ export const applyTanStackQueryDevtoolsAction = async (
52
47
  }
53
48
 
54
49
  case 'CLEAR_MUTATION_CACHE': {
55
- const mutationCountBefore = queryClient
56
- .getMutationCache()
57
- .getAll().length;
50
+ const mutationCountBefore = queryClient.getMutationCache().getAll().length;
58
51
  queryClient.getMutationCache().clear();
59
52
  return {
60
53
  applied: true,
@@ -12,22 +12,18 @@ export const useHandleDevToolsMessages = (
12
12
  return;
13
13
  }
14
14
 
15
- const subscription = client.onMessage(
16
- 'devtools-action',
17
- ({ type, queryHash, metadata }) => {
18
- void applyTanStackQueryDevtoolsAction(queryClient, {
19
- type,
20
- queryHash,
21
- metadata,
22
- }).catch((error) => {
23
- const message =
24
- error instanceof Error ? error.message : String(error);
25
- console.warn(
26
- `[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${type}": ${message}`,
27
- );
28
- });
29
- },
30
- );
15
+ const subscription = client.onMessage('devtools-action', ({ type, queryHash, metadata }) => {
16
+ void applyTanStackQueryDevtoolsAction(queryClient, {
17
+ type,
18
+ queryHash,
19
+ metadata,
20
+ }).catch((error) => {
21
+ const message = error instanceof Error ? error.message : String(error);
22
+ console.warn(
23
+ `[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${type}": ${message}`,
24
+ );
25
+ });
26
+ });
31
27
 
32
28
  return () => {
33
29
  subscription.remove();
@@ -17,6 +17,13 @@ export const useHandleInitialData = (
17
17
  client.send('sync-data', { data: dehydratedState });
18
18
  });
19
19
 
20
+ // This hook runs last in `useTanStackQueryDevTools`, so by the time the
21
+ // panel reacts to this every handler is listening. The panel is recreated on
22
+ // every app reload and asks for the cache as soon as it boots, which usually
23
+ // beats the app's React tree to the punch; without this its only request is
24
+ // dropped and the panel stays empty until the app is restarted.
25
+ client.send('device-ready', {});
26
+
20
27
  return () => {
21
28
  subscription.remove();
22
29
  };
@@ -6,20 +6,14 @@ import {
6
6
  import { useEffect, useMemo, useRef } from 'react';
7
7
  import equal from 'fast-deep-equal';
8
8
  import { TanStackQueryPluginClient } from '../shared/messaging';
9
- import {
10
- dehydrateQuery,
11
- dehydrateMutation,
12
- dehydrateObservers,
13
- } from '../shared/dehydrate';
9
+ import { dehydrateQuery, dehydrateMutation, dehydrateObservers } from '../shared/dehydrate';
14
10
  import { SerializableObserver, PartialQueryState } from '../shared/types';
15
11
 
16
12
  export const useSyncTanStackCache = (
17
13
  queryClient: QueryClient,
18
14
  client: TanStackQueryPluginClient | null,
19
15
  ) => {
20
- const previousObserversRef = useRef<Map<string, SerializableObserver[]>>(
21
- new Map(),
22
- );
16
+ const previousObserversRef = useRef<Map<string, SerializableObserver[]>>(new Map());
23
17
 
24
18
  const handler = useMemo(() => {
25
19
  return (event: QueryCacheNotifyEvent | MutationCacheNotifyEvent): void => {
@@ -187,9 +181,7 @@ export const useSyncTanStackCache = (
187
181
  type === 'observerOptionsUpdated'
188
182
  ) {
189
183
  const dehydratedObservers = dehydrateObservers(query);
190
- const previousObservers = previousObserversRef.current.get(
191
- query.queryHash,
192
- );
184
+ const previousObservers = previousObserversRef.current.get(query.queryHash);
193
185
 
194
186
  // For observerOptionsUpdated, only send if the observers actually changed
195
187
  if (type === 'observerOptionsUpdated' && previousObservers) {
@@ -199,10 +191,7 @@ export const useSyncTanStackCache = (
199
191
  }
200
192
  }
201
193
 
202
- previousObserversRef.current.set(
203
- query.queryHash,
204
- dehydratedObservers,
205
- );
194
+ previousObserversRef.current.set(query.queryHash, dehydratedObservers);
206
195
 
207
196
  client.send('sync-query-event', {
208
197
  type,
@@ -231,12 +220,8 @@ export const useSyncTanStackCache = (
231
220
  return;
232
221
  }
233
222
 
234
- const mutationCacheSubscription = queryClient
235
- .getMutationCache()
236
- .subscribe(handler);
237
- const queryCacheSubscription = queryClient
238
- .getQueryCache()
239
- .subscribe(handler);
223
+ const mutationCacheSubscription = queryClient.getMutationCache().subscribe(handler);
224
+ const queryCacheSubscription = queryClient.getQueryCache().subscribe(handler);
240
225
 
241
226
  return () => {
242
227
  mutationCacheSubscription();
@@ -4,11 +4,7 @@ import {
4
4
  type AgentToolContract,
5
5
  type JSONSchema7,
6
6
  } from '@rozenite/agent-shared';
7
- import type {
8
- FetchStatus,
9
- MutationStatus,
10
- QueryStatus,
11
- } from '@tanstack/react-query';
7
+ import type { FetchStatus, MutationStatus, QueryStatus } from '@tanstack/react-query';
12
8
  import type { applyTanStackQueryDevtoolsAction } from '../react-native/devtools-actions';
13
9
 
14
10
  export const TANSTACK_QUERY_AGENT_PLUGIN_ID = '@rozenite/tanstack-query-plugin';
@@ -22,10 +18,9 @@ export type TanStackQueryAgentQueryHashInput = {
22
18
  queryHash: string;
23
19
  };
24
20
 
25
- export type TanStackQueryAgentQueryToggleInput =
26
- TanStackQueryAgentQueryHashInput & {
27
- enabled: boolean;
28
- };
21
+ export type TanStackQueryAgentQueryToggleInput = TanStackQueryAgentQueryHashInput & {
22
+ enabled: boolean;
23
+ };
29
24
 
30
25
  export type TanStackQueryAgentMutationIdInput = {
31
26
  mutationId: number;
@@ -171,14 +166,12 @@ export type TanStackQueryGetCacheSummaryArgs = undefined;
171
166
  export type TanStackQueryGetCacheSummaryResult = TanStackQueryCacheSummary;
172
167
  export type TanStackQueryGetOnlineStatusArgs = undefined;
173
168
  export type TanStackQueryGetOnlineStatusResult = { online: boolean };
174
- export type TanStackQuerySetOnlineStatusArgs =
175
- TanStackQueryAgentOnlineStatusInput;
169
+ export type TanStackQuerySetOnlineStatusArgs = TanStackQueryAgentOnlineStatusInput;
176
170
  export type TanStackQuerySetOnlineStatusResult = { online: boolean };
177
171
  export type TanStackQueryListQueriesArgs = TanStackQueryAgentPaginationInput;
178
172
  export type TanStackQueryGetQueryDetailsArgs = TanStackQueryAgentQueryHashInput;
179
173
  export type TanStackQueryRefetchQueryArgs = TanStackQueryAgentQueryHashInput;
180
- export type TanStackQuerySetQueryLoadingArgs =
181
- TanStackQueryAgentQueryToggleInput;
174
+ export type TanStackQuerySetQueryLoadingArgs = TanStackQueryAgentQueryToggleInput;
182
175
  export type TanStackQuerySetQueryErrorArgs = TanStackQueryAgentQueryToggleInput;
183
176
  export type TanStackQueryInvalidateQueryArgs = TanStackQueryAgentQueryHashInput;
184
177
  export type TanStackQueryResetQueryArgs = TanStackQueryAgentQueryHashInput;
@@ -186,8 +179,7 @@ export type TanStackQueryRemoveQueryArgs = TanStackQueryAgentQueryHashInput;
186
179
  export type TanStackQueryClearQueryCacheArgs = undefined;
187
180
  export type TanStackQueryClearQueryCacheResult = TanStackQueryActionResult;
188
181
  export type TanStackQueryListMutationsArgs = TanStackQueryAgentPaginationInput;
189
- export type TanStackQueryGetMutationDetailsArgs =
190
- TanStackQueryAgentMutationIdInput;
182
+ export type TanStackQueryGetMutationDetailsArgs = TanStackQueryAgentMutationIdInput;
191
183
  export type TanStackQueryClearMutationCacheArgs = undefined;
192
184
  export type TanStackQueryClearMutationCacheResult = TanStackQueryActionResult;
193
185
 
@@ -208,8 +200,7 @@ const mutationActionProperties = {
208
200
  const paginationProperties = {
209
201
  limit: {
210
202
  type: 'number',
211
- description:
212
- 'Maximum number of items to return. Defaults to 20. Maximum 100.',
203
+ description: 'Maximum number of items to return. Defaults to 20. Maximum 100.',
213
204
  },
214
205
  cursor: {
215
206
  type: 'string',
@@ -228,8 +219,7 @@ export const tanstackQueryToolDefinitions = {
228
219
  TanStackQueryGetCacheSummaryResult
229
220
  >({
230
221
  name: 'get-cache-summary',
231
- description:
232
- 'Return aggregate TanStack Query cache health and count information.',
222
+ description: 'Return aggregate TanStack Query cache health and count information.',
233
223
  inputSchema: emptyInputSchema,
234
224
  }),
235
225
  getOnlineStatus: defineAgentToolContract<
@@ -245,15 +235,13 @@ export const tanstackQueryToolDefinitions = {
245
235
  TanStackQuerySetOnlineStatusResult
246
236
  >({
247
237
  name: 'set-online-status',
248
- description:
249
- 'Set the TanStack Query onlineManager status for testing offline/online behavior.',
238
+ description: 'Set the TanStack Query onlineManager status for testing offline/online behavior.',
250
239
  inputSchema: {
251
240
  type: 'object',
252
241
  properties: {
253
242
  online: {
254
243
  type: 'boolean',
255
- description:
256
- 'Whether the TanStack Query onlineManager should be online.',
244
+ description: 'Whether the TanStack Query onlineManager should be online.',
257
245
  },
258
246
  },
259
247
  required: ['online'],
@@ -283,13 +271,7 @@ export const tanstackQueryToolDefinitions = {
283
271
  'hasData',
284
272
  'hasError',
285
273
  ],
286
- defaultFields: [
287
- 'queryHash',
288
- 'queryKey',
289
- 'status',
290
- 'fetchStatus',
291
- 'hasError',
292
- ],
274
+ defaultFields: ['queryHash', 'queryKey', 'status', 'fetchStatus', 'hasError'],
293
275
  },
294
276
  }),
295
277
  getQueryDetails: defineAgentToolContract<
@@ -297,18 +279,14 @@ export const tanstackQueryToolDefinitions = {
297
279
  TanStackQueryGetQueryDetailsResult
298
280
  >({
299
281
  name: 'get-query-details',
300
- description:
301
- 'Return a JSON-safe TanStack Query query snapshot and observer summary.',
282
+ description: 'Return a JSON-safe TanStack Query query snapshot and observer summary.',
302
283
  inputSchema: {
303
284
  type: 'object',
304
285
  properties: queryActionProperties,
305
286
  required: ['queryHash'],
306
287
  },
307
288
  }),
308
- refetchQuery: defineAgentToolContract<
309
- TanStackQueryRefetchQueryArgs,
310
- TanStackQueryActionResult
311
- >({
289
+ refetchQuery: defineAgentToolContract<TanStackQueryRefetchQueryArgs, TanStackQueryActionResult>({
312
290
  name: 'refetch-query',
313
291
  description: 'Refetch a TanStack Query query by queryHash.',
314
292
  inputSchema: {
@@ -330,32 +308,30 @@ export const tanstackQueryToolDefinitions = {
330
308
  ...queryActionProperties,
331
309
  enabled: {
332
310
  type: 'boolean',
333
- description:
334
- 'Whether the loading-state simulation should be enabled.',
311
+ description: 'Whether the loading-state simulation should be enabled.',
335
312
  },
336
313
  },
337
314
  required: ['queryHash', 'enabled'],
338
315
  },
339
316
  }),
340
- setQueryError: defineAgentToolContract<
341
- TanStackQuerySetQueryErrorArgs,
342
- TanStackQueryActionResult
343
- >({
344
- name: 'set-query-error',
345
- description:
346
- 'Enable or disable TanStack Query error-state simulation for a query by queryHash.',
347
- inputSchema: {
348
- type: 'object',
349
- properties: {
350
- ...queryActionProperties,
351
- enabled: {
352
- type: 'boolean',
353
- description: 'Whether the error-state simulation should be enabled.',
317
+ setQueryError: defineAgentToolContract<TanStackQuerySetQueryErrorArgs, TanStackQueryActionResult>(
318
+ {
319
+ name: 'set-query-error',
320
+ description:
321
+ 'Enable or disable TanStack Query error-state simulation for a query by queryHash.',
322
+ inputSchema: {
323
+ type: 'object',
324
+ properties: {
325
+ ...queryActionProperties,
326
+ enabled: {
327
+ type: 'boolean',
328
+ description: 'Whether the error-state simulation should be enabled.',
329
+ },
354
330
  },
331
+ required: ['queryHash', 'enabled'],
355
332
  },
356
- required: ['queryHash', 'enabled'],
357
333
  },
358
- }),
334
+ ),
359
335
  invalidateQuery: defineAgentToolContract<
360
336
  TanStackQueryInvalidateQueryArgs,
361
337
  TanStackQueryActionResult
@@ -368,10 +344,7 @@ export const tanstackQueryToolDefinitions = {
368
344
  required: ['queryHash'],
369
345
  },
370
346
  }),
371
- resetQuery: defineAgentToolContract<
372
- TanStackQueryResetQueryArgs,
373
- TanStackQueryActionResult
374
- >({
347
+ resetQuery: defineAgentToolContract<TanStackQueryResetQueryArgs, TanStackQueryActionResult>({
375
348
  name: 'reset-query',
376
349
  description: 'Reset a TanStack Query query by queryHash.',
377
350
  inputSchema: {
@@ -380,10 +353,7 @@ export const tanstackQueryToolDefinitions = {
380
353
  required: ['queryHash'],
381
354
  },
382
355
  }),
383
- removeQuery: defineAgentToolContract<
384
- TanStackQueryRemoveQueryArgs,
385
- TanStackQueryActionResult
386
- >({
356
+ removeQuery: defineAgentToolContract<TanStackQueryRemoveQueryArgs, TanStackQueryActionResult>({
387
357
  name: 'remove-query',
388
358
  description: 'Remove a TanStack Query query from the cache by queryHash.',
389
359
  inputSchema: {
@@ -405,8 +375,7 @@ export const tanstackQueryToolDefinitions = {
405
375
  TanStackQueryListMutationsResult
406
376
  >({
407
377
  name: 'list-mutations',
408
- description:
409
- 'List TanStack Query mutation summaries using cursor pagination.',
378
+ description: 'List TanStack Query mutation summaries using cursor pagination.',
410
379
  inputSchema: {
411
380
  type: 'object',
412
381
  properties: paginationProperties,
@@ -431,8 +400,7 @@ export const tanstackQueryToolDefinitions = {
431
400
  TanStackQueryGetMutationDetailsResult
432
401
  >({
433
402
  name: 'get-mutation-details',
434
- description:
435
- 'Return a JSON-safe TanStack Query mutation snapshot for a mutationId.',
403
+ description: 'Return a JSON-safe TanStack Query mutation snapshot for a mutationId.',
436
404
  inputSchema: {
437
405
  type: 'object',
438
406
  properties: mutationActionProperties,
@@ -32,9 +32,7 @@ export const dehydrateMutation = (mutation: Mutation): SerializableMutation => {
32
32
  };
33
33
  };
34
34
 
35
- export const dehydrateQueryClient = (
36
- queryClient: QueryClient,
37
- ): SerializableQueryClient => {
35
+ export const dehydrateQueryClient = (queryClient: QueryClient): SerializableQueryClient => {
38
36
  return {
39
37
  queries: queryClient.getQueryCache().getAll().map(dehydrateQuery),
40
38
  mutations: queryClient.getMutationCache().getAll().map(dehydrateMutation),