@rozenite/storage-plugin 1.7.0 → 1.8.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.
- package/CHANGELOG.md +21 -0
- package/README.md +6 -0
- package/dist/devtools/assets/{panel-9uIwTlU4.js → panel-eGOuOVos.js} +6 -6
- package/dist/devtools/panel.html +1 -1
- package/dist/react-native/chunks/async-storage.require.cjs +1 -0
- package/dist/react-native/chunks/async-storage.require.js +52 -0
- package/dist/react-native/chunks/index.require.cjs +1 -1
- package/dist/react-native/chunks/index.require.js +76 -159
- package/dist/react-native/chunks/secure-storage.require.cjs +1 -0
- package/dist/react-native/chunks/secure-storage.require.js +42 -0
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.cjs +1 -1
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.js +148 -135
- package/dist/react-native/index.cjs +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.js +20 -19
- package/dist/rozenite.json +1 -1
- package/dist/sdk/index.cjs +1 -0
- package/dist/sdk/index.d.ts +197 -0
- package/dist/sdk/index.js +113 -0
- package/package.json +14 -6
- package/react-native.ts +33 -21
- package/sdk.ts +44 -0
- package/src/react-native/useStorageAgentTools.ts +24 -146
- package/src/shared/agent-tools.ts +213 -0
- package/tsconfig.json +3 -1
- package/vite.config.ts +3 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineAgentToolContract,
|
|
3
|
+
type AgentToolContract,
|
|
4
|
+
} from '@rozenite/agent-shared';
|
|
5
|
+
|
|
6
|
+
import type { StorageEntry, StorageEntryType, StorageTarget } from './types';
|
|
7
|
+
|
|
8
|
+
type StorageSelection = Partial<StorageTarget>;
|
|
9
|
+
|
|
10
|
+
const sharedStorageProperties = {
|
|
11
|
+
adapterId: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description:
|
|
14
|
+
'Storage adapter ID. Required when multiple adapters are configured.',
|
|
15
|
+
},
|
|
16
|
+
storageId: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description:
|
|
19
|
+
'Storage node ID within the adapter. Required when multiple storages are configured.',
|
|
20
|
+
},
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export const STORAGE_AGENT_PLUGIN_ID = '@rozenite/storage-plugin';
|
|
24
|
+
|
|
25
|
+
export const STORAGE_AGENT_ENTRY_TYPES = [
|
|
26
|
+
'string',
|
|
27
|
+
'number',
|
|
28
|
+
'boolean',
|
|
29
|
+
'buffer',
|
|
30
|
+
] as const satisfies readonly StorageEntryType[];
|
|
31
|
+
|
|
32
|
+
export type StorageListStoragesArgs = undefined;
|
|
33
|
+
|
|
34
|
+
export type StorageListStoragesItem = {
|
|
35
|
+
adapterId: string;
|
|
36
|
+
storageId: string;
|
|
37
|
+
adapterName: string;
|
|
38
|
+
storageName: string;
|
|
39
|
+
entryCount: number;
|
|
40
|
+
supportedTypes: StorageEntryType[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type StorageListStoragesResult = {
|
|
44
|
+
storages: StorageListStoragesItem[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type StorageListEntriesArgs = StorageSelection & {
|
|
48
|
+
offset?: number;
|
|
49
|
+
limit?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type StorageListEntriesResult = {
|
|
53
|
+
adapterId: string;
|
|
54
|
+
storageId: string;
|
|
55
|
+
total: number;
|
|
56
|
+
offset: number;
|
|
57
|
+
limit: number;
|
|
58
|
+
keys: string[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type StorageReadEntryArgs = StorageSelection & {
|
|
62
|
+
key: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type StorageReadEntryResult = {
|
|
66
|
+
adapterId: string;
|
|
67
|
+
storageId: string;
|
|
68
|
+
entry: StorageEntry;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type StorageWriteEntryArgs = StorageSelection & StorageEntry;
|
|
72
|
+
|
|
73
|
+
export type StorageCreateEntryArgs = StorageWriteEntryArgs;
|
|
74
|
+
|
|
75
|
+
export type StorageCreateEntryResult = {
|
|
76
|
+
adapterId: string;
|
|
77
|
+
storageId: string;
|
|
78
|
+
created: true;
|
|
79
|
+
key: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type StorageEditEntryArgs = StorageWriteEntryArgs;
|
|
83
|
+
|
|
84
|
+
export type StorageEditEntryResult = {
|
|
85
|
+
adapterId: string;
|
|
86
|
+
storageId: string;
|
|
87
|
+
edited: true;
|
|
88
|
+
key: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type StorageRemoveEntryArgs = StorageSelection & {
|
|
92
|
+
key: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type StorageRemoveEntryResult = {
|
|
96
|
+
adapterId: string;
|
|
97
|
+
storageId: string;
|
|
98
|
+
removed: boolean;
|
|
99
|
+
key: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const storageToolDefinitions = {
|
|
103
|
+
listStorages: defineAgentToolContract<
|
|
104
|
+
StorageListStoragesArgs,
|
|
105
|
+
StorageListStoragesResult
|
|
106
|
+
>({
|
|
107
|
+
name: 'list-storages',
|
|
108
|
+
description:
|
|
109
|
+
'List all storage adapters and their storage nodes currently available on the device, including supported entry types and entry counts.',
|
|
110
|
+
inputSchema: { type: 'object', properties: {} },
|
|
111
|
+
}),
|
|
112
|
+
listEntries: defineAgentToolContract<
|
|
113
|
+
StorageListEntriesArgs,
|
|
114
|
+
StorageListEntriesResult
|
|
115
|
+
>({
|
|
116
|
+
name: 'list-entries',
|
|
117
|
+
description:
|
|
118
|
+
'List keys in a storage. This call intentionally does not return entry values to keep responses token-efficient.',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
...sharedStorageProperties,
|
|
123
|
+
offset: {
|
|
124
|
+
type: 'number',
|
|
125
|
+
description: 'Pagination offset. Defaults to 0.',
|
|
126
|
+
},
|
|
127
|
+
limit: {
|
|
128
|
+
type: 'number',
|
|
129
|
+
description: 'Pagination size. Defaults to 100.',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
readEntry: defineAgentToolContract<
|
|
135
|
+
StorageReadEntryArgs,
|
|
136
|
+
StorageReadEntryResult
|
|
137
|
+
>({
|
|
138
|
+
name: 'read-entry',
|
|
139
|
+
description: 'Read a single storage entry value by key.',
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
properties: {
|
|
143
|
+
...sharedStorageProperties,
|
|
144
|
+
key: { type: 'string', description: 'Entry key.' },
|
|
145
|
+
},
|
|
146
|
+
required: ['key'],
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
createEntry: defineAgentToolContract<
|
|
150
|
+
StorageCreateEntryArgs,
|
|
151
|
+
StorageCreateEntryResult
|
|
152
|
+
>({
|
|
153
|
+
name: 'create-entry',
|
|
154
|
+
description: 'Create a new storage entry. Fails if the key already exists.',
|
|
155
|
+
inputSchema: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
...sharedStorageProperties,
|
|
159
|
+
key: { type: 'string', description: 'Entry key.' },
|
|
160
|
+
type: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
enum: [...STORAGE_AGENT_ENTRY_TYPES],
|
|
163
|
+
description:
|
|
164
|
+
'Entry value type. Must be one of the supported types for the target storage (see list-storages).',
|
|
165
|
+
},
|
|
166
|
+
value: {
|
|
167
|
+
description: 'Entry value matching the provided type.',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
required: ['key', 'type', 'value'],
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
editEntry: defineAgentToolContract<
|
|
174
|
+
StorageEditEntryArgs,
|
|
175
|
+
StorageEditEntryResult
|
|
176
|
+
>({
|
|
177
|
+
name: 'edit-entry',
|
|
178
|
+
description:
|
|
179
|
+
'Edit an existing storage entry. Fails if the key does not exist.',
|
|
180
|
+
inputSchema: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
...sharedStorageProperties,
|
|
184
|
+
key: { type: 'string', description: 'Entry key.' },
|
|
185
|
+
type: {
|
|
186
|
+
type: 'string',
|
|
187
|
+
enum: [...STORAGE_AGENT_ENTRY_TYPES],
|
|
188
|
+
description:
|
|
189
|
+
'Entry value type. Must be one of the supported types for the target storage (see list-storages).',
|
|
190
|
+
},
|
|
191
|
+
value: {
|
|
192
|
+
description: 'Entry value matching the provided type.',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
required: ['key', 'type', 'value'],
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
removeEntry: defineAgentToolContract<
|
|
199
|
+
StorageRemoveEntryArgs,
|
|
200
|
+
StorageRemoveEntryResult
|
|
201
|
+
>({
|
|
202
|
+
name: 'remove-entry',
|
|
203
|
+
description: 'Remove a storage entry by key.',
|
|
204
|
+
inputSchema: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
...sharedStorageProperties,
|
|
208
|
+
key: { type: 'string', description: 'Entry key.' },
|
|
209
|
+
},
|
|
210
|
+
required: ['key'],
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
} as const satisfies Record<string, AgentToolContract<unknown, unknown>>;
|
package/tsconfig.json
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"moduleResolution": "bundler",
|
|
14
14
|
"baseUrl": ".",
|
|
15
15
|
"paths": {
|
|
16
|
+
"@rozenite/agent-bridge": ["../agent-bridge/src/index.ts"],
|
|
17
|
+
"@rozenite/agent-shared": ["../agent-shared/src/index.ts"],
|
|
16
18
|
"@rozenite/plugin-bridge": ["../plugin-bridge/src/index.ts"]
|
|
17
19
|
},
|
|
18
20
|
"resolveJsonModule": true,
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
"noEmit": true,
|
|
21
23
|
"jsx": "react-jsx"
|
|
22
24
|
},
|
|
23
|
-
"include": ["src/**/*", "react-native.ts", "rozenite.config.ts"],
|
|
25
|
+
"include": ["src/**/*", "react-native.ts", "sdk.ts", "rozenite.config.ts"],
|
|
24
26
|
"exclude": ["node_modules", "dist", "build"],
|
|
25
27
|
"references": [
|
|
26
28
|
{
|