@z3rno/sdk 0.0.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.
- package/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/index.cjs +292 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +396 -0
- package/dist/index.d.ts +396 -0
- package/dist/index.js +276 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zod schemas and inferred TypeScript types for the Z3rno API.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare const MemoryType: z.ZodEnum<["working", "episodic", "semantic", "procedural"]>;
|
|
8
|
+
type MemoryType = z.infer<typeof MemoryType>;
|
|
9
|
+
declare const RelationshipType: z.ZodEnum<["derived_from", "contradicts", "supports", "supersedes", "related_to", "caused_by"]>;
|
|
10
|
+
type RelationshipType = z.infer<typeof RelationshipType>;
|
|
11
|
+
declare const StoreMemoryRequest: z.ZodObject<{
|
|
12
|
+
agentId: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
memoryType: z.ZodDefault<z.ZodEnum<["working", "episodic", "semantic", "procedural"]>>;
|
|
15
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
|
+
relationships: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
18
|
+
targetMemoryId: z.ZodString;
|
|
19
|
+
relationshipType: z.ZodEnum<["derived_from", "contradicts", "supports", "supersedes", "related_to", "caused_by"]>;
|
|
20
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
metadata: Record<string, unknown>;
|
|
24
|
+
targetMemoryId: string;
|
|
25
|
+
relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
|
|
26
|
+
weight: number;
|
|
27
|
+
}, {
|
|
28
|
+
targetMemoryId: string;
|
|
29
|
+
relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
|
|
30
|
+
metadata?: Record<string, unknown> | undefined;
|
|
31
|
+
weight?: number | undefined;
|
|
32
|
+
}>, "many">>;
|
|
33
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
agentId: string;
|
|
37
|
+
content: string;
|
|
38
|
+
memoryType: "working" | "episodic" | "semantic" | "procedural";
|
|
39
|
+
metadata: Record<string, unknown>;
|
|
40
|
+
relationships: {
|
|
41
|
+
metadata: Record<string, unknown>;
|
|
42
|
+
targetMemoryId: string;
|
|
43
|
+
relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
|
|
44
|
+
weight: number;
|
|
45
|
+
}[];
|
|
46
|
+
userId?: string | undefined;
|
|
47
|
+
ttlSeconds?: number | undefined;
|
|
48
|
+
importance?: number | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
agentId: string;
|
|
51
|
+
content: string;
|
|
52
|
+
memoryType?: "working" | "episodic" | "semantic" | "procedural" | undefined;
|
|
53
|
+
userId?: string | undefined;
|
|
54
|
+
metadata?: Record<string, unknown> | undefined;
|
|
55
|
+
relationships?: {
|
|
56
|
+
targetMemoryId: string;
|
|
57
|
+
relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
|
|
58
|
+
metadata?: Record<string, unknown> | undefined;
|
|
59
|
+
weight?: number | undefined;
|
|
60
|
+
}[] | undefined;
|
|
61
|
+
ttlSeconds?: number | undefined;
|
|
62
|
+
importance?: number | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
type StoreMemoryRequest = z.infer<typeof StoreMemoryRequest>;
|
|
65
|
+
declare const MemoryResponse: z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
agent_id: z.ZodString;
|
|
68
|
+
content: z.ZodString;
|
|
69
|
+
memory_type: z.ZodString;
|
|
70
|
+
importance_score: z.ZodNumber;
|
|
71
|
+
recall_count: z.ZodNumber;
|
|
72
|
+
embedding_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
|
+
created_at: z.ZodString;
|
|
74
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
content: string;
|
|
77
|
+
metadata: Record<string, unknown>;
|
|
78
|
+
id: string;
|
|
79
|
+
agent_id: string;
|
|
80
|
+
memory_type: string;
|
|
81
|
+
importance_score: number;
|
|
82
|
+
recall_count: number;
|
|
83
|
+
created_at: string;
|
|
84
|
+
embedding_model?: string | null | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
content: string;
|
|
87
|
+
id: string;
|
|
88
|
+
agent_id: string;
|
|
89
|
+
memory_type: string;
|
|
90
|
+
importance_score: number;
|
|
91
|
+
recall_count: number;
|
|
92
|
+
created_at: string;
|
|
93
|
+
metadata?: Record<string, unknown> | undefined;
|
|
94
|
+
embedding_model?: string | null | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
type MemoryResponse = z.infer<typeof MemoryResponse>;
|
|
97
|
+
declare const RecallResultItem: z.ZodObject<{
|
|
98
|
+
memory_id: z.ZodString;
|
|
99
|
+
content: z.ZodString;
|
|
100
|
+
summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
101
|
+
memory_type: z.ZodString;
|
|
102
|
+
similarity_score: z.ZodNumber;
|
|
103
|
+
importance_score: z.ZodNumber;
|
|
104
|
+
relevance_score: z.ZodNumber;
|
|
105
|
+
recall_count: z.ZodNumber;
|
|
106
|
+
created_at: z.ZodString;
|
|
107
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
content: string;
|
|
110
|
+
metadata: Record<string, unknown>;
|
|
111
|
+
memory_type: string;
|
|
112
|
+
importance_score: number;
|
|
113
|
+
recall_count: number;
|
|
114
|
+
created_at: string;
|
|
115
|
+
memory_id: string;
|
|
116
|
+
similarity_score: number;
|
|
117
|
+
relevance_score: number;
|
|
118
|
+
summary?: string | null | undefined;
|
|
119
|
+
}, {
|
|
120
|
+
content: string;
|
|
121
|
+
memory_type: string;
|
|
122
|
+
importance_score: number;
|
|
123
|
+
recall_count: number;
|
|
124
|
+
created_at: string;
|
|
125
|
+
memory_id: string;
|
|
126
|
+
similarity_score: number;
|
|
127
|
+
relevance_score: number;
|
|
128
|
+
metadata?: Record<string, unknown> | undefined;
|
|
129
|
+
summary?: string | null | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
type RecallResultItem = z.infer<typeof RecallResultItem>;
|
|
132
|
+
declare const RecallResponse: z.ZodObject<{
|
|
133
|
+
results: z.ZodArray<z.ZodObject<{
|
|
134
|
+
memory_id: z.ZodString;
|
|
135
|
+
content: z.ZodString;
|
|
136
|
+
summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
137
|
+
memory_type: z.ZodString;
|
|
138
|
+
similarity_score: z.ZodNumber;
|
|
139
|
+
importance_score: z.ZodNumber;
|
|
140
|
+
relevance_score: z.ZodNumber;
|
|
141
|
+
recall_count: z.ZodNumber;
|
|
142
|
+
created_at: z.ZodString;
|
|
143
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
content: string;
|
|
146
|
+
metadata: Record<string, unknown>;
|
|
147
|
+
memory_type: string;
|
|
148
|
+
importance_score: number;
|
|
149
|
+
recall_count: number;
|
|
150
|
+
created_at: string;
|
|
151
|
+
memory_id: string;
|
|
152
|
+
similarity_score: number;
|
|
153
|
+
relevance_score: number;
|
|
154
|
+
summary?: string | null | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
content: string;
|
|
157
|
+
memory_type: string;
|
|
158
|
+
importance_score: number;
|
|
159
|
+
recall_count: number;
|
|
160
|
+
created_at: string;
|
|
161
|
+
memory_id: string;
|
|
162
|
+
similarity_score: number;
|
|
163
|
+
relevance_score: number;
|
|
164
|
+
metadata?: Record<string, unknown> | undefined;
|
|
165
|
+
summary?: string | null | undefined;
|
|
166
|
+
}>, "many">;
|
|
167
|
+
total: z.ZodNumber;
|
|
168
|
+
query: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
results: {
|
|
171
|
+
content: string;
|
|
172
|
+
metadata: Record<string, unknown>;
|
|
173
|
+
memory_type: string;
|
|
174
|
+
importance_score: number;
|
|
175
|
+
recall_count: number;
|
|
176
|
+
created_at: string;
|
|
177
|
+
memory_id: string;
|
|
178
|
+
similarity_score: number;
|
|
179
|
+
relevance_score: number;
|
|
180
|
+
summary?: string | null | undefined;
|
|
181
|
+
}[];
|
|
182
|
+
total: number;
|
|
183
|
+
query?: string | null | undefined;
|
|
184
|
+
}, {
|
|
185
|
+
results: {
|
|
186
|
+
content: string;
|
|
187
|
+
memory_type: string;
|
|
188
|
+
importance_score: number;
|
|
189
|
+
recall_count: number;
|
|
190
|
+
created_at: string;
|
|
191
|
+
memory_id: string;
|
|
192
|
+
similarity_score: number;
|
|
193
|
+
relevance_score: number;
|
|
194
|
+
metadata?: Record<string, unknown> | undefined;
|
|
195
|
+
summary?: string | null | undefined;
|
|
196
|
+
}[];
|
|
197
|
+
total: number;
|
|
198
|
+
query?: string | null | undefined;
|
|
199
|
+
}>;
|
|
200
|
+
type RecallResponse = z.infer<typeof RecallResponse>;
|
|
201
|
+
declare const ForgetResponse: z.ZodObject<{
|
|
202
|
+
deleted_count: z.ZodNumber;
|
|
203
|
+
hard_deleted: z.ZodBoolean;
|
|
204
|
+
cascade_count: z.ZodNumber;
|
|
205
|
+
memory_ids: z.ZodArray<z.ZodString, "many">;
|
|
206
|
+
}, "strip", z.ZodTypeAny, {
|
|
207
|
+
deleted_count: number;
|
|
208
|
+
hard_deleted: boolean;
|
|
209
|
+
cascade_count: number;
|
|
210
|
+
memory_ids: string[];
|
|
211
|
+
}, {
|
|
212
|
+
deleted_count: number;
|
|
213
|
+
hard_deleted: boolean;
|
|
214
|
+
cascade_count: number;
|
|
215
|
+
memory_ids: string[];
|
|
216
|
+
}>;
|
|
217
|
+
type ForgetResponse = z.infer<typeof ForgetResponse>;
|
|
218
|
+
declare const AuditEntry: z.ZodObject<{
|
|
219
|
+
id: z.ZodNumber;
|
|
220
|
+
agent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
221
|
+
user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
222
|
+
operation: z.ZodString;
|
|
223
|
+
memory_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
224
|
+
memory_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
225
|
+
details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
226
|
+
ip_address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
227
|
+
created_at: z.ZodString;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
id: number;
|
|
230
|
+
created_at: string;
|
|
231
|
+
operation: string;
|
|
232
|
+
details: Record<string, unknown>;
|
|
233
|
+
agent_id?: string | null | undefined;
|
|
234
|
+
memory_type?: string | null | undefined;
|
|
235
|
+
memory_id?: string | null | undefined;
|
|
236
|
+
user_id?: string | null | undefined;
|
|
237
|
+
ip_address?: string | null | undefined;
|
|
238
|
+
}, {
|
|
239
|
+
id: number;
|
|
240
|
+
created_at: string;
|
|
241
|
+
operation: string;
|
|
242
|
+
agent_id?: string | null | undefined;
|
|
243
|
+
memory_type?: string | null | undefined;
|
|
244
|
+
memory_id?: string | null | undefined;
|
|
245
|
+
user_id?: string | null | undefined;
|
|
246
|
+
details?: Record<string, unknown> | undefined;
|
|
247
|
+
ip_address?: string | null | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
type AuditEntry = z.infer<typeof AuditEntry>;
|
|
250
|
+
declare const AuditPageResponse: z.ZodObject<{
|
|
251
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
252
|
+
id: z.ZodNumber;
|
|
253
|
+
agent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
254
|
+
user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
255
|
+
operation: z.ZodString;
|
|
256
|
+
memory_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
257
|
+
memory_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
258
|
+
details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
259
|
+
ip_address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
260
|
+
created_at: z.ZodString;
|
|
261
|
+
}, "strip", z.ZodTypeAny, {
|
|
262
|
+
id: number;
|
|
263
|
+
created_at: string;
|
|
264
|
+
operation: string;
|
|
265
|
+
details: Record<string, unknown>;
|
|
266
|
+
agent_id?: string | null | undefined;
|
|
267
|
+
memory_type?: string | null | undefined;
|
|
268
|
+
memory_id?: string | null | undefined;
|
|
269
|
+
user_id?: string | null | undefined;
|
|
270
|
+
ip_address?: string | null | undefined;
|
|
271
|
+
}, {
|
|
272
|
+
id: number;
|
|
273
|
+
created_at: string;
|
|
274
|
+
operation: string;
|
|
275
|
+
agent_id?: string | null | undefined;
|
|
276
|
+
memory_type?: string | null | undefined;
|
|
277
|
+
memory_id?: string | null | undefined;
|
|
278
|
+
user_id?: string | null | undefined;
|
|
279
|
+
details?: Record<string, unknown> | undefined;
|
|
280
|
+
ip_address?: string | null | undefined;
|
|
281
|
+
}>, "many">;
|
|
282
|
+
total: z.ZodNumber;
|
|
283
|
+
page: z.ZodNumber;
|
|
284
|
+
page_size: z.ZodNumber;
|
|
285
|
+
has_next: z.ZodBoolean;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
entries: {
|
|
288
|
+
id: number;
|
|
289
|
+
created_at: string;
|
|
290
|
+
operation: string;
|
|
291
|
+
details: Record<string, unknown>;
|
|
292
|
+
agent_id?: string | null | undefined;
|
|
293
|
+
memory_type?: string | null | undefined;
|
|
294
|
+
memory_id?: string | null | undefined;
|
|
295
|
+
user_id?: string | null | undefined;
|
|
296
|
+
ip_address?: string | null | undefined;
|
|
297
|
+
}[];
|
|
298
|
+
total: number;
|
|
299
|
+
page: number;
|
|
300
|
+
page_size: number;
|
|
301
|
+
has_next: boolean;
|
|
302
|
+
}, {
|
|
303
|
+
entries: {
|
|
304
|
+
id: number;
|
|
305
|
+
created_at: string;
|
|
306
|
+
operation: string;
|
|
307
|
+
agent_id?: string | null | undefined;
|
|
308
|
+
memory_type?: string | null | undefined;
|
|
309
|
+
memory_id?: string | null | undefined;
|
|
310
|
+
user_id?: string | null | undefined;
|
|
311
|
+
details?: Record<string, unknown> | undefined;
|
|
312
|
+
ip_address?: string | null | undefined;
|
|
313
|
+
}[];
|
|
314
|
+
total: number;
|
|
315
|
+
page: number;
|
|
316
|
+
page_size: number;
|
|
317
|
+
has_next: boolean;
|
|
318
|
+
}>;
|
|
319
|
+
type AuditPageResponse = z.infer<typeof AuditPageResponse>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Z3rno TypeScript SDK client.
|
|
323
|
+
*
|
|
324
|
+
* Thin fetch wrapper — no database drivers, no embedding providers.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* const client = new Z3rnoClient({ baseUrl: "http://localhost:8000", apiKey: "z3rno_sk_..." });
|
|
329
|
+
* const memory = await client.store({ agentId: "agent-1", content: "User prefers dark mode" });
|
|
330
|
+
* const results = await client.recall({ agentId: "agent-1", query: "user preferences" });
|
|
331
|
+
* await client.forget({ agentId: "agent-1", memoryId: memory.id });
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
interface Z3rnoClientConfig {
|
|
336
|
+
baseUrl: string;
|
|
337
|
+
apiKey: string;
|
|
338
|
+
timeout?: number;
|
|
339
|
+
maxRetries?: number;
|
|
340
|
+
}
|
|
341
|
+
declare class Z3rnoClient {
|
|
342
|
+
private baseUrl;
|
|
343
|
+
private apiKey;
|
|
344
|
+
private timeout;
|
|
345
|
+
constructor(config: Z3rnoClientConfig);
|
|
346
|
+
store(request: StoreMemoryRequest): Promise<MemoryResponse>;
|
|
347
|
+
recall(params: {
|
|
348
|
+
agentId: string;
|
|
349
|
+
query?: string;
|
|
350
|
+
memoryType?: string;
|
|
351
|
+
filters?: Record<string, unknown>;
|
|
352
|
+
topK?: number;
|
|
353
|
+
similarityThreshold?: number;
|
|
354
|
+
}): Promise<RecallResponse>;
|
|
355
|
+
forget(params: {
|
|
356
|
+
agentId: string;
|
|
357
|
+
memoryId?: string;
|
|
358
|
+
memoryIds?: string[];
|
|
359
|
+
hardDelete?: boolean;
|
|
360
|
+
cascade?: boolean;
|
|
361
|
+
reason?: string;
|
|
362
|
+
}): Promise<ForgetResponse>;
|
|
363
|
+
audit(params?: {
|
|
364
|
+
agentId?: string;
|
|
365
|
+
page?: number;
|
|
366
|
+
pageSize?: number;
|
|
367
|
+
}): Promise<AuditPageResponse>;
|
|
368
|
+
private request;
|
|
369
|
+
private handleResponse;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Z3rno SDK error hierarchy.
|
|
374
|
+
*/
|
|
375
|
+
declare class Z3rnoError extends Error {
|
|
376
|
+
statusCode?: number;
|
|
377
|
+
constructor(message: string, statusCode?: number);
|
|
378
|
+
}
|
|
379
|
+
declare class AuthenticationError extends Z3rnoError {
|
|
380
|
+
constructor(message: string);
|
|
381
|
+
}
|
|
382
|
+
declare class RateLimitError extends Z3rnoError {
|
|
383
|
+
retryAfter: number;
|
|
384
|
+
constructor(message: string, retryAfter?: number);
|
|
385
|
+
}
|
|
386
|
+
declare class ValidationError extends Z3rnoError {
|
|
387
|
+
constructor(message: string, statusCode?: number);
|
|
388
|
+
}
|
|
389
|
+
declare class NotFoundError extends Z3rnoError {
|
|
390
|
+
constructor(message: string);
|
|
391
|
+
}
|
|
392
|
+
declare class ServerError extends Z3rnoError {
|
|
393
|
+
constructor(message: string, statusCode?: number);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export { AuditEntry, AuditPageResponse, AuthenticationError, ForgetResponse, MemoryResponse, MemoryType, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RelationshipType, ServerError, StoreMemoryRequest, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoError };
|