@rozenite/storage-plugin 1.7.0 → 1.8.1

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.
@@ -0,0 +1,197 @@
1
+ import { AgentToolContract } from '@rozenite/agent-shared';
2
+ import { AgentToolDescriptor } from '@rozenite/agent-shared';
3
+
4
+ declare type AsyncStorage = {
5
+ kind: 'async';
6
+ getAllKeys: () => Promise<readonly string[]>;
7
+ get: (key: string) => Promise<StorageEntry | undefined>;
8
+ set: (entry: StorageEntry) => Promise<void>;
9
+ delete: (key: string) => Promise<void>;
10
+ subscribe?: (callback: (key: string) => void) => StorageSubscription;
11
+ };
12
+
13
+ export declare const STORAGE_AGENT_ENTRY_TYPES: readonly ["string", "number", "boolean", "buffer"];
14
+
15
+ export declare const STORAGE_AGENT_PLUGIN_ID = "@rozenite/storage-plugin";
16
+
17
+ export declare type StorageAdapter = {
18
+ id: string;
19
+ name: string;
20
+ storages: StorageNode[];
21
+ };
22
+
23
+ export declare type StorageCapabilities = {
24
+ supportedTypes: StorageEntryType[];
25
+ };
26
+
27
+ export declare type StorageCreateEntryArgs = StorageWriteEntryArgs;
28
+
29
+ export declare type StorageCreateEntryResult = {
30
+ adapterId: string;
31
+ storageId: string;
32
+ created: true;
33
+ key: string;
34
+ };
35
+
36
+ export declare type StorageEditEntryArgs = StorageWriteEntryArgs;
37
+
38
+ export declare type StorageEditEntryResult = {
39
+ adapterId: string;
40
+ storageId: string;
41
+ edited: true;
42
+ key: string;
43
+ };
44
+
45
+ export declare type StorageEntry = {
46
+ key: string;
47
+ type: 'string';
48
+ value: string;
49
+ } | {
50
+ key: string;
51
+ type: 'number';
52
+ value: number;
53
+ } | {
54
+ key: string;
55
+ type: 'boolean';
56
+ value: boolean;
57
+ } | {
58
+ key: string;
59
+ type: 'buffer';
60
+ value: number[];
61
+ };
62
+
63
+ export declare type StorageEntryType = StorageEntry['type'];
64
+
65
+ export declare type StorageEntryValue = StorageEntry['value'];
66
+
67
+ export declare type StorageListEntriesArgs = StorageSelection & {
68
+ offset?: number;
69
+ limit?: number;
70
+ };
71
+
72
+ export declare type StorageListEntriesResult = {
73
+ adapterId: string;
74
+ storageId: string;
75
+ total: number;
76
+ offset: number;
77
+ limit: number;
78
+ keys: string[];
79
+ };
80
+
81
+ export declare type StorageListStoragesArgs = undefined;
82
+
83
+ export declare type StorageListStoragesItem = {
84
+ adapterId: string;
85
+ storageId: string;
86
+ adapterName: string;
87
+ storageName: string;
88
+ entryCount: number;
89
+ supportedTypes: StorageEntryType[];
90
+ };
91
+
92
+ export declare type StorageListStoragesResult = {
93
+ storages: StorageListStoragesItem[];
94
+ };
95
+
96
+ export declare type StorageNode = {
97
+ id: string;
98
+ name: string;
99
+ storage: SyncStorage | AsyncStorage;
100
+ capabilities: StorageCapabilities;
101
+ blacklist?: RegExp;
102
+ };
103
+
104
+ export declare type StorageReadEntryArgs = StorageSelection & {
105
+ key: string;
106
+ };
107
+
108
+ export declare type StorageReadEntryResult = {
109
+ adapterId: string;
110
+ storageId: string;
111
+ entry: StorageEntry;
112
+ };
113
+
114
+ export declare type StorageRemoveEntryArgs = StorageSelection & {
115
+ key: string;
116
+ };
117
+
118
+ export declare type StorageRemoveEntryResult = {
119
+ adapterId: string;
120
+ storageId: string;
121
+ removed: boolean;
122
+ key: string;
123
+ };
124
+
125
+ declare type StorageSelection = Partial<StorageTarget>;
126
+
127
+ declare type StorageSubscription = {
128
+ remove: () => void;
129
+ };
130
+
131
+ export declare type StorageTarget = {
132
+ adapterId: string;
133
+ storageId: string;
134
+ };
135
+
136
+ export declare const storageToolDefinitions: {
137
+ readonly listStorages: AgentToolContract<undefined, StorageListStoragesResult>;
138
+ readonly listEntries: AgentToolContract<StorageListEntriesArgs, StorageListEntriesResult>;
139
+ readonly readEntry: AgentToolContract<StorageReadEntryArgs, StorageReadEntryResult>;
140
+ readonly createEntry: AgentToolContract<StorageWriteEntryArgs, StorageCreateEntryResult>;
141
+ readonly editEntry: AgentToolContract<StorageWriteEntryArgs, StorageEditEntryResult>;
142
+ readonly removeEntry: AgentToolContract<StorageRemoveEntryArgs, StorageRemoveEntryResult>;
143
+ };
144
+
145
+ export declare const storageTools: {
146
+ readonly listStorages: AgentToolDescriptor<undefined, StorageListStoragesResult>;
147
+ readonly listEntries: AgentToolDescriptor<StorageListEntriesArgs, StorageListEntriesResult>;
148
+ readonly readEntry: AgentToolDescriptor<StorageReadEntryArgs, StorageReadEntryResult>;
149
+ readonly createEntry: AgentToolDescriptor<(Partial<StorageTarget> & {
150
+ key: string;
151
+ type: "string";
152
+ value: string;
153
+ }) | (Partial<StorageTarget> & {
154
+ key: string;
155
+ type: "number";
156
+ value: number;
157
+ }) | (Partial<StorageTarget> & {
158
+ key: string;
159
+ type: "boolean";
160
+ value: boolean;
161
+ }) | (Partial<StorageTarget> & {
162
+ key: string;
163
+ type: "buffer";
164
+ value: number[];
165
+ }), StorageCreateEntryResult>;
166
+ readonly editEntry: AgentToolDescriptor<(Partial<StorageTarget> & {
167
+ key: string;
168
+ type: "string";
169
+ value: string;
170
+ }) | (Partial<StorageTarget> & {
171
+ key: string;
172
+ type: "number";
173
+ value: number;
174
+ }) | (Partial<StorageTarget> & {
175
+ key: string;
176
+ type: "boolean";
177
+ value: boolean;
178
+ }) | (Partial<StorageTarget> & {
179
+ key: string;
180
+ type: "buffer";
181
+ value: number[];
182
+ }), StorageEditEntryResult>;
183
+ readonly removeEntry: AgentToolDescriptor<StorageRemoveEntryArgs, StorageRemoveEntryResult>;
184
+ };
185
+
186
+ export declare type StorageWriteEntryArgs = StorageSelection & StorageEntry;
187
+
188
+ declare type SyncStorage = {
189
+ kind: 'sync';
190
+ getAllKeys: () => string[];
191
+ get: (key: string) => StorageEntry | undefined;
192
+ set: (entry: StorageEntry) => void;
193
+ delete: (key: string) => void;
194
+ subscribe?: (callback: (key: string) => void) => StorageSubscription;
195
+ };
196
+
197
+ export { }
@@ -0,0 +1,113 @@
1
+ import { defineAgentToolContract as e, defineAgentToolDescriptors as i } from "@rozenite/agent-shared";
2
+ const t = {
3
+ adapterId: {
4
+ type: "string",
5
+ description: "Storage adapter ID. Required when multiple adapters are configured."
6
+ },
7
+ storageId: {
8
+ type: "string",
9
+ description: "Storage node ID within the adapter. Required when multiple storages are configured."
10
+ }
11
+ }, n = "@rozenite/storage-plugin", r = [
12
+ "string",
13
+ "number",
14
+ "boolean",
15
+ "buffer"
16
+ ], s = {
17
+ listStorages: e({
18
+ name: "list-storages",
19
+ description: "List all storage adapters and their storage nodes currently available on the device, including supported entry types and entry counts.",
20
+ inputSchema: { type: "object", properties: {} }
21
+ }),
22
+ listEntries: e({
23
+ name: "list-entries",
24
+ description: "List keys in a storage. This call intentionally does not return entry values to keep responses token-efficient.",
25
+ inputSchema: {
26
+ type: "object",
27
+ properties: {
28
+ ...t,
29
+ offset: {
30
+ type: "number",
31
+ description: "Pagination offset. Defaults to 0."
32
+ },
33
+ limit: {
34
+ type: "number",
35
+ description: "Pagination size. Defaults to 100."
36
+ }
37
+ }
38
+ }
39
+ }),
40
+ readEntry: e({
41
+ name: "read-entry",
42
+ description: "Read a single storage entry value by key.",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ ...t,
47
+ key: { type: "string", description: "Entry key." }
48
+ },
49
+ required: ["key"]
50
+ }
51
+ }),
52
+ createEntry: e({
53
+ name: "create-entry",
54
+ description: "Create a new storage entry. Fails if the key already exists.",
55
+ inputSchema: {
56
+ type: "object",
57
+ properties: {
58
+ ...t,
59
+ key: { type: "string", description: "Entry key." },
60
+ type: {
61
+ type: "string",
62
+ enum: [...r],
63
+ description: "Entry value type. Must be one of the supported types for the target storage (see list-storages)."
64
+ },
65
+ value: {
66
+ description: "Entry value matching the provided type."
67
+ }
68
+ },
69
+ required: ["key", "type", "value"]
70
+ }
71
+ }),
72
+ editEntry: e({
73
+ name: "edit-entry",
74
+ description: "Edit an existing storage entry. Fails if the key does not exist.",
75
+ inputSchema: {
76
+ type: "object",
77
+ properties: {
78
+ ...t,
79
+ key: { type: "string", description: "Entry key." },
80
+ type: {
81
+ type: "string",
82
+ enum: [...r],
83
+ description: "Entry value type. Must be one of the supported types for the target storage (see list-storages)."
84
+ },
85
+ value: {
86
+ description: "Entry value matching the provided type."
87
+ }
88
+ },
89
+ required: ["key", "type", "value"]
90
+ }
91
+ }),
92
+ removeEntry: e({
93
+ name: "remove-entry",
94
+ description: "Remove a storage entry by key.",
95
+ inputSchema: {
96
+ type: "object",
97
+ properties: {
98
+ ...t,
99
+ key: { type: "string", description: "Entry key." }
100
+ },
101
+ required: ["key"]
102
+ }
103
+ })
104
+ }, a = i(
105
+ n,
106
+ s
107
+ );
108
+ export {
109
+ r as STORAGE_AGENT_ENTRY_TYPES,
110
+ n as STORAGE_AGENT_PLUGIN_ID,
111
+ s as storageToolDefinitions,
112
+ a as storageTools
113
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozenite/storage-plugin",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Generic Storage Inspector for Rozenite.",
5
5
  "type": "module",
6
6
  "main": "./dist/react-native/index.cjs",
@@ -15,8 +15,9 @@
15
15
  "url": "https://github.com/callstackincubator/rozenite.git"
16
16
  },
