@rozenite/tanstack-query-plugin 1.12.0 → 2.0.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@rozenite/agent-shared"),a="@rozenite/tanstack-query-plugin",t={queryHash:{type:"string",description:"TanStack Query queryHash identifying the query."}},o={mutationId:{type:"number",description:"TanStack Query mutationId identifying the mutation."}},r={limit:{type:"number",description:"Maximum number of items to return. Defaults to 20. Maximum 100."},cursor:{type:"string",description:"Opaque pagination cursor from a previous list call."}},n={type:"object",properties:{}},i={getCacheSummary:e.defineAgentToolContract({name:"get-cache-summary",description:"Return aggregate TanStack Query cache health and count information.",inputSchema:n}),getOnlineStatus:e.defineAgentToolContract({name:"get-online-status",description:"Return the current TanStack Query onlineManager status.",inputSchema:n}),setOnlineStatus:e.defineAgentToolContract({name:"set-online-status",description:"Set the TanStack Query onlineManager status for testing offline/online behavior.",inputSchema:{type:"object",properties:{online:{type:"boolean",description:"Whether the TanStack Query onlineManager should be online."}},required:["online"]}}),listQueries:e.defineAgentToolContract({name:"list-queries",description:"List TanStack Query query summaries using cursor pagination.",inputSchema:{type:"object",properties:r}}),getQueryDetails:e.defineAgentToolContract({name:"get-query-details",description:"Return a JSON-safe TanStack Query query snapshot and observer summary.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),refetchQuery:e.defineAgentToolContract({name:"refetch-query",description:"Refetch a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),setQueryLoading:e.defineAgentToolContract({name:"set-query-loading",description:"Enable or disable TanStack Query loading-state simulation for a query by queryHash.",inputSchema:{type:"object",properties:{...t,enabled:{type:"boolean",description:"Whether the loading-state simulation should be enabled."}},required:["queryHash","enabled"]}}),setQueryError:e.defineAgentToolContract({name:"set-query-error",description:"Enable or disable TanStack Query error-state simulation for a query by queryHash.",inputSchema:{type:"object",properties:{...t,enabled:{type:"boolean",description:"Whether the error-state simulation should be enabled."}},required:["queryHash","enabled"]}}),invalidateQuery:e.defineAgentToolContract({name:"invalidate-query",description:"Invalidate a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),resetQuery:e.defineAgentToolContract({name:"reset-query",description:"Reset a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),removeQuery:e.defineAgentToolContract({name:"remove-query",description:"Remove a TanStack Query query from the cache by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),clearQueryCache:e.defineAgentToolContract({name:"clear-query-cache",description:"Clear the full TanStack Query query cache.",inputSchema:n}),listMutations:e.defineAgentToolContract({name:"list-mutations",description:"List TanStack Query mutation summaries using cursor pagination.",inputSchema:{type:"object",properties:r}}),getMutationDetails:e.defineAgentToolContract({name:"get-mutation-details",description:"Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",inputSchema:{type:"object",properties:o,required:["mutationId"]}}),clearMutationCache:e.defineAgentToolContract({name:"clear-mutation-cache",description:"Clear the full TanStack Query mutation cache.",inputSchema:n})},u=e.defineAgentToolDescriptors(a,i);exports.TANSTACK_QUERY_AGENT_PLUGIN_ID=a;exports.tanstackQueryToolDefinitions=i;exports.tanstackQueryTools=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@rozenite/agent-shared"),n="@rozenite/tanstack-query-plugin",t={queryHash:{type:"string",description:"TanStack Query queryHash identifying the query."}},o={mutationId:{type:"number",description:"TanStack Query mutationId identifying the mutation."}},r={limit:{type:"number",description:"Maximum number of items to return. Defaults to 20. Maximum 100."},cursor:{type:"string",description:"Opaque pagination cursor from a previous list call."}},a={type:"object",properties:{}},i={getCacheSummary:e.defineAgentToolContract({name:"get-cache-summary",description:"Return aggregate TanStack Query cache health and count information.",inputSchema:a}),getOnlineStatus:e.defineAgentToolContract({name:"get-online-status",description:"Return the current TanStack Query onlineManager status.",inputSchema:a}),setOnlineStatus:e.defineAgentToolContract({name:"set-online-status",description:"Set the TanStack Query onlineManager status for testing offline/online behavior.",inputSchema:{type:"object",properties:{online:{type:"boolean",description:"Whether the TanStack Query onlineManager should be online."}},required:["online"]}}),listQueries:e.definePaginatedAgentToolContract({name:"list-queries",description:"List TanStack Query query summaries using cursor pagination.",inputSchema:{type:"object",properties:r},pagination:{kind:"cursor",fields:["queryHash","queryKey","status","fetchStatus","observersCount","isInvalidated","dataUpdatedAt","errorUpdatedAt","hasData","hasError"],defaultFields:["queryHash","queryKey","status","fetchStatus","hasError"]}}),getQueryDetails:e.defineAgentToolContract({name:"get-query-details",description:"Return a JSON-safe TanStack Query query snapshot and observer summary.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),refetchQuery:e.defineAgentToolContract({name:"refetch-query",description:"Refetch a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),setQueryLoading:e.defineAgentToolContract({name:"set-query-loading",description:"Enable or disable TanStack Query loading-state simulation for a query by queryHash.",inputSchema:{type:"object",properties:{...t,enabled:{type:"boolean",description:"Whether the loading-state simulation should be enabled."}},required:["queryHash","enabled"]}}),setQueryError:e.defineAgentToolContract({name:"set-query-error",description:"Enable or disable TanStack Query error-state simulation for a query by queryHash.",inputSchema:{type:"object",properties:{...t,enabled:{type:"boolean",description:"Whether the error-state simulation should be enabled."}},required:["queryHash","enabled"]}}),invalidateQuery:e.defineAgentToolContract({name:"invalidate-query",description:"Invalidate a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),resetQuery:e.defineAgentToolContract({name:"reset-query",description:"Reset a TanStack Query query by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),removeQuery:e.defineAgentToolContract({name:"remove-query",description:"Remove a TanStack Query query from the cache by queryHash.",inputSchema:{type:"object",properties:t,required:["queryHash"]}}),clearQueryCache:e.defineAgentToolContract({name:"clear-query-cache",description:"Clear the full TanStack Query query cache.",inputSchema:a}),listMutations:e.definePaginatedAgentToolContract({name:"list-mutations",description:"List TanStack Query mutation summaries using cursor pagination.",inputSchema:{type:"object",properties:r},pagination:{kind:"cursor",fields:["mutationId","mutationKey","status","isPaused","submittedAt","failureCount","hasData","hasError"],defaultFields:["mutationId","mutationKey","status","hasError"]}}),getMutationDetails:e.defineAgentToolContract({name:"get-mutation-details",description:"Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",inputSchema:{type:"object",properties:o,required:["mutationId"]}}),clearMutationCache:e.defineAgentToolContract({name:"clear-mutation-cache",description:"Clear the full TanStack Query mutation cache.",inputSchema:a})},u=e.defineAgentToolDescriptors(n,i);exports.TANSTACK_QUERY_AGENT_PLUGIN_ID=n;exports.tanstackQueryToolDefinitions=i;exports.tanstackQueryTools=u;
package/dist/sdk/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineAgentToolContract as e, defineAgentToolDescriptors as n } from "@rozenite/agent-shared";
2
- const i = "@rozenite/tanstack-query-plugin", t = {
1
+ import { defineAgentToolContract as e, definePaginatedAgentToolContract as r, defineAgentToolDescriptors as i } from "@rozenite/agent-shared";
2
+ const u = "@rozenite/tanstack-query-plugin", t = {
3
3
  queryHash: {
4
4
  type: "string",
5
5
  description: "TanStack Query queryHash identifying the query."
@@ -9,7 +9,7 @@ const i = "@rozenite/tanstack-query-plugin", t = {
9
9
  type: "number",
10
10
  description: "TanStack Query mutationId identifying the mutation."
11
11
  }
12
- }, a = {
12
+ }, n = {
13
13
  limit: {
14
14
  type: "number",
15
15
  description: "Maximum number of items to return. Defaults to 20. Maximum 100."
@@ -18,19 +18,19 @@ const i = "@rozenite/tanstack-query-plugin", t = {
18
18
  type: "string",
19
19
  description: "Opaque pagination cursor from a previous list call."
20
20
  }
21
- }, r = {
21
+ }, a = {
22
22
  type: "object",
23
23
  properties: {}
24
- }, u = {
24
+ }, s = {
25
25
  getCacheSummary: e({
26
26
  name: "get-cache-summary",
27
27
  description: "Return aggregate TanStack Query cache health and count information.",
28
- inputSchema: r
28
+ inputSchema: a
29
29
  }),
30
30
  getOnlineStatus: e({
31
31
  name: "get-online-status",
32
32
  description: "Return the current TanStack Query onlineManager status.",
33
- inputSchema: r
33
+ inputSchema: a
34
34
  }),
35
35
  setOnlineStatus: e({
36
36
  name: "set-online-status",
@@ -46,12 +46,34 @@ const i = "@rozenite/tanstack-query-plugin", t = {
46
46
  required: ["online"]
47
47
  }
48
48
  }),
49
- listQueries: e({
49
+ listQueries: r({
50
50
  name: "list-queries",
51
51
  description: "List TanStack Query query summaries using cursor pagination.",
52
52
  inputSchema: {
53
53
  type: "object",
54
- properties: a
54
+ properties: n
55
+ },
56
+ pagination: {
57
+ kind: "cursor",
58
+ fields: [
59
+ "queryHash",
60
+ "queryKey",
61
+ "status",
62
+ "fetchStatus",
63
+ "observersCount",
64
+ "isInvalidated",
65
+ "dataUpdatedAt",
66
+ "errorUpdatedAt",
67
+ "hasData",
68
+ "hasError"
69
+ ],
70
+ defaultFields: [
71
+ "queryHash",
72
+ "queryKey",
73
+ "status",
74
+ "fetchStatus",
75
+ "hasError"
76
+ ]
55
77
  }
56
78
  }),
57
79
  getQueryDetails: e({
@@ -132,14 +154,28 @@ const i = "@rozenite/tanstack-query-plugin", t = {
132
154
  clearQueryCache: e({
133
155
  name: "clear-query-cache",
134
156
  description: "Clear the full TanStack Query query cache.",
135
- inputSchema: r
157
+ inputSchema: a
136
158
  }),
137
- listMutations: e({
159
+ listMutations: r({
138
160
  name: "list-mutations",
139
161
  description: "List TanStack Query mutation summaries using cursor pagination.",
140
162
  inputSchema: {
141
163
  type: "object",
142
- properties: a
164
+ properties: n
165
+ },
166
+ pagination: {
167
+ kind: "cursor",
168
+ fields: [
169
+ "mutationId",
170
+ "mutationKey",
171
+ "status",
172
+ "isPaused",
173
+ "submittedAt",
174
+ "failureCount",
175
+ "hasData",
176
+ "hasError"
177
+ ],
178
+ defaultFields: ["mutationId", "mutationKey", "status", "hasError"]
143
179
  }
144
180
  }),
145
181
  getMutationDetails: e({
@@ -154,14 +190,14 @@ const i = "@rozenite/tanstack-query-plugin", t = {
154
190
  clearMutationCache: e({
155
191
  name: "clear-mutation-cache",
156
192
  description: "Clear the full TanStack Query mutation cache.",
157
- inputSchema: r
193
+ inputSchema: a
158
194
  })
159
- }, c = n(
160
- i,
161
- u
195
+ }, y = i(
196
+ u,
197
+ s
162
198
  );
163
199
  export {
164
- i as TANSTACK_QUERY_AGENT_PLUGIN_ID,
165
- u as tanstackQueryToolDefinitions,
166
- c as tanstackQueryTools
200
+ u as TANSTACK_QUERY_AGENT_PLUGIN_ID,
201
+ s as tanstackQueryToolDefinitions,
202
+ y as tanstackQueryTools
167
203
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozenite/tanstack-query-plugin",
3
- "version": "1.12.0",
3
+ "version": "2.0.0",
4
4
  "description": "TanStack Query for Rozenite.",
5
5
  "type": "module",
6
6
  "main": "./dist/react-native/index.cjs",
@@ -16,26 +16,22 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "fast-deep-equal": "^3.1.3",
19
- "@rozenite/agent-shared": "1.12.0",
20
- "@rozenite/agent-bridge": "1.12.0",
21
- "@rozenite/plugin-bridge": "1.12.0"
19
+ "@rozenite/agent-shared": "2.0.0",
20
+ "@rozenite/agent-bridge": "2.0.0",
21
+ "@rozenite/plugin-bridge": "2.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@tanstack/react-query": "^5.0.0",
25
25
  "@tanstack/react-query-devtools": "^5.0.0",
26
- "@types/react": "~19.2.2",
27
- "autoprefixer": "^10.4.21",
28
- "postcss": "^8.5.6",
29
- "react": "19.2.0",
30
- "react-dom": "19.2.0",
31
- "react-native": "0.83.1",
26
+ "@types/react": "~19.2.3",
27
+ "react": "19.2.3",
28
+ "react-dom": "19.2.3",
29
+ "react-native": "0.86.0",
32
30
  "react-native-web": "^0.21.2",
33
- "tailwindcss": "^3.4.17",
34
- "tailwindcss-animate": "^1.0.7",
35
31
  "typescript": "~5.9.3",
36
32
  "vite": "^7.3.1",
37
- "@rozenite/vite-plugin": "1.12.0",
38
- "rozenite": "1.12.0"
33
+ "@rozenite/vite-plugin": "2.0.0",
34
+ "rozenite": "2.0.0"
39
35
  },
40
36
  "peerDependencies": {
41
37
  "@tanstack/react-query": "^5.0.0",
package/sdk.ts CHANGED
@@ -4,10 +4,7 @@ import {
4
4
  tanstackQueryToolDefinitions,
5
5
  } from './src/shared/agent-tools.js';
6
6
 
7
- export {
8
- TANSTACK_QUERY_AGENT_PLUGIN_ID,
9
- tanstackQueryToolDefinitions,
10
- };
7
+ export { TANSTACK_QUERY_AGENT_PLUGIN_ID, tanstackQueryToolDefinitions };
11
8
 
12
9
  export const tanstackQueryTools = defineAgentToolDescriptors(
13
10
  TANSTACK_QUERY_AGENT_PLUGIN_ID,
@@ -106,10 +106,34 @@ describe('tanstack query agent controller', () => {
106
106
  'get-mutation-details',
107
107
  'clear-mutation-cache',
108
108
  ]);
109
- expect(tanstackQueryToolDefinitions.setQueryLoading.inputSchema.required).toEqual([
110
- 'queryHash',
111
- 'enabled',
112
- ]);
109
+ expect(
110
+ tanstackQueryToolDefinitions.setQueryLoading.inputSchema.required,
111
+ ).toEqual(['queryHash', 'enabled']);
112
+ expect(tanstackQueryToolDefinitions.listQueries.pagination).toMatchObject({
113
+ kind: 'cursor',
114
+ fields: expect.arrayContaining(['queryHash', 'status', 'fetchStatus']),
115
+ });
116
+ });
117
+
118
+ it('trims listQueries/listMutations defaultFields narrower than the full field set', () => {
119
+ const listQueriesPagination =
120
+ tanstackQueryToolDefinitions.listQueries.pagination;
121
+ const listMutationsPagination =
122
+ tanstackQueryToolDefinitions.listMutations.pagination;
123
+
124
+ expect(listQueriesPagination?.defaultFields?.length).toBeLessThan(
125
+ listQueriesPagination?.fields.length ?? 0,
126
+ );
127
+ for (const field of listQueriesPagination?.defaultFields ?? []) {
128
+ expect(listQueriesPagination?.fields).toContain(field);
129
+ }
130
+
131
+ expect(listMutationsPagination?.defaultFields?.length).toBeLessThan(
132
+ listMutationsPagination?.fields.length ?? 0,
133
+ );
134
+ for (const field of listMutationsPagination?.defaultFields ?? []) {
135
+ expect(listMutationsPagination?.fields).toContain(field);
136
+ }
113
137
  });
114
138
 
115
139
  it('lists queries with cursor pagination and invalidates stale cursors after additions', async () => {
@@ -41,7 +41,7 @@ const isPlainObject = (value: unknown): value is Record<string, unknown> => {
41
41
 
42
42
  export const serializeForAgent = (
43
43
  value: unknown,
44
- seen = new WeakSet<object>()
44
+ seen = new WeakSet<object>(),
45
45
  ): AgentSafeValue => {
46
46
  if (value == null) {
47
47
  return null;
@@ -74,7 +74,7 @@ export const serializeForAgent = (
74
74
  stack: value.stack ?? null,
75
75
  cause: serializeForAgent(
76
76
  (value as Error & { cause?: unknown }).cause,
77
- seen
77
+ seen,
78
78
  ),
79
79
  };
80
80
  }
@@ -85,7 +85,7 @@ export const serializeForAgent = (
85
85
 
86
86
  if (ArrayBuffer.isView(value)) {
87
87
  return Array.from(value as unknown as ArrayLike<number>).map((item) =>
88
- typeof item === 'number' ? item : Number(item)
88
+ typeof item === 'number' ? item : Number(item),
89
89
  );
90
90
  }
91
91
 
@@ -131,7 +131,7 @@ const sanitizeLimit = (limit?: number) => {
131
131
  const encodeCursor = (
132
132
  kind: CursorKind,
133
133
  generation: number,
134
- offset: number
134
+ offset: number,
135
135
  ): string => {
136
136
  return `${kind}:${generation}:${offset}`;
137
137
  };
@@ -139,12 +139,12 @@ const encodeCursor = (
139
139
  const decodeCursor = (
140
140
  cursor: string,
141
141
  kind: CursorKind,
142
- generation: number
142
+ generation: number,
143
143
  ): number => {
144
144
  const [cursorKind, rawGeneration, rawOffset] = cursor.split(':', 3);
145
145
  if (cursorKind !== kind || !rawGeneration || !rawOffset) {
146
146
  throw new Error(
147
- 'Cursor does not match the requested listing. Run the command again.'
147
+ 'Cursor does not match the requested listing. Run the command again.',
148
148
  );
149
149
  }
150
150
 
@@ -153,7 +153,7 @@ const decodeCursor = (
153
153
 
154
154
  if (!Number.isInteger(cursorGeneration) || cursorGeneration !== generation) {
155
155
  throw new Error(
156
- 'Cursor does not match the requested listing. Run the command again.'
156
+ 'Cursor does not match the requested listing. Run the command again.',
157
157
  );
158
158
  }
159
159
 
@@ -168,7 +168,7 @@ const paginate = <T>(
168
168
  rows: T[],
169
169
  kind: CursorKind,
170
170
  generation: number,
171
- input: PaginationInput
171
+ input: PaginationInput,
172
172
  ) => {
173
173
  const limit = sanitizeLimit(input.limit);
174
174
  const startIndex = input.cursor
@@ -211,7 +211,7 @@ export const TANSTACK_QUERY_AGENT_TOOLS = Object.values(
211
211
  );
212
212
 
213
213
  const pickObserverOptionsSummary = (
214
- options: Record<string, unknown> | undefined
214
+ options: Record<string, unknown> | undefined,
215
215
  ): TanStackQueryObserverOptionsSummary | null => {
216
216
  if (!options) {
217
217
  return null;
@@ -238,7 +238,7 @@ const pickObserverOptionsSummary = (
238
238
  };
239
239
 
240
240
  const pickMutationOptionsSummary = (
241
- options: MutationObserverOptions<unknown, Error, unknown, unknown>
241
+ options: MutationObserverOptions<unknown, Error, unknown, unknown>,
242
242
  ): TanStackQueryMutationOptionsSummary => {
243
243
  return {
244
244
  mutationKey: serializeForAgent(options.mutationKey),
@@ -270,11 +270,10 @@ const compareQueries = (a: Query, b: Query) => {
270
270
 
271
271
  const compareMutations = (
272
272
  a: Mutation<unknown, Error, unknown, unknown>,
273
- b: Mutation<unknown, Error, unknown, unknown>
273
+ b: Mutation<unknown, Error, unknown, unknown>,
274
274
  ) => {
275
275
  return (
276
- b.state.submittedAt - a.state.submittedAt ||
277
- b.mutationId - a.mutationId
276
+ b.state.submittedAt - a.state.submittedAt || b.mutationId - a.mutationId
278
277
  );
279
278
  };
280
279
 
@@ -294,13 +293,13 @@ const getQuerySummary = (query: Query) => {
294
293
  };
295
294
 
296
295
  const getMutationStatus = (
297
- state: MutationState<unknown, Error, unknown, unknown>
296
+ state: MutationState<unknown, Error, unknown, unknown>,
298
297
  ) => {
299
298
  return state.status;
300
299
  };
301
300
 
302
301
  const getMutationSummary = (
303
- mutation: Mutation<unknown, Error, unknown, unknown>
302
+ mutation: Mutation<unknown, Error, unknown, unknown>,
304
303
  ) => {
305
304
  return {
306
305
  mutationId: mutation.mutationId,
@@ -323,7 +322,7 @@ const resolveQuery = (queryClient: QueryClient, queryHash: string) => {
323
322
  .map((entry) => entry.queryHash)
324
323
  .join(', ');
325
324
  throw new Error(
326
- `Unknown queryHash "${queryHash}". Available: ${available || '(none)'}`
325
+ `Unknown queryHash "${queryHash}". Available: ${available || '(none)'}`,
327
326
  );
328
327
  }
329
328
 
@@ -343,7 +342,7 @@ const resolveMutation = (queryClient: QueryClient, mutationId: number) => {
343
342
  .map((entry) => entry.mutationId)
344
343
  .join(', ');
345
344
  throw new Error(
346
- `Unknown mutationId "${mutationId}". Available: ${available || '(none)'}`
345
+ `Unknown mutationId "${mutationId}". Available: ${available || '(none)'}`,
347
346
  );
348
347
  }
349
348
 
@@ -360,7 +359,7 @@ export const buildTanStackQueryCacheSummary = (queryClient: QueryClient) => {
360
359
  total: queries.length,
361
360
  active: queries.filter((query) => query.getObserversCount() > 0).length,
362
361
  fetching: queries.filter(
363
- (query) => query.state.fetchStatus === 'fetching'
362
+ (query) => query.state.fetchStatus === 'fetching',
364
363
  ).length,
365
364
  pending: queries.filter((query) => query.state.status === 'pending')
366
365
  .length,
@@ -372,10 +371,10 @@ export const buildTanStackQueryCacheSummary = (queryClient: QueryClient) => {
372
371
  mutations: {
373
372
  total: mutations.length,
374
373
  pending: mutations.filter(
375
- (mutation) => mutation.state.status === 'pending'
374
+ (mutation) => mutation.state.status === 'pending',
376
375
  ).length,
377
376
  success: mutations.filter(
378
- (mutation) => mutation.state.status === 'success'
377
+ (mutation) => mutation.state.status === 'success',
379
378
  ).length,
380
379
  error: mutations.filter((mutation) => mutation.state.status === 'error')
381
380
  .length,
@@ -384,7 +383,9 @@ export const buildTanStackQueryCacheSummary = (queryClient: QueryClient) => {
384
383
  };
385
384
  };
386
385
 
387
- export const createTanStackQueryAgentController = (queryClient: QueryClient) => {
386
+ export const createTanStackQueryAgentController = (
387
+ queryClient: QueryClient,
388
+ ) => {
388
389
  const cursorState: CursorState = {
389
390
  queriesGeneration: 0,
390
391
  mutationsGeneration: 0,
@@ -421,7 +422,9 @@ export const createTanStackQueryAgentController = (queryClient: QueryClient) =>
421
422
  },
422
423
 
423
424
  listQueries(input: PaginationInput = {}) {
424
- const queries = [...queryClient.getQueryCache().getAll()].sort(compareQueries);
425
+ const queries = [...queryClient.getQueryCache().getAll()].sort(
426
+ compareQueries,
427
+ );
425
428
  return {
426
429
  ...buildTanStackQueryCacheSummary(queryClient),
427
430
  total: queries.length,
@@ -429,7 +432,7 @@ export const createTanStackQueryAgentController = (queryClient: QueryClient) =>
429
432
  queries.map(getQuerySummary),
430
433
  'queries',
431
434
  cursorState.queriesGeneration,
432
- input
435
+ input,
433
436
  ),
434
437
  };
435
438
  },
@@ -446,7 +449,7 @@ export const createTanStackQueryAgentController = (queryClient: QueryClient) =>
446
449
  observers: query.observers.map((observer) => ({
447
450
  queryHash: query.queryHash,
448
451
  options: pickObserverOptionsSummary(
449
- observer.options as unknown as Record<string, unknown>
452
+ observer.options as unknown as Record<string, unknown>,
450
453
  ),
451
454
  })),
452
455
  },
@@ -503,7 +506,7 @@ export const createTanStackQueryAgentController = (queryClient: QueryClient) =>
503
506
 
504
507
  listMutations(input: PaginationInput = {}) {
505
508
  const mutations = [...queryClient.getMutationCache().getAll()].sort(
506
- compareMutations
509
+ compareMutations,
507
510
  );
508
511
 
509
512
  return {
@@ -513,7 +516,7 @@ export const createTanStackQueryAgentController = (queryClient: QueryClient) =>
513
516
  mutations.map(getMutationSummary),
514
517
  'mutations',
515
518
  cursorState.mutationsGeneration,
516
- input
519
+ input,
517
520
  ),
518
521
  };
519
522
  },
@@ -1,9 +1,7 @@
1
1
  import { useEffect, useMemo } from 'react';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
  import { useRozenitePluginAgentTool } from '@rozenite/agent-bridge';
4
- import {
5
- createTanStackQueryAgentController,
6
- } from './tanstack-query-agent';
4
+ import { createTanStackQueryAgentController } from './tanstack-query-agent';
7
5
  import {
8
6
  TANSTACK_QUERY_AGENT_PLUGIN_ID,
9
7
  tanstackQueryToolDefinitions,
@@ -12,7 +10,7 @@ import {
12
10
  export const useTanStackQueryAgentTools = (queryClient: QueryClient) => {
13
11
  const controller = useMemo(
14
12
  () => createTanStackQueryAgentController(queryClient),
15
- [queryClient]
13
+ [queryClient],
16
14
  );
17
15
 
18
16
  useEffect(() => {
@@ -5,7 +5,7 @@ import { dehydrateQueryClient } from '../shared/dehydrate';
5
5
 
6
6
  export const useHandleInitialData = (
7
7
  queryClient: QueryClient,
8
- client: TanStackQueryPluginClient | null
8
+ client: TanStackQueryPluginClient | null,
9
9
  ) => {
10
10
  useEffect(() => {
11
11
  if (!client) {
@@ -15,10 +15,10 @@ import { SerializableObserver, PartialQueryState } from '../shared/types';
15
15
 
16
16
  export const useSyncTanStackCache = (
17
17
  queryClient: QueryClient,
18
- client: TanStackQueryPluginClient | null
18
+ client: TanStackQueryPluginClient | null,
19
19
  ) => {
20
20
  const previousObserversRef = useRef<Map<string, SerializableObserver[]>>(
21
- new Map()
21
+ new Map(),
22
22
  );
23
23
 
24
24
  const handler = useMemo(() => {
@@ -188,7 +188,7 @@ export const useSyncTanStackCache = (
188
188
  ) {
189
189
  const dehydratedObservers = dehydrateObservers(query);
190
190
  const previousObservers = previousObserversRef.current.get(
191
- query.queryHash
191
+ query.queryHash,
192
192
  );
193
193
 
194
194
  // For observerOptionsUpdated, only send if the observers actually changed
@@ -201,7 +201,7 @@ export const useSyncTanStackCache = (
201
201
 
202
202
  previousObserversRef.current.set(
203
203
  query.queryHash,
204
- dehydratedObservers
204
+ dehydratedObservers,
205
205
  );
206
206
 
207
207
  client.send('sync-query-event', {
@@ -1,9 +1,14 @@
1
1
  import {
2
2
  defineAgentToolContract,
3
+ definePaginatedAgentToolContract,
3
4
  type AgentToolContract,
4
5
  type JSONSchema7,
5
6
  } from '@rozenite/agent-shared';
6
- import type { FetchStatus, MutationStatus, QueryStatus } from '@tanstack/react-query';
7
+ import type {
8
+ FetchStatus,
9
+ MutationStatus,
10
+ QueryStatus,
11
+ } from '@tanstack/react-query';
7
12
  import type { applyTanStackQueryDevtoolsAction } from '../react-native/devtools-actions';
8
13
 
9
14
  export const TANSTACK_QUERY_AGENT_PLUGIN_ID = '@rozenite/tanstack-query-plugin';
@@ -166,12 +171,14 @@ export type TanStackQueryGetCacheSummaryArgs = undefined;
166
171
  export type TanStackQueryGetCacheSummaryResult = TanStackQueryCacheSummary;
167
172
  export type TanStackQueryGetOnlineStatusArgs = undefined;
168
173
  export type TanStackQueryGetOnlineStatusResult = { online: boolean };
169
- export type TanStackQuerySetOnlineStatusArgs = TanStackQueryAgentOnlineStatusInput;
174
+ export type TanStackQuerySetOnlineStatusArgs =
175
+ TanStackQueryAgentOnlineStatusInput;
170
176
  export type TanStackQuerySetOnlineStatusResult = { online: boolean };
171
177
  export type TanStackQueryListQueriesArgs = TanStackQueryAgentPaginationInput;
172
178
  export type TanStackQueryGetQueryDetailsArgs = TanStackQueryAgentQueryHashInput;
173
179
  export type TanStackQueryRefetchQueryArgs = TanStackQueryAgentQueryHashInput;
174
- export type TanStackQuerySetQueryLoadingArgs = TanStackQueryAgentQueryToggleInput;
180
+ export type TanStackQuerySetQueryLoadingArgs =
181
+ TanStackQueryAgentQueryToggleInput;
175
182
  export type TanStackQuerySetQueryErrorArgs = TanStackQueryAgentQueryToggleInput;
176
183
  export type TanStackQueryInvalidateQueryArgs = TanStackQueryAgentQueryHashInput;
177
184
  export type TanStackQueryResetQueryArgs = TanStackQueryAgentQueryHashInput;
@@ -179,7 +186,8 @@ export type TanStackQueryRemoveQueryArgs = TanStackQueryAgentQueryHashInput;
179
186
  export type TanStackQueryClearQueryCacheArgs = undefined;
180
187
  export type TanStackQueryClearQueryCacheResult = TanStackQueryActionResult;
181
188
  export type TanStackQueryListMutationsArgs = TanStackQueryAgentPaginationInput;
182
- export type TanStackQueryGetMutationDetailsArgs = TanStackQueryAgentMutationIdInput;
189
+ export type TanStackQueryGetMutationDetailsArgs =
190
+ TanStackQueryAgentMutationIdInput;
183
191
  export type TanStackQueryClearMutationCacheArgs = undefined;
184
192
  export type TanStackQueryClearMutationCacheResult = TanStackQueryActionResult;
185
193
 
@@ -200,7 +208,8 @@ const mutationActionProperties = {
200
208
  const paginationProperties = {
201
209
  limit: {
202
210
  type: 'number',
203
- description: 'Maximum number of items to return. Defaults to 20. Maximum 100.',
211
+ description:
212
+ 'Maximum number of items to return. Defaults to 20. Maximum 100.',
204
213
  },
205
214
  cursor: {
206
215
  type: 'string',
@@ -243,13 +252,14 @@ export const tanstackQueryToolDefinitions = {
243
252
  properties: {
244
253
  online: {
245
254
  type: 'boolean',
246
- description: 'Whether the TanStack Query onlineManager should be online.',
255
+ description:
256
+ 'Whether the TanStack Query onlineManager should be online.',
247
257
  },
248
258
  },
249
259
  required: ['online'],
250
260
  },
251
261
  }),
252
- listQueries: defineAgentToolContract<
262
+ listQueries: definePaginatedAgentToolContract<
253
263
  TanStackQueryListQueriesArgs,
254
264
  TanStackQueryListQueriesResult
255
265
  >({
@@ -259,6 +269,28 @@ export const tanstackQueryToolDefinitions = {
259
269
  type: 'object',
260
270
  properties: paginationProperties,
261
271
  },
272
+ pagination: {
273
+ kind: 'cursor',
274
+ fields: [
275
+ 'queryHash',
276
+ 'queryKey',
277
+ 'status',
278
+ 'fetchStatus',
279
+ 'observersCount',
280
+ 'isInvalidated',
281
+ 'dataUpdatedAt',
282
+ 'errorUpdatedAt',
283
+ 'hasData',
284
+ 'hasError',
285
+ ],
286
+ defaultFields: [
287
+ 'queryHash',
288
+ 'queryKey',
289
+ 'status',
290
+ 'fetchStatus',
291
+ 'hasError',
292
+ ],
293
+ },
262
294
  }),
263
295
  getQueryDetails: defineAgentToolContract<
264
296
  TanStackQueryGetQueryDetailsArgs,
@@ -368,16 +400,31 @@ export const tanstackQueryToolDefinitions = {
368
400
  description: 'Clear the full TanStack Query query cache.',
369
401
  inputSchema: emptyInputSchema,
370
402
  }),
371
- listMutations: defineAgentToolContract<
403
+ listMutations: definePaginatedAgentToolContract<
372
404
  TanStackQueryListMutationsArgs,
373
405
  TanStackQueryListMutationsResult
374
406
  >({
375
407
  name: 'list-mutations',
376
- description: 'List TanStack Query mutation summaries using cursor pagination.',
408
+ description:
409
+ 'List TanStack Query mutation summaries using cursor pagination.',
377
410
  inputSchema: {
378
411
  type: 'object',
379
412
  properties: paginationProperties,
380
413
  },
414
+ pagination: {
415
+ kind: 'cursor',
416
+ fields: [
417
+ 'mutationId',
418
+ 'mutationKey',
419
+ 'status',
420
+ 'isPaused',
421
+ 'submittedAt',
422
+ 'failureCount',
423
+ 'hasData',
424
+ 'hasError',
425
+ ],
426
+ defaultFields: ['mutationId', 'mutationKey', 'status', 'hasError'],
427
+ },
381
428
  }),
382
429
  getMutationDetails: defineAgentToolContract<
383
430
  TanStackQueryGetMutationDetailsArgs,
@@ -33,7 +33,7 @@ export const dehydrateMutation = (mutation: Mutation): SerializableMutation => {
33
33
  };
34
34
 
35
35
  export const dehydrateQueryClient = (
36
- queryClient: QueryClient
36
+ queryClient: QueryClient,
37
37
  ): SerializableQueryClient => {
38
38
  return {
39
39
  queries: queryClient.getQueryCache().getAll().map(dehydrateQuery),