@z3rno/sdk 0.9.0 → 0.23.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/dist/index.d.cts DELETED
@@ -1,2127 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Zod schemas and inferred TypeScript types for the Z3rno API.
5
- *
6
- * Each export is a dual: a Zod schema (used for runtime validation) and an
7
- * identically-named TypeScript type (used at compile time). Request schemas
8
- * validate client-side input; response schemas validate server payloads.
9
- *
10
- * @module models
11
- */
12
-
13
- /**
14
- * Memory type enum.
15
- *
16
- * Controls how a memory is stored, indexed, and decayed.
17
- *
18
- * - `working` — Short-lived scratchpad memory (high decay rate).
19
- * - `episodic` — Event-based memory tied to a specific interaction.
20
- * - `semantic` — Long-term factual knowledge.
21
- * - `procedural` — How-to or process knowledge.
22
- */
23
- declare const MemoryType: z.ZodEnum<["working", "episodic", "semantic", "procedural"]>;
24
- /** Memory type: `"working"` | `"episodic"` | `"semantic"` | `"procedural"`. */
25
- type MemoryType = z.infer<typeof MemoryType>;
26
- /**
27
- * Relationship type enum.
28
- *
29
- * Describes how two memories are related in the knowledge graph.
30
- *
31
- * - `derived_from` — This memory was created from another.
32
- * - `contradicts` — This memory conflicts with another.
33
- * - `supports` — This memory reinforces another.
34
- * - `supersedes` — This memory replaces another.
35
- * - `related_to` — General association.
36
- * - `caused_by` — Causal relationship.
37
- */
38
- declare const RelationshipType: z.ZodEnum<["derived_from", "contradicts", "supports", "supersedes", "related_to", "caused_by"]>;
39
- /** Relationship type between two memories. */
40
- type RelationshipType = z.infer<typeof RelationshipType>;
41
- /**
42
- * Retrieval strategy for `recall({ strategy: ... })` — Phase C.
43
- *
44
- * `AUTO` is the default; the server's LLM router picks one of the
45
- * others when configured. Use an explicit value to bypass routing.
46
- */
47
- declare const RetrievalStrategy: z.ZodEnum<["AUTO", "VECTOR", "LEXICAL", "GRAPH", "TRIPLET", "TRACE", "TEMPORAL", "ASK", "CYPHER"]>;
48
- /** Retrieval strategy enum (canonical UPPERCASE names). */
49
- type RetrievalStrategy = z.infer<typeof RetrievalStrategy>;
50
- /**
51
- * Schema for storing a new memory.
52
- *
53
- * @example
54
- * ```ts
55
- * const request = StoreMemoryRequest.parse({
56
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
57
- * content: "User prefers dark mode",
58
- * memoryType: "semantic",
59
- * });
60
- * ```
61
- */
62
- declare const StoreMemoryRequest: z.ZodObject<{
63
- /** UUID of the agent that owns this memory. */
64
- agentId: z.ZodString;
65
- /** The text content to store (1 to 100,000 characters). */
66
- content: z.ZodString;
67
- /** Category of memory. Defaults to `"episodic"`. */
68
- memoryType: z.ZodDefault<z.ZodEnum<["working", "episodic", "semantic", "procedural"]>>;
69
- /** Optional UUID of the user associated with this memory. */
70
- userId: z.ZodOptional<z.ZodString>;
71
- /** Arbitrary key-value metadata attached to the memory. */
72
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
73
- /** Relationships to other memories in the knowledge graph. */
74
- relationships: z.ZodDefault<z.ZodArray<z.ZodObject<{
75
- /** UUID of the target memory. */
76
- targetMemoryId: z.ZodString;
77
- /** Type of relationship to the target memory. */
78
- relationshipType: z.ZodEnum<["derived_from", "contradicts", "supports", "supersedes", "related_to", "caused_by"]>;
79
- /** Relationship strength from 0 to 1. Defaults to 1.0. */
80
- weight: z.ZodDefault<z.ZodNumber>;
81
- /** Arbitrary metadata for the relationship edge. */
82
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
83
- }, "strip", z.ZodTypeAny, {
84
- metadata: Record<string, unknown>;
85
- targetMemoryId: string;
86
- relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
87
- weight: number;
88
- }, {
89
- targetMemoryId: string;
90
- relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
91
- metadata?: Record<string, unknown> | undefined;
92
- weight?: number | undefined;
93
- }>, "many">>;
94
- /** Time-to-live in seconds. Memory auto-deletes after this duration. */
95
- ttlSeconds: z.ZodOptional<z.ZodNumber>;
96
- /** Importance score from 0 to 1. Influences recall ranking. */
97
- importance: z.ZodOptional<z.ZodNumber>;
98
- }, "strip", z.ZodTypeAny, {
99
- agentId: string;
100
- content: string;
101
- memoryType: "working" | "episodic" | "semantic" | "procedural";
102
- metadata: Record<string, unknown>;
103
- relationships: {
104
- metadata: Record<string, unknown>;
105
- targetMemoryId: string;
106
- relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
107
- weight: number;
108
- }[];
109
- userId?: string | undefined;
110
- ttlSeconds?: number | undefined;
111
- importance?: number | undefined;
112
- }, {
113
- agentId: string;
114
- content: string;
115
- memoryType?: "working" | "episodic" | "semantic" | "procedural" | undefined;
116
- userId?: string | undefined;
117
- metadata?: Record<string, unknown> | undefined;
118
- relationships?: {
119
- targetMemoryId: string;
120
- relationshipType: "derived_from" | "contradicts" | "supports" | "supersedes" | "related_to" | "caused_by";
121
- metadata?: Record<string, unknown> | undefined;
122
- weight?: number | undefined;
123
- }[] | undefined;
124
- ttlSeconds?: number | undefined;
125
- importance?: number | undefined;
126
- }>;
127
- /** Parsed type for a store-memory request. */
128
- type StoreMemoryRequest = z.infer<typeof StoreMemoryRequest>;
129
- /**
130
- * Schema for a single memory object returned by the API.
131
- *
132
- * Used by {@link Z3rnoClient.store}, {@link Z3rnoClient.getMemory}, and
133
- * {@link Z3rnoClient.updateMemory}.
134
- */
135
- declare const MemoryResponse: z.ZodObject<{
136
- /** Unique identifier for this memory. */
137
- id: z.ZodString;
138
- /** UUID of the owning agent. */
139
- agent_id: z.ZodString;
140
- /** Text content of the memory. */
141
- content: z.ZodString;
142
- /** Category of the memory. */
143
- memory_type: z.ZodString;
144
- /** Server-computed importance score (0-1). */
145
- importance_score: z.ZodNumber;
146
- /** Number of times this memory has been recalled. */
147
- recall_count: z.ZodNumber;
148
- /** Name of the embedding model used, if any. */
149
- embedding_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
150
- /** ISO 8601 creation timestamp. */
151
- created_at: z.ZodString;
152
- /** Arbitrary metadata attached to the memory. */
153
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
154
- }, "strip", z.ZodTypeAny, {
155
- content: string;
156
- metadata: Record<string, unknown>;
157
- id: string;
158
- agent_id: string;
159
- memory_type: string;
160
- importance_score: number;
161
- recall_count: number;
162
- created_at: string;
163
- embedding_model?: string | null | undefined;
164
- }, {
165
- content: string;
166
- id: string;
167
- agent_id: string;
168
- memory_type: string;
169
- importance_score: number;
170
- recall_count: number;
171
- created_at: string;
172
- metadata?: Record<string, unknown> | undefined;
173
- embedding_model?: string | null | undefined;
174
- }>;
175
- /** Parsed type for a memory response. */
176
- type MemoryResponse = z.infer<typeof MemoryResponse>;
177
- /**
178
- * Schema for a single item in recall results.
179
- *
180
- * Each item includes similarity, importance, and relevance scores
181
- * computed by the server's ranking algorithm.
182
- */
183
- declare const RecallResultItem: z.ZodObject<{
184
- /** Unique identifier of the recalled memory. */
185
- memory_id: z.ZodString;
186
- /** Text content of the memory. */
187
- content: z.ZodString;
188
- /** Optional server-generated summary. */
189
- summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
- /** Category of the memory. */
191
- memory_type: z.ZodString;
192
- /** Cosine similarity to the query (0-1). */
193
- similarity_score: z.ZodNumber;
194
- /** Server-computed importance score (0-1). */
195
- importance_score: z.ZodNumber;
196
- /** Combined relevance score used for ranking (0-1). */
197
- relevance_score: z.ZodNumber;
198
- /** Number of times this memory has been recalled. */
199
- recall_count: z.ZodNumber;
200
- /** ISO 8601 creation timestamp. */
201
- created_at: z.ZodString;
202
- /** Arbitrary metadata attached to the memory. */
203
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
204
- /**
205
- * Phase C per-source signals — e.g. `{ vector: 0.83, lexical: 0.61 }`.
206
- * Optional so older servers (v0.7.x) keep parsing.
207
- */
208
- score_components: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
209
- }, "strip", z.ZodTypeAny, {
210
- content: string;
211
- metadata: Record<string, unknown>;
212
- memory_type: string;
213
- importance_score: number;
214
- recall_count: number;
215
- created_at: string;
216
- memory_id: string;
217
- similarity_score: number;
218
- relevance_score: number;
219
- score_components: Record<string, number>;
220
- summary?: string | null | undefined;
221
- }, {
222
- content: string;
223
- memory_type: string;
224
- importance_score: number;
225
- recall_count: number;
226
- created_at: string;
227
- memory_id: string;
228
- similarity_score: number;
229
- relevance_score: number;
230
- metadata?: Record<string, unknown> | undefined;
231
- summary?: string | null | undefined;
232
- score_components?: Record<string, number> | undefined;
233
- }>;
234
- /** Parsed type for a single recall result item. */
235
- type RecallResultItem = z.infer<typeof RecallResultItem>;
236
- /**
237
- * Schema for the full recall response.
238
- *
239
- * Contains an array of ranked results and the total count of matches.
240
- */
241
- declare const RecallResponse: z.ZodObject<{
242
- /** Ranked list of matching memories. */
243
- results: z.ZodArray<z.ZodObject<{
244
- /** Unique identifier of the recalled memory. */
245
- memory_id: z.ZodString;
246
- /** Text content of the memory. */
247
- content: z.ZodString;
248
- /** Optional server-generated summary. */
249
- summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
250
- /** Category of the memory. */
251
- memory_type: z.ZodString;
252
- /** Cosine similarity to the query (0-1). */
253
- similarity_score: z.ZodNumber;
254
- /** Server-computed importance score (0-1). */
255
- importance_score: z.ZodNumber;
256
- /** Combined relevance score used for ranking (0-1). */
257
- relevance_score: z.ZodNumber;
258
- /** Number of times this memory has been recalled. */
259
- recall_count: z.ZodNumber;
260
- /** ISO 8601 creation timestamp. */
261
- created_at: z.ZodString;
262
- /** Arbitrary metadata attached to the memory. */
263
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
264
- /**
265
- * Phase C per-source signals — e.g. `{ vector: 0.83, lexical: 0.61 }`.
266
- * Optional so older servers (v0.7.x) keep parsing.
267
- */
268
- score_components: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
269
- }, "strip", z.ZodTypeAny, {
270
- content: string;
271
- metadata: Record<string, unknown>;
272
- memory_type: string;
273
- importance_score: number;
274
- recall_count: number;
275
- created_at: string;
276
- memory_id: string;
277
- similarity_score: number;
278
- relevance_score: number;
279
- score_components: Record<string, number>;
280
- summary?: string | null | undefined;
281
- }, {
282
- content: string;
283
- memory_type: string;
284
- importance_score: number;
285
- recall_count: number;
286
- created_at: string;
287
- memory_id: string;
288
- similarity_score: number;
289
- relevance_score: number;
290
- metadata?: Record<string, unknown> | undefined;
291
- summary?: string | null | undefined;
292
- score_components?: Record<string, number> | undefined;
293
- }>, "many">;
294
- /** Total number of matches (may exceed `topK`). */
295
- total: z.ZodNumber;
296
- /** The query that was searched, if any. */
297
- query: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
- /** Phase C: strategy that actually ran (after AUTO routing + re-rank). */
299
- strategy_used: z.ZodDefault<z.ZodString>;
300
- /** Phase C: AUTO's candidate list (e.g. `["AUTO->GRAPH"]`). */
301
- strategies_considered: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
302
- /** Phase C: whether the cross-encoder re-rank ran. */
303
- reranked: z.ZodDefault<z.ZodBoolean>;
304
- /** Phase C: end-to-end recall latency on the server (ms). */
305
- elapsed_ms: z.ZodDefault<z.ZodNumber>;
306
- }, "strip", z.ZodTypeAny, {
307
- results: {
308
- content: string;
309
- metadata: Record<string, unknown>;
310
- memory_type: string;
311
- importance_score: number;
312
- recall_count: number;
313
- created_at: string;
314
- memory_id: string;
315
- similarity_score: number;
316
- relevance_score: number;
317
- score_components: Record<string, number>;
318
- summary?: string | null | undefined;
319
- }[];
320
- total: number;
321
- strategy_used: string;
322
- strategies_considered: string[];
323
- reranked: boolean;
324
- elapsed_ms: number;
325
- query?: string | null | undefined;
326
- }, {
327
- results: {
328
- content: string;
329
- memory_type: string;
330
- importance_score: number;
331
- recall_count: number;
332
- created_at: string;
333
- memory_id: string;
334
- similarity_score: number;
335
- relevance_score: number;
336
- metadata?: Record<string, unknown> | undefined;
337
- summary?: string | null | undefined;
338
- score_components?: Record<string, number> | undefined;
339
- }[];
340
- total: number;
341
- query?: string | null | undefined;
342
- strategy_used?: string | undefined;
343
- strategies_considered?: string[] | undefined;
344
- reranked?: boolean | undefined;
345
- elapsed_ms?: number | undefined;
346
- }>;
347
- /** Parsed type for a recall response. */
348
- type RecallResponse = z.infer<typeof RecallResponse>;
349
- /**
350
- * Schema for the forget (delete) response.
351
- *
352
- * Reports how many memories were deleted and whether cascade was applied.
353
- */
354
- declare const ForgetResponse: z.ZodObject<{
355
- /** Number of memories deleted. */
356
- deleted_count: z.ZodNumber;
357
- /** Whether a hard delete was performed. */
358
- hard_deleted: z.ZodBoolean;
359
- /** Number of related memories deleted via cascade. */
360
- cascade_count: z.ZodNumber;
361
- /** IDs of all deleted memories. */
362
- memory_ids: z.ZodArray<z.ZodString, "many">;
363
- }, "strip", z.ZodTypeAny, {
364
- deleted_count: number;
365
- hard_deleted: boolean;
366
- cascade_count: number;
367
- memory_ids: string[];
368
- }, {
369
- deleted_count: number;
370
- hard_deleted: boolean;
371
- cascade_count: number;
372
- memory_ids: string[];
373
- }>;
374
- /** Parsed type for a forget response. */
375
- type ForgetResponse = z.infer<typeof ForgetResponse>;
376
- /**
377
- * Schema for a single audit log entry.
378
- *
379
- * Audit entries record every operation performed on the agent's memories.
380
- */
381
- declare const AuditEntry: z.ZodEffects<z.ZodObject<{
382
- /** Auto-incrementing audit entry ID. */
383
- id: z.ZodNumber;
384
- /** UUID of the agent, if applicable. */
385
- agent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
386
- /** UUID of the user, if applicable. */
387
- user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
388
- /** Operation type (e.g., `"store"`, `"recall"`, `"forget"`). */
389
- operation: z.ZodString;
390
- /** UUID of the affected memory, if applicable. */
391
- memory_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
392
- /** Memory type of the affected memory, if applicable. */
393
- memory_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
394
- /** Additional details about the operation. */
395
- details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
396
- /** IP address of the caller, if available. */
397
- ip_address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
398
- /** ISO 8601 timestamp of the operation. */
399
- created_at: z.ZodString;
400
- }, "strip", z.ZodTypeAny, {
401
- id: number;
402
- created_at: string;
403
- operation: string;
404
- details: Record<string, unknown>;
405
- agent_id?: string | null | undefined;
406
- memory_type?: string | null | undefined;
407
- memory_id?: string | null | undefined;
408
- user_id?: string | null | undefined;
409
- ip_address?: string | null | undefined;
410
- }, {
411
- id: number;
412
- created_at: string;
413
- operation: string;
414
- agent_id?: string | null | undefined;
415
- memory_type?: string | null | undefined;
416
- memory_id?: string | null | undefined;
417
- user_id?: string | null | undefined;
418
- details?: Record<string, unknown> | undefined;
419
- ip_address?: string | null | undefined;
420
- }>, {
421
- /** Alias for `created_at`. Added in v0.8.1 for cross-SDK naming parity. */
422
- timestamp: string;
423
- id: number;
424
- created_at: string;
425
- operation: string;
426
- details: Record<string, unknown>;
427
- agent_id?: string | null | undefined;
428
- memory_type?: string | null | undefined;
429
- memory_id?: string | null | undefined;
430
- user_id?: string | null | undefined;
431
- ip_address?: string | null | undefined;
432
- }, {
433
- id: number;
434
- created_at: string;
435
- operation: string;
436
- agent_id?: string | null | undefined;
437
- memory_type?: string | null | undefined;
438
- memory_id?: string | null | undefined;
439
- user_id?: string | null | undefined;
440
- details?: Record<string, unknown> | undefined;
441
- ip_address?: string | null | undefined;
442
- }>;
443
- /** Parsed type for an audit entry. */
444
- type AuditEntry = z.infer<typeof AuditEntry>;
445
- /**
446
- * Schema for a paginated audit log response.
447
- *
448
- * Supports cursor-based pagination via `page` and `page_size`.
449
- */
450
- declare const AuditPageResponse: z.ZodEffects<z.ZodObject<{
451
- /** Audit entries on this page. */
452
- entries: z.ZodArray<z.ZodEffects<z.ZodObject<{
453
- /** Auto-incrementing audit entry ID. */
454
- id: z.ZodNumber;
455
- /** UUID of the agent, if applicable. */
456
- agent_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
457
- /** UUID of the user, if applicable. */
458
- user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
459
- /** Operation type (e.g., `"store"`, `"recall"`, `"forget"`). */
460
- operation: z.ZodString;
461
- /** UUID of the affected memory, if applicable. */
462
- memory_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
463
- /** Memory type of the affected memory, if applicable. */
464
- memory_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
465
- /** Additional details about the operation. */
466
- details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
467
- /** IP address of the caller, if available. */
468
- ip_address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
469
- /** ISO 8601 timestamp of the operation. */
470
- created_at: z.ZodString;
471
- }, "strip", z.ZodTypeAny, {
472
- id: number;
473
- created_at: string;
474
- operation: string;
475
- details: Record<string, unknown>;
476
- agent_id?: string | null | undefined;
477
- memory_type?: string | null | undefined;
478
- memory_id?: string | null | undefined;
479
- user_id?: string | null | undefined;
480
- ip_address?: string | null | undefined;
481
- }, {
482
- id: number;
483
- created_at: string;
484
- operation: string;
485
- agent_id?: string | null | undefined;
486
- memory_type?: string | null | undefined;
487
- memory_id?: string | null | undefined;
488
- user_id?: string | null | undefined;
489
- details?: Record<string, unknown> | undefined;
490
- ip_address?: string | null | undefined;
491
- }>, {
492
- /** Alias for `created_at`. Added in v0.8.1 for cross-SDK naming parity. */
493
- timestamp: string;
494
- id: number;
495
- created_at: string;
496
- operation: string;
497
- details: Record<string, unknown>;
498
- agent_id?: string | null | undefined;
499
- memory_type?: string | null | undefined;
500
- memory_id?: string | null | undefined;
501
- user_id?: string | null | undefined;
502
- ip_address?: string | null | undefined;
503
- }, {
504
- id: number;
505
- created_at: string;
506
- operation: string;
507
- agent_id?: string | null | undefined;
508
- memory_type?: string | null | undefined;
509
- memory_id?: string | null | undefined;
510
- user_id?: string | null | undefined;
511
- details?: Record<string, unknown> | undefined;
512
- ip_address?: string | null | undefined;
513
- }>, "many">;
514
- /** Total number of matching audit entries. */
515
- total: z.ZodNumber;
516
- /** Current page number (1-indexed). */
517
- page: z.ZodNumber;
518
- /** Number of entries per page. */
519
- page_size: z.ZodNumber;
520
- /** Whether more pages are available. */
521
- has_next: z.ZodBoolean;
522
- }, "strip", z.ZodTypeAny, {
523
- entries: {
524
- /** Alias for `created_at`. Added in v0.8.1 for cross-SDK naming parity. */
525
- timestamp: string;
526
- id: number;
527
- created_at: string;
528
- operation: string;
529
- details: Record<string, unknown>;
530
- agent_id?: string | null | undefined;
531
- memory_type?: string | null | undefined;
532
- memory_id?: string | null | undefined;
533
- user_id?: string | null | undefined;
534
- ip_address?: string | null | undefined;
535
- }[];
536
- total: number;
537
- page: number;
538
- page_size: number;
539
- has_next: boolean;
540
- }, {
541
- entries: {
542
- id: number;
543
- created_at: string;
544
- operation: string;
545
- agent_id?: string | null | undefined;
546
- memory_type?: string | null | undefined;
547
- memory_id?: string | null | undefined;
548
- user_id?: string | null | undefined;
549
- details?: Record<string, unknown> | undefined;
550
- ip_address?: string | null | undefined;
551
- }[];
552
- total: number;
553
- page: number;
554
- page_size: number;
555
- has_next: boolean;
556
- }>, {
557
- /** Alias for `total`. Added in v0.8.1 for cross-SDK naming parity. */
558
- total_count: number;
559
- entries: {
560
- /** Alias for `created_at`. Added in v0.8.1 for cross-SDK naming parity. */
561
- timestamp: string;
562
- id: number;
563
- created_at: string;
564
- operation: string;
565
- details: Record<string, unknown>;
566
- agent_id?: string | null | undefined;
567
- memory_type?: string | null | undefined;
568
- memory_id?: string | null | undefined;
569
- user_id?: string | null | undefined;
570
- ip_address?: string | null | undefined;
571
- }[];
572
- total: number;
573
- page: number;
574
- page_size: number;
575
- has_next: boolean;
576
- }, {
577
- entries: {
578
- id: number;
579
- created_at: string;
580
- operation: string;
581
- agent_id?: string | null | undefined;
582
- memory_type?: string | null | undefined;
583
- memory_id?: string | null | undefined;
584
- user_id?: string | null | undefined;
585
- details?: Record<string, unknown> | undefined;
586
- ip_address?: string | null | undefined;
587
- }[];
588
- total: number;
589
- page: number;
590
- page_size: number;
591
- has_next: boolean;
592
- }>;
593
- /** Parsed type for a paginated audit response. */
594
- type AuditPageResponse = z.infer<typeof AuditPageResponse>;
595
- /**
596
- * Schema for the batch store response.
597
- *
598
- * Returned by {@link Z3rnoClient.storeBatch} after storing multiple memories.
599
- */
600
- declare const BatchStoreResponse: z.ZodObject<{
601
- /** Array of stored memory objects. */
602
- results: z.ZodArray<z.ZodObject<{
603
- /** Unique identifier for this memory. */
604
- id: z.ZodString;
605
- /** UUID of the owning agent. */
606
- agent_id: z.ZodString;
607
- /** Text content of the memory. */
608
- content: z.ZodString;
609
- /** Category of the memory. */
610
- memory_type: z.ZodString;
611
- /** Server-computed importance score (0-1). */
612
- importance_score: z.ZodNumber;
613
- /** Number of times this memory has been recalled. */
614
- recall_count: z.ZodNumber;
615
- /** Name of the embedding model used, if any. */
616
- embedding_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
617
- /** ISO 8601 creation timestamp. */
618
- created_at: z.ZodString;
619
- /** Arbitrary metadata attached to the memory. */
620
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
621
- }, "strip", z.ZodTypeAny, {
622
- content: string;
623
- metadata: Record<string, unknown>;
624
- id: string;
625
- agent_id: string;
626
- memory_type: string;
627
- importance_score: number;
628
- recall_count: number;
629
- created_at: string;
630
- embedding_model?: string | null | undefined;
631
- }, {
632
- content: string;
633
- id: string;
634
- agent_id: string;
635
- memory_type: string;
636
- importance_score: number;
637
- recall_count: number;
638
- created_at: string;
639
- metadata?: Record<string, unknown> | undefined;
640
- embedding_model?: string | null | undefined;
641
- }>, "many">;
642
- /** Number of memories successfully stored. */
643
- stored_count: z.ZodNumber;
644
- }, "strip", z.ZodTypeAny, {
645
- results: {
646
- content: string;
647
- metadata: Record<string, unknown>;
648
- id: string;
649
- agent_id: string;
650
- memory_type: string;
651
- importance_score: number;
652
- recall_count: number;
653
- created_at: string;
654
- embedding_model?: string | null | undefined;
655
- }[];
656
- stored_count: number;
657
- }, {
658
- results: {
659
- content: string;
660
- id: string;
661
- agent_id: string;
662
- memory_type: string;
663
- importance_score: number;
664
- recall_count: number;
665
- created_at: string;
666
- metadata?: Record<string, unknown> | undefined;
667
- embedding_model?: string | null | undefined;
668
- }[];
669
- stored_count: number;
670
- }>;
671
- /** Parsed type for a batch store response. */
672
- type BatchStoreResponse = z.infer<typeof BatchStoreResponse>;
673
- /**
674
- * Schema for a single version of a memory (temporal versioning).
675
- *
676
- * Each version represents the state of a memory during a specific time range.
677
- */
678
- declare const MemoryVersion: z.ZodObject<{
679
- /** Version identifier. */
680
- id: z.ZodString;
681
- /** Text content at this version. */
682
- content: z.ZodString;
683
- /** Memory type at this version. */
684
- memory_type: z.ZodString;
685
- /** Importance score at this version. */
686
- importance_score: z.ZodNumber;
687
- /** ISO 8601 timestamp when this version became active. */
688
- valid_from: z.ZodString;
689
- /** ISO 8601 timestamp when this version was superseded, or null if current. */
690
- valid_to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
691
- /** Metadata at this version. */
692
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
693
- }, "strip", z.ZodTypeAny, {
694
- content: string;
695
- metadata: Record<string, unknown>;
696
- id: string;
697
- memory_type: string;
698
- importance_score: number;
699
- valid_from: string;
700
- valid_to?: string | null | undefined;
701
- }, {
702
- content: string;
703
- id: string;
704
- memory_type: string;
705
- importance_score: number;
706
- valid_from: string;
707
- metadata?: Record<string, unknown> | undefined;
708
- valid_to?: string | null | undefined;
709
- }>;
710
- /** Parsed type for a memory version. */
711
- type MemoryVersion = z.infer<typeof MemoryVersion>;
712
- /**
713
- * Schema for the memory history response.
714
- *
715
- * Contains all temporal versions of a single memory, ordered chronologically.
716
- */
717
- declare const MemoryHistoryResponse: z.ZodObject<{
718
- /** UUID of the memory. */
719
- memory_id: z.ZodString;
720
- /** Chronologically ordered list of versions. */
721
- versions: z.ZodArray<z.ZodObject<{
722
- /** Version identifier. */
723
- id: z.ZodString;
724
- /** Text content at this version. */
725
- content: z.ZodString;
726
- /** Memory type at this version. */
727
- memory_type: z.ZodString;
728
- /** Importance score at this version. */
729
- importance_score: z.ZodNumber;
730
- /** ISO 8601 timestamp when this version became active. */
731
- valid_from: z.ZodString;
732
- /** ISO 8601 timestamp when this version was superseded, or null if current. */
733
- valid_to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
734
- /** Metadata at this version. */
735
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
736
- }, "strip", z.ZodTypeAny, {
737
- content: string;
738
- metadata: Record<string, unknown>;
739
- id: string;
740
- memory_type: string;
741
- importance_score: number;
742
- valid_from: string;
743
- valid_to?: string | null | undefined;
744
- }, {
745
- content: string;
746
- id: string;
747
- memory_type: string;
748
- importance_score: number;
749
- valid_from: string;
750
- metadata?: Record<string, unknown> | undefined;
751
- valid_to?: string | null | undefined;
752
- }>, "many">;
753
- /** Total number of versions. */
754
- total: z.ZodNumber;
755
- }, "strip", z.ZodTypeAny, {
756
- memory_id: string;
757
- total: number;
758
- versions: {
759
- content: string;
760
- metadata: Record<string, unknown>;
761
- id: string;
762
- memory_type: string;
763
- importance_score: number;
764
- valid_from: string;
765
- valid_to?: string | null | undefined;
766
- }[];
767
- }, {
768
- memory_id: string;
769
- total: number;
770
- versions: {
771
- content: string;
772
- id: string;
773
- memory_type: string;
774
- importance_score: number;
775
- valid_from: string;
776
- metadata?: Record<string, unknown> | undefined;
777
- valid_to?: string | null | undefined;
778
- }[];
779
- }>;
780
- /** Parsed type for a memory history response. */
781
- type MemoryHistoryResponse = z.infer<typeof MemoryHistoryResponse>;
782
- /**
783
- * Schema for a session response.
784
- *
785
- * Sessions group related memory operations (e.g., a conversation turn).
786
- */
787
- declare const SessionResponse: z.ZodObject<{
788
- /** Unique session identifier. */
789
- session_id: z.ZodString;
790
- /** UUID of the agent this session belongs to. */
791
- agent_id: z.ZodString;
792
- /** Type of session (e.g., `"conversation"`). */
793
- session_type: z.ZodString;
794
- /** ISO 8601 timestamp when the session started. */
795
- started_at: z.ZodString;
796
- /** Arbitrary session metadata. */
797
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
798
- }, "strip", z.ZodTypeAny, {
799
- metadata: Record<string, unknown>;
800
- agent_id: string;
801
- session_id: string;
802
- session_type: string;
803
- started_at: string;
804
- }, {
805
- agent_id: string;
806
- session_id: string;
807
- session_type: string;
808
- started_at: string;
809
- metadata?: Record<string, unknown> | undefined;
810
- }>;
811
- /** Parsed type for a session response. */
812
- type SessionResponse = z.infer<typeof SessionResponse>;
813
- /**
814
- * Schema for the end-session response.
815
- *
816
- * Returned when a session is closed, including summary statistics.
817
- */
818
- declare const EndSessionResponse: z.ZodObject<{
819
- /** The session that was ended. */
820
- session_id: z.ZodString;
821
- /** ISO 8601 timestamp when the session ended. */
822
- ended_at: z.ZodString;
823
- /** Total duration of the session in seconds. */
824
- duration_seconds: z.ZodNumber;
825
- /** Number of memories created during the session. */
826
- memory_count: z.ZodNumber;
827
- }, "strip", z.ZodTypeAny, {
828
- session_id: string;
829
- ended_at: string;
830
- duration_seconds: number;
831
- memory_count: number;
832
- }, {
833
- session_id: string;
834
- ended_at: string;
835
- duration_seconds: number;
836
- memory_count: number;
837
- }>;
838
- /** Parsed type for an end-session response. */
839
- type EndSessionResponse = z.infer<typeof EndSessionResponse>;
840
- /** Response to POST /v1/ingest — the enqueue ack. */
841
- declare const IngestJobResponse: z.ZodObject<{
842
- job_id: z.ZodString;
843
- kind: z.ZodString;
844
- status: z.ZodString;
845
- dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
846
- enqueued_at: z.ZodString;
847
- }, "strip", z.ZodTypeAny, {
848
- status: string;
849
- job_id: string;
850
- kind: string;
851
- enqueued_at: string;
852
- dataset_id?: string | null | undefined;
853
- }, {
854
- status: string;
855
- job_id: string;
856
- kind: string;
857
- enqueued_at: string;
858
- dataset_id?: string | null | undefined;
859
- }>;
860
- type IngestJobResponse = z.infer<typeof IngestJobResponse>;
861
- /** Full state from GET /v1/ingest/{job_id}. */
862
- declare const IngestJobStatusResponse: z.ZodObject<{
863
- job_id: z.ZodString;
864
- agent_id: z.ZodString;
865
- dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
866
- kind: z.ZodString;
867
- status: z.ZodString;
868
- source_uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
869
- content_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
870
- filename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
871
- file_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
872
- memory_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
873
- memos_written: z.ZodDefault<z.ZodNumber>;
874
- distill_job_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
875
- codegraph_memos_written: z.ZodDefault<z.ZodNumber>;
876
- codegraph_edges_written: z.ZodDefault<z.ZodNumber>;
877
- error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
878
- warnings: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
879
- started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
880
- completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
881
- created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
882
- updated_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
883
- }, "strip", z.ZodTypeAny, {
884
- status: string;
885
- agent_id: string;
886
- memory_ids: string[];
887
- job_id: string;
888
- kind: string;
889
- memos_written: number;
890
- codegraph_memos_written: number;
891
- codegraph_edges_written: number;
892
- warnings: Record<string, unknown>[];
893
- created_at?: string | null | undefined;
894
- started_at?: string | null | undefined;
895
- dataset_id?: string | null | undefined;
896
- source_uri?: string | null | undefined;
897
- content_type?: string | null | undefined;
898
- filename?: string | null | undefined;
899
- file_size?: number | null | undefined;
900
- distill_job_id?: string | null | undefined;
901
- error?: string | null | undefined;
902
- completed_at?: string | null | undefined;
903
- updated_at?: string | null | undefined;
904
- }, {
905
- status: string;
906
- agent_id: string;
907
- job_id: string;
908
- kind: string;
909
- created_at?: string | null | undefined;
910
- memory_ids?: string[] | undefined;
911
- started_at?: string | null | undefined;
912
- dataset_id?: string | null | undefined;
913
- source_uri?: string | null | undefined;
914
- content_type?: string | null | undefined;
915
- filename?: string | null | undefined;
916
- file_size?: number | null | undefined;
917
- memos_written?: number | undefined;
918
- distill_job_id?: string | null | undefined;
919
- codegraph_memos_written?: number | undefined;
920
- codegraph_edges_written?: number | undefined;
921
- error?: string | null | undefined;
922
- warnings?: Record<string, unknown>[] | undefined;
923
- completed_at?: string | null | undefined;
924
- updated_at?: string | null | undefined;
925
- }>;
926
- type IngestJobStatusResponse = z.infer<typeof IngestJobStatusResponse>;
927
- /** Distill enqueue ack. */
928
- declare const DistillJobResponse: z.ZodObject<{
929
- job_id: z.ZodString;
930
- status: z.ZodString;
931
- memory_ids: z.ZodArray<z.ZodString, "many">;
932
- enqueued_at: z.ZodString;
933
- }, "strip", z.ZodTypeAny, {
934
- status: string;
935
- memory_ids: string[];
936
- job_id: string;
937
- enqueued_at: string;
938
- }, {
939
- status: string;
940
- memory_ids: string[];
941
- job_id: string;
942
- enqueued_at: string;
943
- }>;
944
- type DistillJobResponse = z.infer<typeof DistillJobResponse>;
945
- /** Full distill job state. */
946
- declare const DistillJobStatusResponse: z.ZodObject<{
947
- job_id: z.ZodString;
948
- agent_id: z.ZodString;
949
- status: z.ZodString;
950
- model: z.ZodString;
951
- memory_ids: z.ZodArray<z.ZodString, "many">;
952
- chunk_size: z.ZodNumber;
953
- chunk_overlap: z.ZodNumber;
954
- max_concurrency: z.ZodNumber;
955
- chunks_total: z.ZodNumber;
956
- chunks_failed: z.ZodNumber;
957
- entities_extracted: z.ZodNumber;
958
- relationships_extracted: z.ZodNumber;
959
- memos_written: z.ZodNumber;
960
- error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
961
- started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
962
- completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
963
- created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
964
- updated_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
965
- }, "strip", z.ZodTypeAny, {
966
- status: string;
967
- agent_id: string;
968
- memory_ids: string[];
969
- job_id: string;
970
- memos_written: number;
971
- model: string;
972
- chunk_size: number;
973
- chunk_overlap: number;
974
- max_concurrency: number;
975
- chunks_total: number;
976
- chunks_failed: number;
977
- entities_extracted: number;
978
- relationships_extracted: number;
979
- created_at?: string | null | undefined;
980
- started_at?: string | null | undefined;
981
- error?: string | null | undefined;
982
- completed_at?: string | null | undefined;
983
- updated_at?: string | null | undefined;
984
- }, {
985
- status: string;
986
- agent_id: string;
987
- memory_ids: string[];
988
- job_id: string;
989
- memos_written: number;
990
- model: string;
991
- chunk_size: number;
992
- chunk_overlap: number;
993
- max_concurrency: number;
994
- chunks_total: number;
995
- chunks_failed: number;
996
- entities_extracted: number;
997
- relationships_extracted: number;
998
- created_at?: string | null | undefined;
999
- started_at?: string | null | undefined;
1000
- error?: string | null | undefined;
1001
- completed_at?: string | null | undefined;
1002
- updated_at?: string | null | undefined;
1003
- }>;
1004
- type DistillJobStatusResponse = z.infer<typeof DistillJobStatusResponse>;
1005
- /** Refine enqueue ack. */
1006
- declare const RefineJobResponse: z.ZodObject<{
1007
- job_id: z.ZodString;
1008
- status: z.ZodString;
1009
- dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1010
- enqueued_at: z.ZodString;
1011
- }, "strip", z.ZodTypeAny, {
1012
- status: string;
1013
- job_id: string;
1014
- enqueued_at: string;
1015
- dataset_id?: string | null | undefined;
1016
- }, {
1017
- status: string;
1018
- job_id: string;
1019
- enqueued_at: string;
1020
- dataset_id?: string | null | undefined;
1021
- }>;
1022
- type RefineJobResponse = z.infer<typeof RefineJobResponse>;
1023
- /** Full refine job state. */
1024
- declare const RefineJobStatusResponse: z.ZodObject<{
1025
- job_id: z.ZodString;
1026
- status: z.ZodString;
1027
- dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1028
- trigger: z.ZodString;
1029
- memos_scanned: z.ZodDefault<z.ZodNumber>;
1030
- memos_deduped: z.ZodDefault<z.ZodNumber>;
1031
- edges_reweighted: z.ZodDefault<z.ZodNumber>;
1032
- edges_pruned: z.ZodDefault<z.ZodNumber>;
1033
- feedback_drained: z.ZodDefault<z.ZodNumber>;
1034
- job_metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1035
- error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1036
- started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1037
- completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1038
- created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1039
- updated_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1040
- }, "strip", z.ZodTypeAny, {
1041
- status: string;
1042
- job_id: string;
1043
- trigger: string;
1044
- memos_scanned: number;
1045
- memos_deduped: number;
1046
- edges_reweighted: number;
1047
- edges_pruned: number;
1048
- feedback_drained: number;
1049
- job_metadata: Record<string, unknown>;
1050
- created_at?: string | null | undefined;
1051
- started_at?: string | null | undefined;
1052
- dataset_id?: string | null | undefined;
1053
- error?: string | null | undefined;
1054
- completed_at?: string | null | undefined;
1055
- updated_at?: string | null | undefined;
1056
- }, {
1057
- status: string;
1058
- job_id: string;
1059
- trigger: string;
1060
- created_at?: string | null | undefined;
1061
- started_at?: string | null | undefined;
1062
- dataset_id?: string | null | undefined;
1063
- error?: string | null | undefined;
1064
- completed_at?: string | null | undefined;
1065
- updated_at?: string | null | undefined;
1066
- memos_scanned?: number | undefined;
1067
- memos_deduped?: number | undefined;
1068
- edges_reweighted?: number | undefined;
1069
- edges_pruned?: number | undefined;
1070
- feedback_drained?: number | undefined;
1071
- job_metadata?: Record<string, unknown> | undefined;
1072
- }>;
1073
- type RefineJobStatusResponse = z.infer<typeof RefineJobStatusResponse>;
1074
- /** Conversation metadata. */
1075
- declare const ConversationResponse: z.ZodObject<{
1076
- id: z.ZodString;
1077
- agent_id: z.ZodString;
1078
- user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1079
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1080
- summary_cadence: z.ZodNumber;
1081
- turn_count: z.ZodNumber;
1082
- last_summary_turn: z.ZodNumber;
1083
- metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1084
- created_at: z.ZodString;
1085
- updated_at: z.ZodString;
1086
- }, "strip", z.ZodTypeAny, {
1087
- metadata: Record<string, unknown>;
1088
- id: string;
1089
- agent_id: string;
1090
- created_at: string;
1091
- updated_at: string;
1092
- summary_cadence: number;
1093
- turn_count: number;
1094
- last_summary_turn: number;
1095
- user_id?: string | null | undefined;
1096
- title?: string | null | undefined;
1097
- }, {
1098
- id: string;
1099
- agent_id: string;
1100
- created_at: string;
1101
- updated_at: string;
1102
- summary_cadence: number;
1103
- turn_count: number;
1104
- last_summary_turn: number;
1105
- metadata?: Record<string, unknown> | undefined;
1106
- user_id?: string | null | undefined;
1107
- title?: string | null | undefined;
1108
- }>;
1109
- type ConversationResponse = z.infer<typeof ConversationResponse>;
1110
- /** Result of POST /v1/conversations/{id}/turns. */
1111
- declare const TurnAddResponse: z.ZodObject<{
1112
- turn_index: z.ZodNumber;
1113
- needs_summary: z.ZodBoolean;
1114
- }, "strip", z.ZodTypeAny, {
1115
- turn_index: number;
1116
- needs_summary: boolean;
1117
- }, {
1118
- turn_index: number;
1119
- needs_summary: boolean;
1120
- }>;
1121
- type TurnAddResponse = z.infer<typeof TurnAddResponse>;
1122
- /** One turn within a conversation. */
1123
- declare const TurnResponse: z.ZodObject<{
1124
- memory_id: z.ZodString;
1125
- turn_index: z.ZodNumber;
1126
- turn_role: z.ZodString;
1127
- content: z.ZodString;
1128
- created_at: z.ZodString;
1129
- }, "strip", z.ZodTypeAny, {
1130
- content: string;
1131
- created_at: string;
1132
- memory_id: string;
1133
- turn_index: number;
1134
- turn_role: string;
1135
- }, {
1136
- content: string;
1137
- created_at: string;
1138
- memory_id: string;
1139
- turn_index: number;
1140
- turn_role: string;
1141
- }>;
1142
- type TurnResponse = z.infer<typeof TurnResponse>;
1143
- /** Paginated turn list. */
1144
- declare const TurnListResponse: z.ZodObject<{
1145
- turns: z.ZodArray<z.ZodObject<{
1146
- memory_id: z.ZodString;
1147
- turn_index: z.ZodNumber;
1148
- turn_role: z.ZodString;
1149
- content: z.ZodString;
1150
- created_at: z.ZodString;
1151
- }, "strip", z.ZodTypeAny, {
1152
- content: string;
1153
- created_at: string;
1154
- memory_id: string;
1155
- turn_index: number;
1156
- turn_role: string;
1157
- }, {
1158
- content: string;
1159
- created_at: string;
1160
- memory_id: string;
1161
- turn_index: number;
1162
- turn_role: string;
1163
- }>, "many">;
1164
- total: z.ZodNumber;
1165
- conversation_id: z.ZodString;
1166
- }, "strip", z.ZodTypeAny, {
1167
- total: number;
1168
- turns: {
1169
- content: string;
1170
- created_at: string;
1171
- memory_id: string;
1172
- turn_index: number;
1173
- turn_role: string;
1174
- }[];
1175
- conversation_id: string;
1176
- }, {
1177
- total: number;
1178
- turns: {
1179
- content: string;
1180
- created_at: string;
1181
- memory_id: string;
1182
- turn_index: number;
1183
- turn_role: string;
1184
- }[];
1185
- conversation_id: string;
1186
- }>;
1187
- type TurnListResponse = z.infer<typeof TurnListResponse>;
1188
- /** Per-tenant budget caps. Zero means inherit server default. */
1189
- declare const TenantBudgets: z.ZodObject<{
1190
- daily_tokens: z.ZodNumber;
1191
- daily_llm_calls: z.ZodNumber;
1192
- daily_embeddings: z.ZodNumber;
1193
- monthly_tokens: z.ZodNumber;
1194
- monthly_llm_calls: z.ZodNumber;
1195
- monthly_embeddings: z.ZodNumber;
1196
- }, "strip", z.ZodTypeAny, {
1197
- daily_tokens: number;
1198
- daily_llm_calls: number;
1199
- daily_embeddings: number;
1200
- monthly_tokens: number;
1201
- monthly_llm_calls: number;
1202
- monthly_embeddings: number;
1203
- }, {
1204
- daily_tokens: number;
1205
- daily_llm_calls: number;
1206
- daily_embeddings: number;
1207
- monthly_tokens: number;
1208
- monthly_llm_calls: number;
1209
- monthly_embeddings: number;
1210
- }>;
1211
- type TenantBudgets = z.infer<typeof TenantBudgets>;
1212
- /** Server response: stored overrides + resolved effective caps. */
1213
- declare const TenantBudgetsView: z.ZodObject<{
1214
- overrides: z.ZodObject<{
1215
- daily_tokens: z.ZodNumber;
1216
- daily_llm_calls: z.ZodNumber;
1217
- daily_embeddings: z.ZodNumber;
1218
- monthly_tokens: z.ZodNumber;
1219
- monthly_llm_calls: z.ZodNumber;
1220
- monthly_embeddings: z.ZodNumber;
1221
- }, "strip", z.ZodTypeAny, {
1222
- daily_tokens: number;
1223
- daily_llm_calls: number;
1224
- daily_embeddings: number;
1225
- monthly_tokens: number;
1226
- monthly_llm_calls: number;
1227
- monthly_embeddings: number;
1228
- }, {
1229
- daily_tokens: number;
1230
- daily_llm_calls: number;
1231
- daily_embeddings: number;
1232
- monthly_tokens: number;
1233
- monthly_llm_calls: number;
1234
- monthly_embeddings: number;
1235
- }>;
1236
- effective: z.ZodObject<{
1237
- daily_tokens: z.ZodNumber;
1238
- daily_llm_calls: z.ZodNumber;
1239
- daily_embeddings: z.ZodNumber;
1240
- monthly_tokens: z.ZodNumber;
1241
- monthly_llm_calls: z.ZodNumber;
1242
- monthly_embeddings: z.ZodNumber;
1243
- }, "strip", z.ZodTypeAny, {
1244
- daily_tokens: number;
1245
- daily_llm_calls: number;
1246
- daily_embeddings: number;
1247
- monthly_tokens: number;
1248
- monthly_llm_calls: number;
1249
- monthly_embeddings: number;
1250
- }, {
1251
- daily_tokens: number;
1252
- daily_llm_calls: number;
1253
- daily_embeddings: number;
1254
- monthly_tokens: number;
1255
- monthly_llm_calls: number;
1256
- monthly_embeddings: number;
1257
- }>;
1258
- }, "strip", z.ZodTypeAny, {
1259
- overrides: {
1260
- daily_tokens: number;
1261
- daily_llm_calls: number;
1262
- daily_embeddings: number;
1263
- monthly_tokens: number;
1264
- monthly_llm_calls: number;
1265
- monthly_embeddings: number;
1266
- };
1267
- effective: {
1268
- daily_tokens: number;
1269
- daily_llm_calls: number;
1270
- daily_embeddings: number;
1271
- monthly_tokens: number;
1272
- monthly_llm_calls: number;
1273
- monthly_embeddings: number;
1274
- };
1275
- }, {
1276
- overrides: {
1277
- daily_tokens: number;
1278
- daily_llm_calls: number;
1279
- daily_embeddings: number;
1280
- monthly_tokens: number;
1281
- monthly_llm_calls: number;
1282
- monthly_embeddings: number;
1283
- };
1284
- effective: {
1285
- daily_tokens: number;
1286
- daily_llm_calls: number;
1287
- daily_embeddings: number;
1288
- monthly_tokens: number;
1289
- monthly_llm_calls: number;
1290
- monthly_embeddings: number;
1291
- };
1292
- }>;
1293
- type TenantBudgetsView = z.infer<typeof TenantBudgetsView>;
1294
-
1295
- /**
1296
- * Z3rno TypeScript SDK client.
1297
- *
1298
- * Thin fetch wrapper — no database drivers, no embedding providers.
1299
- * Works in Node.js 18+, Deno, Bun, and modern browsers (any runtime
1300
- * with a global `fetch` and `AbortController`).
1301
- *
1302
- * @module client
1303
- *
1304
- * @example
1305
- * ```ts
1306
- * const client = new Z3rnoClient({ baseUrl: "http://localhost:8000", apiKey: "z3rno_sk_..." });
1307
- * const memory = await client.store({ agentId: "agent-1", content: "User prefers dark mode" });
1308
- * const results = await client.recall({ agentId: "agent-1", query: "user preferences" });
1309
- * await client.forget({ agentId: "agent-1", memoryId: memory.id });
1310
- * ```
1311
- */
1312
-
1313
- /**
1314
- * Configuration options for the {@link Z3rnoClient}.
1315
- *
1316
- * All fields are optional. When omitted, the client reads from environment
1317
- * variables (`Z3RNO_BASE_URL`, `Z3RNO_API_KEY`) or uses sensible defaults.
1318
- */
1319
- interface Z3rnoClientConfig {
1320
- /**
1321
- * Base URL of the Z3rno API.
1322
- *
1323
- * Falls back to the `Z3RNO_BASE_URL` environment variable, then
1324
- * to `"https://api.z3rno.dev"`.
1325
- */
1326
- baseUrl?: string;
1327
- /**
1328
- * API key for authentication.
1329
- *
1330
- * Falls back to the `Z3RNO_API_KEY` environment variable, then to
1331
- * an empty string (unauthenticated).
1332
- */
1333
- apiKey?: string;
1334
- /**
1335
- * Request timeout in milliseconds.
1336
- *
1337
- * @defaultValue 30000 (30 seconds)
1338
- */
1339
- timeout?: number;
1340
- /**
1341
- * Maximum number of retry attempts for retryable errors (5xx, 429,
1342
- * network failures, timeouts).
1343
- *
1344
- * @defaultValue 3
1345
- */
1346
- maxRetries?: number;
1347
- /**
1348
- * Custom fetch implementation.
1349
- *
1350
- * Defaults to `globalThis.fetch`. Override to use `undici`, `node-fetch`,
1351
- * or a test double.
1352
- *
1353
- * @defaultValue globalThis.fetch
1354
- */
1355
- fetch?: typeof globalThis.fetch;
1356
- /**
1357
- * Intercept outgoing requests before they are sent.
1358
- *
1359
- * Use this to add custom headers, log requests, or collect metrics.
1360
- * The callback receives the URL and the `RequestInit` and must return
1361
- * a (possibly modified) `RequestInit`.
1362
- */
1363
- onRequest?: (url: string, init: RequestInit) => RequestInit;
1364
- /**
1365
- * Intercept responses before they are processed.
1366
- *
1367
- * Use this for logging, metrics, or response transformation.
1368
- * The callback receives the `Response` and must return a `Response`.
1369
- */
1370
- onResponse?: (response: Response) => Response;
1371
- }
1372
- /**
1373
- * Client for the Z3rno AI agent memory API.
1374
- *
1375
- * Uses the standard Fetch API under the hood, making it compatible with
1376
- * Node.js 18+, Deno, Bun, and modern browsers. All responses are
1377
- * validated at runtime with Zod schemas.
1378
- *
1379
- * @example
1380
- * ```ts
1381
- * import { Z3rnoClient } from "@z3rno/sdk";
1382
- *
1383
- * const client = new Z3rnoClient({
1384
- * baseUrl: "http://localhost:8000",
1385
- * apiKey: "z3rno_sk_test_...",
1386
- * });
1387
- *
1388
- * // Store a memory
1389
- * const mem = await client.store({
1390
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
1391
- * content: "User prefers dark mode",
1392
- * });
1393
- *
1394
- * // Recall relevant memories
1395
- * const results = await client.recall({
1396
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
1397
- * query: "user preferences",
1398
- * });
1399
- * ```
1400
- */
1401
- declare class Z3rnoClient {
1402
- private baseUrl;
1403
- private apiKey;
1404
- private timeout;
1405
- private maxRetries;
1406
- private fetchImpl;
1407
- private onRequest?;
1408
- private onResponse?;
1409
- /**
1410
- * Creates a new Z3rno client instance.
1411
- *
1412
- * @param config - Client configuration options. All fields are optional.
1413
- *
1414
- * @example
1415
- * ```ts
1416
- * // Explicit configuration
1417
- * const client = new Z3rnoClient({
1418
- * baseUrl: "http://localhost:8000",
1419
- * apiKey: "z3rno_sk_test_...",
1420
- * timeout: 10000,
1421
- * maxRetries: 2,
1422
- * });
1423
- *
1424
- * // Or rely on environment variables (Z3RNO_BASE_URL, Z3RNO_API_KEY)
1425
- * const client = new Z3rnoClient();
1426
- * ```
1427
- */
1428
- constructor(config?: Z3rnoClientConfig);
1429
- /**
1430
- * Stores a new memory for an agent.
1431
- *
1432
- * The server generates an embedding for the content and stores it in
1433
- * the vector database. The memory is immediately available for recall.
1434
- *
1435
- * @param request - The memory to store.
1436
- * @returns The stored memory, including the server-generated ID and scores.
1437
- * @throws {@link AuthenticationError} If the API key is invalid.
1438
- * @throws {@link ValidationError} If the request body is invalid.
1439
- * @throws {@link Z3rnoTimeoutError} If the request times out.
1440
- *
1441
- * @example
1442
- * ```ts
1443
- * const memory = await client.store({
1444
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
1445
- * content: "User prefers dark mode",
1446
- * memoryType: "semantic",
1447
- * metadata: { source: "settings-page" },
1448
- * });
1449
- * console.log(memory.id); // "mem-abc123"
1450
- * ```
1451
- */
1452
- store(request: StoreMemoryRequest): Promise<MemoryResponse>;
1453
- /**
1454
- * Recalls memories by semantic similarity to a query.
1455
- *
1456
- * Returns a ranked list of memories sorted by a combined relevance score
1457
- * that factors in similarity, importance, and recency.
1458
- *
1459
- * @param params - Recall parameters including the query and filters.
1460
- * @param params.agentId - UUID of the agent whose memories to search.
1461
- * @param params.query - Natural-language query for semantic search.
1462
- * @param params.memoryType - Filter by memory type.
1463
- * @param params.filters - Additional metadata filters.
1464
- * @param params.topK - Maximum results to return (default 10).
1465
- * @param params.similarityThreshold - Minimum similarity score (default 0).
1466
- * @returns Ranked recall results with similarity scores.
1467
- * @throws {@link AuthenticationError} If the API key is invalid.
1468
- * @throws {@link Z3rnoTimeoutError} If the request times out.
1469
- *
1470
- * @example
1471
- * ```ts
1472
- * const results = await client.recall({
1473
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
1474
- * query: "user preferences",
1475
- * topK: 5,
1476
- * similarityThreshold: 0.7,
1477
- * });
1478
- * for (const item of results.results) {
1479
- * console.log(`${item.content} (score: ${item.relevance_score})`);
1480
- * }
1481
- * ```
1482
- */
1483
- recall(params: {
1484
- agentId: string;
1485
- query?: string;
1486
- memoryType?: string;
1487
- /**
1488
- * v0.21.2 — JSONB metadata containment filter
1489
- * (`metadata @> :metadata_filter` server-side). Renamed from
1490
- * `filters`; the old name is still accepted via `filters` below
1491
- * but emits a deprecation warning.
1492
- */
1493
- metadataFilter?: Record<string, unknown>;
1494
- /** @deprecated Use `metadataFilter` instead. */
1495
- filters?: Record<string, unknown>;
1496
- /**
1497
- * v0.21.1 — scope by end-user id (the `memories.user_id`
1498
- * column). Multi-user agents use this for per-user recall
1499
- * isolation. Real WHERE predicate, not just audit context.
1500
- */
1501
- userId?: string;
1502
- topK?: number;
1503
- similarityThreshold?: number;
1504
- /**
1505
- * Phase C: retrieval strategy. One of `AUTO | VECTOR | LEXICAL |
1506
- * GRAPH | TRIPLET | TRACE | TEMPORAL | ASK | CYPHER`. Default
1507
- * `"AUTO"` — server's LLM router picks per query.
1508
- */
1509
- strategy?: string;
1510
- /**
1511
- * Phase C: cross-encoder re-ranking. When `true`, the server
1512
- * re-ranks the strategy's top results. Requires
1513
- * `sentence-transformers` on the server side.
1514
- */
1515
- rerank?: boolean;
1516
- /**
1517
- * Phase G slice 2: scope recall to a single conversation. Older
1518
- * servers ignore the field.
1519
- */
1520
- conversationId?: string;
1521
- }): Promise<RecallResponse>;
1522
- /**
1523
- * Forgets (deletes) one or more memories.
1524
- *
1525
- * By default, performs a soft delete (marks as deleted but retains data).
1526
- * Set `hardDelete: true` for permanent removal. Use `cascade: true` to
1527
- * also delete related memories in the knowledge graph.
1528
- *
1529
- * @param params - Forget parameters.
1530
- * @param params.agentId - UUID of the agent that owns the memories.
1531
- * @param params.memoryId - UUID of a single memory to delete.
1532
- * @param params.memoryIds - UUIDs of multiple memories to delete.
1533
- * @param params.hardDelete - Permanently delete (default false).
1534
- * @param params.cascade - Delete related memories too (default false).
1535
- * @param params.reason - Reason for deletion (stored in audit log).
1536
- * @returns Summary of the deletion operation.
1537
- * @throws {@link AuthenticationError} If the API key is invalid.
1538
- * @throws {@link NotFoundError} If the specified memory does not exist.
1539
- *
1540
- * @example
1541
- * ```ts
1542
- * const result = await client.forget({
1543
- * agentId: "550e8400-e29b-41d4-a716-446655440000",
1544
- * memoryId: "mem-abc123",
1545
- * hardDelete: true,
1546
- * reason: "User requested data deletion",
1547
- * });
1548
- * console.log(`Deleted ${result.deleted_count} memories`);
1549
- * ```
1550
- */
1551
- forget(params: {
1552
- agentId: string;
1553
- memoryId?: string;
1554
- memoryIds?: string[];
1555
- hardDelete?: boolean;
1556
- cascade?: boolean;
1557
- reason?: string;
1558
- }): Promise<ForgetResponse>;
1559
- /**
1560
- * Retrieves a single memory by its ID.
1561
- *
1562
- * @param memoryId - The unique identifier of the memory to retrieve.
1563
- * @returns The full memory object.
1564
- * @throws {@link NotFoundError} If no memory exists with the given ID.
1565
- * @throws {@link AuthenticationError} If the API key is invalid.
1566
- *
1567
- * @example
1568
- * ```ts
1569
- * const memory = await client.getMemory("mem-abc123");
1570
- * console.log(memory.content);
1571
- * console.log(memory.importance_score);
1572
- * ```
1573
- */
1574
- getMemory(memoryId: string): Promise<MemoryResponse>;
1575
- /**
1576
- * Stores multiple memories in a single API call.
1577
- *
1578
- * More efficient than calling {@link store} in a loop. All memories are
1579
- * processed atomically on the server.
1580
- *
1581
- * @param memories - Array of memories to store.
1582
- * @returns The stored memories and a count of how many were created.
1583
- * @throws {@link ValidationError} If any memory in the batch is invalid.
1584
- * @throws {@link AuthenticationError} If the API key is invalid.
1585
- *
1586
- * @example
1587
- * ```ts
1588
- * const result = await client.storeBatch([
1589
- * { agentId: "agent-1", content: "Fact one" },
1590
- * { agentId: "agent-1", content: "Fact two", memoryType: "semantic" },
1591
- * ]);
1592
- * console.log(`Stored ${result.stored_count} memories`);
1593
- * ```
1594
- */
1595
- storeBatch(memories: StoreMemoryRequest[]): Promise<BatchStoreResponse>;
1596
- /**
1597
- * Retrieves the full version history of a memory.
1598
- *
1599
- * Z3rno uses temporal versioning — every update creates a new version
1600
- * rather than overwriting. This method returns all versions ordered
1601
- * chronologically.
1602
- *
1603
- * @param memoryId - The unique identifier of the memory.
1604
- * @returns All versions of the memory with validity timestamps.
1605
- * @throws {@link NotFoundError} If no memory exists with the given ID.
1606
- * @throws {@link AuthenticationError} If the API key is invalid.
1607
- *
1608
- * @example
1609
- * ```ts
1610
- * const history = await client.getMemoryHistory("mem-abc123");
1611
- * for (const version of history.versions) {
1612
- * console.log(`${version.valid_from}: ${version.content}`);
1613
- * }
1614
- * ```
1615
- */
1616
- getMemoryHistory(memoryId: string): Promise<MemoryHistoryResponse>;
1617
- /**
1618
- * Updates an existing memory's content, metadata, or importance.
1619
- *
1620
- * Creates a new temporal version of the memory. The previous version
1621
- * remains accessible via {@link getMemoryHistory}.
1622
- *
1623
- * @param memoryId - The unique identifier of the memory to update.
1624
- * @param updates - Fields to update (only provided fields are changed).
1625
- * @param updates.content - New text content.
1626
- * @param updates.metadata - New metadata (replaces existing metadata).
1627
- * @param updates.importance - New importance score (0-1).
1628
- * @returns The updated memory object.
1629
- * @throws {@link NotFoundError} If no memory exists with the given ID.
1630
- * @throws {@link ValidationError} If the update values are invalid.
1631
- * @throws {@link AuthenticationError} If the API key is invalid.
1632
- *
1633
- * @example
1634
- * ```ts
1635
- * const updated = await client.updateMemory("mem-abc123", {
1636
- * content: "User now prefers light mode",
1637
- * importance: 0.9,
1638
- * });
1639
- * ```
1640
- */
1641
- updateMemory(memoryId: string, updates: {
1642
- content?: string;
1643
- metadata?: Record<string, unknown>;
1644
- importance?: number;
1645
- }): Promise<MemoryResponse>;
1646
- /**
1647
- * Starts a new session for grouping related memory operations.
1648
- *
1649
- * Sessions are useful for tracking conversation turns or task boundaries.
1650
- * Memories created during a session are automatically associated with it.
1651
- *
1652
- * @param params - Session parameters.
1653
- * @param params.agentId - UUID of the agent to start the session for.
1654
- * @param params.sessionType - Type of session (default `"conversation"`).
1655
- * @returns The created session with its ID and start time.
1656
- * @throws {@link AuthenticationError} If the API key is invalid.
1657
- *
1658
- * @example
1659
- * ```ts
1660
- * const session = await client.startSession({ agentId: "agent-1" });
1661
- * console.log(`Session started: ${session.session_id}`);
1662
- * // ... perform operations ...
1663
- * await client.endSession(session.session_id);
1664
- * ```
1665
- */
1666
- startSession(params: {
1667
- agentId: string;
1668
- sessionType?: string;
1669
- }): Promise<SessionResponse>;
1670
- /**
1671
- * Ends an active session.
1672
- *
1673
- * Returns summary statistics including the session duration and the
1674
- * number of memories created during the session.
1675
- *
1676
- * @param sessionId - The unique identifier of the session to end.
1677
- * @returns Session summary with duration and memory count.
1678
- * @throws {@link NotFoundError} If no active session exists with the given ID.
1679
- * @throws {@link AuthenticationError} If the API key is invalid.
1680
- *
1681
- * @example
1682
- * ```ts
1683
- * const summary = await client.endSession("sess-abc123");
1684
- * console.log(`Session lasted ${summary.duration_seconds}s, ${summary.memory_count} memories`);
1685
- * ```
1686
- */
1687
- endSession(sessionId: string): Promise<EndSessionResponse>;
1688
- /**
1689
- * Retrieves a paginated audit log of memory operations.
1690
- *
1691
- * The audit log records every store, recall, forget, and update operation
1692
- * performed by any agent. Useful for compliance, debugging, and analytics.
1693
- *
1694
- * @param params - Optional pagination and filter parameters.
1695
- * @param params.agentId - Filter by agent UUID.
1696
- * @param params.page - Page number (1-indexed).
1697
- * @param params.pageSize - Number of entries per page.
1698
- * @returns A page of audit log entries with pagination metadata.
1699
- * @throws {@link AuthenticationError} If the API key is invalid.
1700
- *
1701
- * @example
1702
- * ```ts
1703
- * const page = await client.audit({ agentId: "agent-1", page: 1, pageSize: 20 });
1704
- * for (const entry of page.entries) {
1705
- * console.log(`${entry.created_at}: ${entry.operation} on ${entry.memory_id}`);
1706
- * }
1707
- * if (page.has_next) {
1708
- * const nextPage = await client.audit({ agentId: "agent-1", page: 2 });
1709
- * }
1710
- * ```
1711
- */
1712
- audit(params?: {
1713
- agentId?: string;
1714
- page?: number;
1715
- pageSize?: number;
1716
- }): Promise<AuditPageResponse>;
1717
- ingestText(params: {
1718
- agentId: string;
1719
- text: string;
1720
- datasetId?: string;
1721
- }): Promise<IngestJobResponse>;
1722
- ingestUrl(params: {
1723
- agentId: string;
1724
- url: string;
1725
- datasetId?: string;
1726
- }): Promise<IngestJobResponse>;
1727
- getIngestStatus(jobId: string): Promise<IngestJobStatusResponse>;
1728
- distill(params: {
1729
- agentId: string;
1730
- memoryIds: string[];
1731
- chunkSize?: number;
1732
- chunkOverlap?: number;
1733
- maxConcurrency?: number;
1734
- summaryStyle?: string;
1735
- includeSummary?: boolean;
1736
- }): Promise<DistillJobResponse>;
1737
- getDistillStatus(jobId: string): Promise<DistillJobStatusResponse>;
1738
- refine(params?: {
1739
- datasetId?: string;
1740
- }): Promise<RefineJobResponse>;
1741
- getRefineStatus(jobId: string): Promise<RefineJobStatusResponse>;
1742
- /**
1743
- * Open a new conversation. Returns the conversation row including
1744
- * the assigned `id`, which subsequent `recall`s and `addTurn`s
1745
- * reference. The `summaryCadence` controls how often the server
1746
- * flags the conversation for summarization.
1747
- */
1748
- createConversation(params: {
1749
- agentId: string;
1750
- userId?: string;
1751
- title?: string;
1752
- summaryCadence?: number;
1753
- metadata?: Record<string, unknown>;
1754
- }): Promise<ConversationResponse>;
1755
- getConversation(conversationId: string): Promise<ConversationResponse>;
1756
- /**
1757
- * Stamp an existing Memo as the next turn of the conversation.
1758
- * Returns the assigned `turn_index` plus `needs_summary` — when
1759
- * `true`, the conversation has crossed its cadence threshold.
1760
- */
1761
- addTurn(conversationId: string, params: {
1762
- memoryId: string;
1763
- turnRole: string;
1764
- }): Promise<TurnAddResponse>;
1765
- /**
1766
- * v0.19.3 — soft-delete a conversation. Existing turn Memos stay
1767
- * queryable through standard recall; the conversation itself stops
1768
- * accepting turns and its endpoints 404. Idempotent.
1769
- */
1770
- deleteConversation(conversationId: string): Promise<void>;
1771
- listTurns(conversationId: string, params?: {
1772
- afterTurn?: number;
1773
- limit?: number;
1774
- }): Promise<TurnListResponse>;
1775
- /**
1776
- * Cross-tenant admin sub-namespace (v0.22.1, slice 21.3).
1777
- *
1778
- * Pairs with z3rno-server v0.22.1's `/v1/tenants/{orgId}/budgets`
1779
- * surface. Requires `SUPERADMIN_ENABLED=true` on the server and
1780
- * the client to be configured with the matching superadmin API
1781
- * key. Methods raise `AuthenticationError` (401) or a generic
1782
- * `Z3rnoError` (403) otherwise.
1783
- */
1784
- get admin(): AdminAPI;
1785
- /**
1786
- * Read this org's stored budget overrides + resolved effective caps.
1787
- * Auth: any admin/write/read member of the calling org.
1788
- */
1789
- getMyBudgets(): Promise<TenantBudgetsView>;
1790
- /**
1791
- * Replace this org's budget overrides. Zero / missing fields
1792
- * inherit the server default. Auth: admin/write only.
1793
- */
1794
- setMyBudgets(budgets: Partial<TenantBudgets>): Promise<TenantBudgetsView>;
1795
- private request;
1796
- private sleep;
1797
- private handleResponse;
1798
- }
1799
- /**
1800
- * Cross-tenant admin sub-namespace exposed via `client.admin`.
1801
- *
1802
- * Construction captures the parent client's `request` method as a
1803
- * bound closure — no privileged access to the class internals, just
1804
- * a function reference. That's deliberate: the namespace is
1805
- * dependency-injected the same way a stub would be, so test doubles
1806
- * can swap it out without touching the parent client.
1807
- */
1808
- declare class AdminAPI {
1809
- private readonly request;
1810
- constructor(request: (method: string, path: string, body?: unknown) => Promise<unknown>);
1811
- /**
1812
- * Read another tenant's budget overrides + effective caps.
1813
- *
1814
- * Requires `SUPERADMIN_ENABLED=true` server-side and the client to
1815
- * be configured with the superadmin API key.
1816
- */
1817
- getBudgets(orgId: string): Promise<TenantBudgetsView>;
1818
- /**
1819
- * Replace another tenant's budget overrides. Zero / missing fields
1820
- * inherit the server default.
1821
- */
1822
- setBudgets(orgId: string, budgets: Partial<TenantBudgets>): Promise<TenantBudgetsView>;
1823
- }
1824
-
1825
- /**
1826
- * Z3rno SDK error hierarchy.
1827
- *
1828
- * All errors thrown by the SDK extend {@link Z3rnoError}, which itself extends
1829
- * the built-in `Error` class. This lets callers catch broadly (`Z3rnoError`)
1830
- * or narrowly (`AuthenticationError`, `RateLimitError`, etc.).
1831
- *
1832
- * @module errors
1833
- */
1834
- /**
1835
- * Base error class for all Z3rno SDK errors.
1836
- *
1837
- * Every error produced by the SDK is an instance of this class, so you can
1838
- * use a single `catch (e) { if (e instanceof Z3rnoError) ... }` guard to
1839
- * handle them all.
1840
- *
1841
- * @example
1842
- * ```ts
1843
- * try {
1844
- * await client.store({ agentId: "...", content: "..." });
1845
- * } catch (e) {
1846
- * if (e instanceof Z3rnoError) {
1847
- * console.error(`Z3rno error (${e.statusCode}): ${e.message}`);
1848
- * }
1849
- * }
1850
- * ```
1851
- */
1852
- declare class Z3rnoError extends Error {
1853
- /** HTTP status code returned by the server, if applicable. */
1854
- statusCode?: number;
1855
- /**
1856
- * @param message - Human-readable description of the error.
1857
- * @param statusCode - HTTP status code associated with the error, if any.
1858
- */
1859
- constructor(message: string, statusCode?: number);
1860
- }
1861
- /**
1862
- * Thrown when the API key is missing, invalid, or revoked (HTTP 401).
1863
- *
1864
- * @example
1865
- * ```ts
1866
- * try {
1867
- * await client.store({ agentId: "...", content: "..." });
1868
- * } catch (e) {
1869
- * if (e instanceof AuthenticationError) {
1870
- * console.error("Check your API key");
1871
- * }
1872
- * }
1873
- * ```
1874
- */
1875
- declare class AuthenticationError extends Z3rnoError {
1876
- /**
1877
- * @param message - Description of the authentication failure.
1878
- */
1879
- constructor(message: string);
1880
- }
1881
- /**
1882
- * Thrown when the client exceeds the API rate limit (HTTP 429).
1883
- *
1884
- * The {@link retryAfter} property indicates how many seconds to wait
1885
- * before retrying, as reported by the server's `Retry-After` header.
1886
- *
1887
- * @example
1888
- * ```ts
1889
- * try {
1890
- * await client.recall({ agentId: "...", query: "..." });
1891
- * } catch (e) {
1892
- * if (e instanceof RateLimitError) {
1893
- * console.log(`Retry after ${e.retryAfter} seconds`);
1894
- * }
1895
- * }
1896
- * ```
1897
- */
1898
- declare class RateLimitError extends Z3rnoError {
1899
- /** Number of seconds to wait before retrying, per the Retry-After header. */
1900
- retryAfter: number;
1901
- /**
1902
- * @param message - Description of the rate-limit error.
1903
- * @param retryAfter - Seconds to wait before retrying (defaults to 60).
1904
- */
1905
- constructor(message: string, retryAfter?: number);
1906
- }
1907
- /**
1908
- * Thrown when the server rejects the request due to invalid input (HTTP 400 or 422).
1909
- *
1910
- * @example
1911
- * ```ts
1912
- * try {
1913
- * await client.store({ agentId: "not-a-uuid", content: "" });
1914
- * } catch (e) {
1915
- * if (e instanceof ValidationError) {
1916
- * console.error(`Validation failed: ${e.message}`);
1917
- * }
1918
- * }
1919
- * ```
1920
- */
1921
- declare class ValidationError extends Z3rnoError {
1922
- /**
1923
- * @param message - Description of the validation failure.
1924
- * @param statusCode - HTTP status code (400 or 422, defaults to 400).
1925
- */
1926
- constructor(message: string, statusCode?: number);
1927
- }
1928
- /**
1929
- * Thrown when the requested resource does not exist (HTTP 404).
1930
- *
1931
- * @example
1932
- * ```ts
1933
- * try {
1934
- * await client.getMemory("non-existent-id");
1935
- * } catch (e) {
1936
- * if (e instanceof NotFoundError) {
1937
- * console.error("Memory not found");
1938
- * }
1939
- * }
1940
- * ```
1941
- */
1942
- declare class NotFoundError extends Z3rnoError {
1943
- /**
1944
- * @param message - Description of what was not found.
1945
- */
1946
- constructor(message: string);
1947
- }
1948
- /**
1949
- * Thrown when the Z3rno API returns a server-side error (HTTP 5xx).
1950
- *
1951
- * The SDK automatically retries on 5xx errors with exponential backoff.
1952
- * This error is only thrown after all retries are exhausted.
1953
- *
1954
- * @example
1955
- * ```ts
1956
- * try {
1957
- * await client.store({ agentId: "...", content: "..." });
1958
- * } catch (e) {
1959
- * if (e instanceof ServerError) {
1960
- * console.error(`Server error (${e.statusCode}): ${e.message}`);
1961
- * }
1962
- * }
1963
- * ```
1964
- */
1965
- declare class ServerError extends Z3rnoError {
1966
- /**
1967
- * @param message - Description of the server error.
1968
- * @param statusCode - HTTP status code (defaults to 500).
1969
- */
1970
- constructor(message: string, statusCode?: number);
1971
- }
1972
- /**
1973
- * Thrown when a request exceeds the configured timeout duration.
1974
- *
1975
- * The SDK uses an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortController | AbortController}
1976
- * to enforce timeouts. This error is thrown after all retries are exhausted.
1977
- *
1978
- * @example
1979
- * ```ts
1980
- * const client = new Z3rnoClient({ timeout: 5000 }); // 5 seconds
1981
- * try {
1982
- * await client.recall({ agentId: "...", query: "..." });
1983
- * } catch (e) {
1984
- * if (e instanceof Z3rnoTimeoutError) {
1985
- * console.error(`Timed out after ${e.timeout}ms`);
1986
- * }
1987
- * }
1988
- * ```
1989
- */
1990
- declare class Z3rnoTimeoutError extends Z3rnoError {
1991
- /** The timeout duration in milliseconds that was exceeded. */
1992
- timeout: number;
1993
- /**
1994
- * @param message - Description of the timeout.
1995
- * @param timeout - The configured timeout value in milliseconds.
1996
- */
1997
- constructor(message: string, timeout: number);
1998
- }
1999
- /**
2000
- * Thrown when the SDK cannot establish a connection to the Z3rno API.
2001
- *
2002
- * This typically indicates a network issue, DNS failure, or the server
2003
- * being unreachable. The SDK retries connection errors with exponential
2004
- * backoff before throwing this error.
2005
- *
2006
- * @example
2007
- * ```ts
2008
- * try {
2009
- * await client.store({ agentId: "...", content: "..." });
2010
- * } catch (e) {
2011
- * if (e instanceof Z3rnoConnectionError) {
2012
- * console.error("Cannot reach Z3rno API — check your network");
2013
- * }
2014
- * }
2015
- * ```
2016
- */
2017
- declare class Z3rnoConnectionError extends Z3rnoError {
2018
- /**
2019
- * @param message - Description of the connection failure.
2020
- */
2021
- constructor(message: string);
2022
- }
2023
-
2024
- /**
2025
- * Vercel AI SDK adapter for Z3rno (Phase G slice 3).
2026
- *
2027
- * Vercel AI SDK accepts a plain `CoreMessage[]` history; this adapter
2028
- * loads + persists that history through Z3rno conversations. Drop the
2029
- * `messages` accessor straight into `streamText` / `generateText`,
2030
- * call `appendUserMessage` / `appendAssistantMessage` after each turn,
2031
- * and Z3rno handles ordering + recall.
2032
- *
2033
- * Zero hard dependency on the `ai` package — we duck-type on the
2034
- * minimal `CoreMessage` shape (`{ role, content }`).
2035
- */
2036
-
2037
- type Z3rnoMessageRole = "user" | "assistant" | "system" | "tool";
2038
- /** Subset of Vercel `ai` `CoreMessage` the adapter needs. */
2039
- interface CoreMessage {
2040
- role: Z3rnoMessageRole;
2041
- content: string;
2042
- }
2043
- interface Z3rnoVercelMemoryOptions {
2044
- client: Z3rnoClient;
2045
- agentId: string;
2046
- /** When set, recall + persisted turns are scoped to this Z3rno conversation. */
2047
- conversationId?: string;
2048
- /** Max history slice to load. Default 50. */
2049
- topK?: number;
2050
- }
2051
- /**
2052
- * Lightweight history adapter you can hand straight to Vercel AI SDK
2053
- * helpers. `await mem.messages()` returns a CoreMessage[] ready to
2054
- * pass to `streamText({ messages: ... })`. After each turn, call
2055
- * `appendUserMessage` / `appendAssistantMessage` so future recalls
2056
- * see the latest state.
2057
- */
2058
- declare class Z3rnoVercelMemory {
2059
- private readonly client;
2060
- private readonly agentId;
2061
- private readonly conversationId;
2062
- private readonly topK;
2063
- constructor(options: Z3rnoVercelMemoryOptions);
2064
- messages(): Promise<CoreMessage[]>;
2065
- appendUserMessage(content: string): Promise<void>;
2066
- appendAssistantMessage(content: string): Promise<void>;
2067
- appendToolMessage(content: string): Promise<void>;
2068
- private append;
2069
- private normaliseRole;
2070
- }
2071
-
2072
- /**
2073
- * Mastra adapter for Z3rno (Phase G slice 3).
2074
- *
2075
- * Mastra exposes a `MastraMemory`-shaped interface — see
2076
- * https://mastra.ai/docs/agents/memory. This adapter implements
2077
- * the same surface (`getMessages` / `addMessage` / `clear`) using
2078
- * Z3rno conversations as the backing store.
2079
- *
2080
- * Zero hard dependency on the `@mastra/core` package — we provide
2081
- * the typed surface and Mastra's runtime accepts any conforming
2082
- * object.
2083
- */
2084
-
2085
- type MastraRole = "user" | "assistant" | "system" | "tool";
2086
- interface MastraMessage {
2087
- role: MastraRole;
2088
- content: string;
2089
- threadId?: string;
2090
- resourceId?: string;
2091
- }
2092
- interface Z3rnoMastraMemoryOptions {
2093
- client: Z3rnoClient;
2094
- agentId: string;
2095
- /** Mastra's thread is Z3rno's conversation; supply or look up by threadId. */
2096
- conversationId?: string;
2097
- topK?: number;
2098
- }
2099
- /**
2100
- * Mastra-compatible memory backed by Z3rno conversations. Plug into
2101
- * a Mastra `Agent`:
2102
- *
2103
- * const memory = new Z3rnoMastraMemory({ client, agentId, conversationId });
2104
- * const agent = new Agent({ name: "support", memory });
2105
- */
2106
- declare class Z3rnoMastraMemory {
2107
- private readonly client;
2108
- private readonly agentId;
2109
- private readonly conversationId;
2110
- private readonly topK;
2111
- constructor(options: Z3rnoMastraMemoryOptions);
2112
- /** Mastra contract: return ordered prior messages for the thread. */
2113
- getMessages(_args?: {
2114
- limit?: number;
2115
- }): Promise<MastraMessage[]>;
2116
- /** Mastra contract: persist one message. */
2117
- addMessage(message: MastraMessage): Promise<void>;
2118
- /**
2119
- * Mastra `clear()` — deliberate no-op. Z3rno keeps the source of
2120
- * truth and recall is already scoped per conversation; flushing
2121
- * the thread would risk losing audit-relevant history.
2122
- */
2123
- clear(): Promise<void>;
2124
- private normaliseRole;
2125
- }
2126
-
2127
- export { AdminAPI, AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, ConversationResponse, type CoreMessage, DistillJobResponse, DistillJobStatusResponse, EndSessionResponse, ForgetResponse, IngestJobResponse, IngestJobStatusResponse, type MastraMessage, type MastraRole, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RefineJobResponse, RefineJobStatusResponse, RelationshipType, RetrievalStrategy, ServerError, SessionResponse, StoreMemoryRequest, TenantBudgets, TenantBudgetsView, TurnAddResponse, TurnListResponse, TurnResponse, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoConnectionError, Z3rnoError, Z3rnoMastraMemory, type Z3rnoMastraMemoryOptions, type Z3rnoMessageRole, Z3rnoTimeoutError, Z3rnoVercelMemory, type Z3rnoVercelMemoryOptions };