17
17
  "dependencies": {
18
- "@rozenite/agent-bridge": "1.7.0",
19
- "@rozenite/plugin-bridge": "1.7.0"
18
+ "@rozenite/agent-shared": "1.8.1",
19
+ "@rozenite/agent-bridge": "1.8.1",
20
+ "@rozenite/plugin-bridge": "1.8.1"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@tanstack/react-table": "^8.21.3",
@@ -37,8 +38,8 @@
37
38
  "tailwindcss-animate": "^1.0.7",
38
39
  "typescript": "~5.9.3",
39
40
  "vite": "^7.3.1",
40
- "@rozenite/vite-plugin": "1.7.0",
41
- "rozenite": "1.7.0"
41
+ "@rozenite/vite-plugin": "1.8.1",
42
+ "rozenite": "1.8.1"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "@react-native-async-storage/async-storage": "*",
@@ -65,6 +66,12 @@
65
66
  "import": "./dist/react-native/index.js",
66
67
  "require": "./dist/react-native/index.cjs"
67
68
  },
69
+ "./sdk": {
70
+ "development": "./sdk.ts",
71
+ "types": "./dist/sdk/index.d.ts",
72
+ "import": "./dist/sdk/index.js",
73
+ "require": "./dist/sdk/index.cjs"
74
+ },
68
75
  "./package.json": "./package.json"
69
76
  },
70
77
  "publishConfig": {
@@ -74,6 +81,7 @@
74
81
  "build": "rozenite build",
75
82
  "dev": "rozenite dev",
76
83
  "typecheck": "tsc -p tsconfig.json --noEmit",
77
- "lint": "eslint ."
84
+ "lint": "eslint .",
85
+ "test": "vitest --run --passWithNoTests"
78
86
  }
79
87
  }
package/react-native.ts CHANGED
@@ -30,28 +30,17 @@ const isWeb =
30
30
  const isDev = process.env.NODE_ENV !== 'production';
31
31
  const isServer = typeof window === 'undefined';
32
32
 
33
- if (isDev && !isWeb && !isServer) {
34
- createAsyncStorageAdapter =
35
- require('./src/react-native/adapters').createAsyncStorageAdapter;
36
- createExpoAsyncStorageAdapter =
37
- require('./src/react-native/adapters').createExpoAsyncStorageAdapter;
38
- createExpoSecureStorageAdapter =
39
- require('./src/react-native/adapters').createExpoSecureStorageAdapter;
40
- createMMKVStorageAdapter =
41
- require('./src/react-native/adapters').createMMKVStorageAdapter;
42
- useRozeniteStoragePlugin =
43
- require('./src/react-native/useRozeniteStoragePlugin').useRozeniteStoragePlugin;
44
- } else {
45
- const createNoopStorageAdapter = (
46
- options: { adapterId?: string; adapterName?: string } | undefined,
47
- defaultId: string,
48
- defaultName: string
49
- ) => ({
50
- id: options?.adapterId ?? defaultId,
51
- name: options?.adapterName ?? defaultName,
52
- storages: [],
53
- });
33
+ const createNoopStorageAdapter = (
34
+ options: { adapterId?: string; adapterName?: string } | undefined,
35
+ defaultId: string,
36
+ defaultName: string
37
+ ) => ({
38
+ id: options?.adapterId ?? defaultId,
39
+ name: options?.adapterName ?? defaultName,
40
+ storages: [],
41
+ });
54
42
 
43
+ if (!isDev || isServer) {
55
44
  createAsyncStorageAdapter = ((
56
45
  options: { adapterId?: string; adapterName?: string }
57
46
  ) =>
@@ -74,4 +63,27 @@ if (isDev && !isWeb && !isServer) {
74
63
  options: { adapterId?: string; adapterName?: string }
75
64
  ) => createNoopStorageAdapter(options, 'mmkv', 'MMKV')) as typeof createMMKVStorageAdapter;
76
65
  useRozeniteStoragePlugin = () => null;
66
+ } else if (isWeb) {
67
+ const asyncStorageModule = require('./src/react-native/adapters/async-storage');
68
+ const secureStorageModule = require('./src/react-native/adapters/secure-storage');
69
+
70
+ createAsyncStorageAdapter = asyncStorageModule.createAsyncStorageAdapter;
71
+ createExpoAsyncStorageAdapter = asyncStorageModule.createExpoAsyncStorageAdapter;
72
+ createExpoSecureStorageAdapter = secureStorageModule.createExpoSecureStorageAdapter;
73
+ createMMKVStorageAdapter = ((
74
+ options: { adapterId?: string; adapterName?: string }
75
+ ) => createNoopStorageAdapter(options, 'mmkv', 'MMKV')) as typeof createMMKVStorageAdapter;
76
+ useRozeniteStoragePlugin =
77
+ require('./src/react-native/useRozeniteStoragePlugin').useRozeniteStoragePlugin;
78
+ } else {
79
+ createAsyncStorageAdapter =
80
+ require('./src/react-native/adapters').createAsyncStorageAdapter;
81
+ createExpoAsyncStorageAdapter =
82
+ require('./src/react-native/adapters').createExpoAsyncStorageAdapter;
83
+ createExpoSecureStorageAdapter =
84
+ require('./src/react-native/adapters').createExpoSecureStorageAdapter;
85
+ createMMKVStorageAdapter =
86
+ require('./src/react-native/adapters').createMMKVStorageAdapter;
87
+ useRozeniteStoragePlugin =
88
+ require('./src/react-native/useRozeniteStoragePlugin').useRozeniteStoragePlugin;
77
89
  }
package/sdk.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { defineAgentToolDescriptors } from '@rozenite/agent-shared';
2
+ import {
3
+ STORAGE_AGENT_ENTRY_TYPES,
4
+ STORAGE_AGENT_PLUGIN_ID,
5
+ storageToolDefinitions,
6
+ } from './src/shared/agent-tools.js';
7
+
8
+ export {
9
+ STORAGE_AGENT_ENTRY_TYPES,
10
+ STORAGE_AGENT_PLUGIN_ID,
11
+ storageToolDefinitions,
12
+ };
13
+
14
+ export const storageTools = defineAgentToolDescriptors(
15
+ STORAGE_AGENT_PLUGIN_ID,
16
+ storageToolDefinitions,
17
+ );
18
+
19
+ export type {
20
+ StorageCreateEntryArgs,
21
+ StorageCreateEntryResult,
22
+ StorageEditEntryArgs,
23
+ StorageEditEntryResult,
24
+ StorageListEntriesArgs,
25
+ StorageListEntriesResult,
26
+ StorageListStoragesArgs,
27
+ StorageListStoragesItem,
28
+ StorageListStoragesResult,
29
+ StorageReadEntryArgs,
30
+ StorageReadEntryResult,
31
+ StorageRemoveEntryArgs,
32
+ StorageRemoveEntryResult,
33
+ StorageWriteEntryArgs,
34
+ } from './src/shared/agent-tools.js';
35
+
36
+ export type {
37
+ StorageAdapter,
38
+ StorageCapabilities,
39
+ StorageEntry,
40
+ StorageEntryType,
41
+ StorageEntryValue,
42
+ StorageNode,
43
+ StorageTarget,
44
+ } from './src/shared/types.js';
@@ -1,131 +1,12 @@
1
1
  import { useCallback } from 'react';
2
- import { useRozenitePluginAgentTool, type AgentTool } from '@rozenite/agent-bridge';
2
+ import { useRozenitePluginAgentTool } from '@rozenite/agent-bridge';
3
+ import {
4
+ STORAGE_AGENT_PLUGIN_ID,
5
+ storageToolDefinitions,
6
+ } from '../shared/agent-tools';
3
7
  import type { StorageEntry, StorageEntryType, StorageEntryValue } from '../shared/types';
4
8
  import type { StorageView } from './storage-view';
5
9
 
6
- type StorageInput = { adapterId?: string; storageId?: string };
7
- type KeyInput = StorageInput & { key: string };
8
- type SetInput = StorageInput & {
9
- key: string;
10
- type: StorageEntryType;
11
- value: unknown;
12
- };
13
- type ListEntriesInput = StorageInput & {
14
- offset?: number;
15
- limit?: number;
16
- };
17
-
18
- const toolPrefix = '@rozenite/storage-plugin';
19
- const sharedStorageProperties = {
20
- adapterId: {
21
- type: 'string',
22
- description:
23
- 'Storage adapter ID. Required when multiple adapters are configured.',
24
- },
25
- storageId: {
26
- type: 'string',
27
- description:
28
- 'Storage node ID within the adapter. Required when multiple storages are configured.',
29
- },
30
- } as const;
31
-
32
- const listStoragesTool: AgentTool = {
33
- name: 'list-storages',
34
- description:
35
- 'List all storage adapters and their storage nodes currently available on the device, including supported entry types and entry counts.',
36
- inputSchema: { type: 'object', properties: {} },
37
- };
38
-
39
- const listEntriesTool: AgentTool = {
40
- name: 'list-entries',
41
- description:
42
- 'List keys in a storage. This call intentionally does not return entry values to keep responses token-efficient.',
43
- inputSchema: {
44
- type: 'object',
45
- properties: {
46
- ...sharedStorageProperties,
47
- offset: {
48
- type: 'number',
49
- description: 'Pagination offset. Defaults to 0.',
50
- },
51
- limit: {
52
- type: 'number',
53
- description: 'Pagination size. Defaults to 100.',
54
- },
55
- },
56
- },
57
- };
58
-
59
- const readEntryTool: AgentTool = {
60
- name: 'read-entry',
61
- description: 'Read a single storage entry value by key.',
62
- inputSchema: {
63
- type: 'object',
64
- properties: {
65
- ...sharedStorageProperties,
66
- key: { type: 'string', description: 'Entry key.' },
67
- },
68
- required: ['key'],
69
- },
70
- };
71
-
72
- const createEntryTool: AgentTool = {
73
- name: 'create-entry',
74
- description: 'Create a new storage entry. Fails if the key already exists.',
75
- inputSchema: {
76
- type: 'object',
77
- properties: {
78
- ...sharedStorageProperties,
79
- key: { type: 'string', description: 'Entry key.' },
80
- type: {
81
- type: 'string',
82
- enum: ['string', 'number', 'boolean', 'buffer'],
83
- description:
84
- 'Entry value type. Must be one of the supported types for the target storage (see list-storages).',
85
- },
86
- value: {
87
- description: 'Entry value matching the provided type.',
88
- },
89
- },
90
- required: ['key', 'type', 'value'],
91
- },
92
- };
93
-
94
- const editEntryTool: AgentTool = {
95
- name: 'edit-entry',
96
- description: 'Edit an existing storage entry. Fails if the key does not exist.',
97
- inputSchema: {
98
- type: 'object',
99
- properties: {
100
- ...sharedStorageProperties,
101
- key: { type: 'string', description: 'Entry key.' },
102
- type: {
103
- type: 'string',
104
- enum: ['string', 'number', 'boolean', 'buffer'],
105
- description:
106
- 'Entry value type. Must be one of the supported types for the target storage (see list-storages).',
107
- },
108
- value: {
109
- description: 'Entry value matching the provided type.',
110
- },
111
- },
112
- required: ['key', 'type', 'value'],
113
- },
114
- };
115
-
116
- const removeEntryTool: AgentTool = {
117
- name: 'remove-entry',
118
- description: 'Remove a storage entry by key.',
119
- inputSchema: {
120
- type: 'object',
121
- properties: {
122
- ...sharedStorageProperties,
123
- key: { type: 'string', description: 'Entry key.' },
124
- },
125
- required: ['key'],
126
- },
127
- };
128
-
129
10
  const parseValueForType = (
130
11
  type: StorageEntryType,
131
12
  value: unknown
@@ -202,8 +83,8 @@ export const useStorageAgentTools = (views: StorageView[]) => {
202
83
  );
203
84
 
204
85
  useRozenitePluginAgentTool({
205
- pluginId: toolPrefix,
206
- tool: listStoragesTool,
86
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
87
+ tool: storageToolDefinitions.listStorages,
207
88
  handler: async () => ({
208
89
  storages: await Promise.all(
209
90
  views.map(async (view) => ({
@@ -218,9 +99,9 @@ export const useStorageAgentTools = (views: StorageView[]) => {
218
99
  }),
219
100
  });
220
101
 
221
- useRozenitePluginAgentTool<ListEntriesInput>({
222
- pluginId: toolPrefix,
223
- tool: listEntriesTool,
102
+ useRozenitePluginAgentTool({
103
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
104
+ tool: storageToolDefinitions.listEntries,
224
105
  handler: async ({ adapterId, storageId, offset = 0, limit = 100 }) => {
225
106
  const view = resolveStorage(adapterId, storageId);
226
107
  const allKeys = await view.getAllKeys();
@@ -239,12 +120,9 @@ export const useStorageAgentTools = (views: StorageView[]) => {
239
120
  },
240
121
  });
241
122
 
242
- useRozenitePluginAgentTool<
243
- KeyInput,
244
- { adapterId: string; storageId: string; entry: StorageEntry }
245
- >({
246
- pluginId: toolPrefix,
247
- tool: readEntryTool,
123
+ useRozenitePluginAgentTool({
124
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
125
+ tool: storageToolDefinitions.readEntry,
248
126
  handler: async ({ adapterId, storageId, key }) => {
249
127
  const view = resolveStorage(adapterId, storageId);
250
128
  const entry = await view.get(key);
@@ -263,9 +141,9 @@ export const useStorageAgentTools = (views: StorageView[]) => {
263
141
  },
264
142
  });
265
143
 
266
- useRozenitePluginAgentTool<SetInput>({
267
- pluginId: toolPrefix,
268
- tool: createEntryTool,
144
+ useRozenitePluginAgentTool({
145
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
146
+ tool: storageToolDefinitions.createEntry,
269
147
  handler: async ({ adapterId, storageId, key, type, value }) => {
270
148
  const view = resolveStorage(adapterId, storageId);
271
149
  const existing = await view.get(key);
@@ -282,15 +160,15 @@ export const useStorageAgentTools = (views: StorageView[]) => {
282
160
  return {
283
161
  adapterId: view.target.adapterId,
284
162
  storageId: view.target.storageId,
285
- created: true,
163
+ created: true as const,
286
164
  key,
287
165
  };
288
166
  },
289
167
  });
290
168
 
291
- useRozenitePluginAgentTool<SetInput>({
292
- pluginId: toolPrefix,
293
- tool: editEntryTool,
169
+ useRozenitePluginAgentTool({
170
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
171
+ tool: storageToolDefinitions.editEntry,
294
172
  handler: async ({ adapterId, storageId, key, type, value }) => {
295
173
  const view = resolveStorage(adapterId, storageId);
296
174
  const existing = await view.get(key);
@@ -307,15 +185,15 @@ export const useStorageAgentTools = (views: StorageView[]) => {
307
185
  return {
308
186
  adapterId: view.target.adapterId,
309
187
  storageId: view.target.storageId,
310
- edited: true,
188
+ edited: true as const,
311
189
  key,
312
190
  };
313
191
  },
314
192
  });
315
193
 
316
- useRozenitePluginAgentTool<KeyInput>({
317
- pluginId: toolPrefix,
318
- tool: removeEntryTool,
194
+ useRozenitePluginAgentTool({
195
+ pluginId: STORAGE_AGENT_PLUGIN_ID,
196
+ tool: storageToolDefinitions.removeEntry,
319
197
  handler: async ({ adapterId, storageId, key }) => {
320
198
  const view = resolveStorage(adapterId, storageId);
321
199
  const existed = !!(await view.get(key));