@z3rno/sdk 0.2.0 → 0.4.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.cjs +188 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +313 -1
- package/dist/index.d.ts +313 -1
- package/dist/index.js +182 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,15 @@ type MemoryType = z.infer<typeof MemoryType>;
|
|
|
38
38
|
declare const RelationshipType: z.ZodEnum<["derived_from", "contradicts", "supports", "supersedes", "related_to", "caused_by"]>;
|
|
39
39
|
/** Relationship type between two memories. */
|
|
40
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>;
|
|
41
50
|
/**
|
|
42
51
|
* Schema for storing a new memory.
|
|
43
52
|
*
|
|
@@ -192,6 +201,11 @@ declare const RecallResultItem: z.ZodObject<{
|
|
|
192
201
|
created_at: z.ZodString;
|
|
193
202
|
/** Arbitrary metadata attached to the memory. */
|
|
194
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>>;
|
|
195
209
|
}, "strip", z.ZodTypeAny, {
|
|
196
210
|
content: string;
|
|
197
211
|
metadata: Record<string, unknown>;
|
|
@@ -202,6 +216,7 @@ declare const RecallResultItem: z.ZodObject<{
|
|
|
202
216
|
memory_id: string;
|
|
203
217
|
similarity_score: number;
|
|
204
218
|
relevance_score: number;
|
|
219
|
+
score_components: Record<string, number>;
|
|
205
220
|
summary?: string | null | undefined;
|
|
206
221
|
}, {
|
|
207
222
|
content: string;
|
|
@@ -214,6 +229,7 @@ declare const RecallResultItem: z.ZodObject<{
|
|
|
214
229
|
relevance_score: number;
|
|
215
230
|
metadata?: Record<string, unknown> | undefined;
|
|
216
231
|
summary?: string | null | undefined;
|
|
232
|
+
score_components?: Record<string, number> | undefined;
|
|
217
233
|
}>;
|
|
218
234
|
/** Parsed type for a single recall result item. */
|
|
219
235
|
type RecallResultItem = z.infer<typeof RecallResultItem>;
|
|
@@ -245,6 +261,11 @@ declare const RecallResponse: z.ZodObject<{
|
|
|
245
261
|
created_at: z.ZodString;
|
|
246
262
|
/** Arbitrary metadata attached to the memory. */
|
|
247
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>>;
|
|
248
269
|
}, "strip", z.ZodTypeAny, {
|
|
249
270
|
content: string;
|
|
250
271
|
metadata: Record<string, unknown>;
|
|
@@ -255,6 +276,7 @@ declare const RecallResponse: z.ZodObject<{
|
|
|
255
276
|
memory_id: string;
|
|
256
277
|
similarity_score: number;
|
|
257
278
|
relevance_score: number;
|
|
279
|
+
score_components: Record<string, number>;
|
|
258
280
|
summary?: string | null | undefined;
|
|
259
281
|
}, {
|
|
260
282
|
content: string;
|
|
@@ -267,11 +289,20 @@ declare const RecallResponse: z.ZodObject<{
|
|
|
267
289
|
relevance_score: number;
|
|
268
290
|
metadata?: Record<string, unknown> | undefined;
|
|
269
291
|
summary?: string | null | undefined;
|
|
292
|
+
score_components?: Record<string, number> | undefined;
|
|
270
293
|
}>, "many">;
|
|
271
294
|
/** Total number of matches (may exceed `topK`). */
|
|
272
295
|
total: z.ZodNumber;
|
|
273
296
|
/** The query that was searched, if any. */
|
|
274
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>;
|
|
275
306
|
}, "strip", z.ZodTypeAny, {
|
|
276
307
|
results: {
|
|
277
308
|
content: string;
|
|
@@ -283,9 +314,14 @@ declare const RecallResponse: z.ZodObject<{
|
|
|
283
314
|
memory_id: string;
|
|
284
315
|
similarity_score: number;
|
|
285
316
|
relevance_score: number;
|
|
317
|
+
score_components: Record<string, number>;
|
|
286
318
|
summary?: string | null | undefined;
|
|
287
319
|
}[];
|
|
288
320
|
total: number;
|
|
321
|
+
strategy_used: string;
|
|
322
|
+
strategies_considered: string[];
|
|
323
|
+
reranked: boolean;
|
|
324
|
+
elapsed_ms: number;
|
|
289
325
|
query?: string | null | undefined;
|
|
290
326
|
}, {
|
|
291
327
|
results: {
|
|
@@ -299,9 +335,14 @@ declare const RecallResponse: z.ZodObject<{
|
|
|
299
335
|
relevance_score: number;
|
|
300
336
|
metadata?: Record<string, unknown> | undefined;
|
|
301
337
|
summary?: string | null | undefined;
|
|
338
|
+
score_components?: Record<string, number> | undefined;
|
|
302
339
|
}[];
|
|
303
340
|
total: number;
|
|
304
341
|
query?: string | null | undefined;
|
|
342
|
+
strategy_used?: string | undefined;
|
|
343
|
+
strategies_considered?: string[] | undefined;
|
|
344
|
+
reranked?: boolean | undefined;
|
|
345
|
+
elapsed_ms?: number | undefined;
|
|
305
346
|
}>;
|
|
306
347
|
/** Parsed type for a recall response. */
|
|
307
348
|
type RecallResponse = z.infer<typeof RecallResponse>;
|
|
@@ -714,6 +755,240 @@ declare const EndSessionResponse: z.ZodObject<{
|
|
|
714
755
|
}>;
|
|
715
756
|
/** Parsed type for an end-session response. */
|
|
716
757
|
type EndSessionResponse = z.infer<typeof EndSessionResponse>;
|
|
758
|
+
/** Response to POST /v1/ingest — the enqueue ack. */
|
|
759
|
+
declare const IngestJobResponse: z.ZodObject<{
|
|
760
|
+
job_id: z.ZodString;
|
|
761
|
+
kind: z.ZodString;
|
|
762
|
+
status: z.ZodString;
|
|
763
|
+
dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
764
|
+
enqueued_at: z.ZodString;
|
|
765
|
+
}, "strip", z.ZodTypeAny, {
|
|
766
|
+
status: string;
|
|
767
|
+
job_id: string;
|
|
768
|
+
kind: string;
|
|
769
|
+
enqueued_at: string;
|
|
770
|
+
dataset_id?: string | null | undefined;
|
|
771
|
+
}, {
|
|
772
|
+
status: string;
|
|
773
|
+
job_id: string;
|
|
774
|
+
kind: string;
|
|
775
|
+
enqueued_at: string;
|
|
776
|
+
dataset_id?: string | null | undefined;
|
|
777
|
+
}>;
|
|
778
|
+
type IngestJobResponse = z.infer<typeof IngestJobResponse>;
|
|
779
|
+
/** Full state from GET /v1/ingest/{job_id}. */
|
|
780
|
+
declare const IngestJobStatusResponse: z.ZodObject<{
|
|
781
|
+
job_id: z.ZodString;
|
|
782
|
+
agent_id: z.ZodString;
|
|
783
|
+
dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
784
|
+
kind: z.ZodString;
|
|
785
|
+
status: z.ZodString;
|
|
786
|
+
source_uri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
787
|
+
content_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
788
|
+
filename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
789
|
+
file_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
790
|
+
memory_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
791
|
+
memos_written: z.ZodDefault<z.ZodNumber>;
|
|
792
|
+
distill_job_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
793
|
+
codegraph_memos_written: z.ZodDefault<z.ZodNumber>;
|
|
794
|
+
codegraph_edges_written: z.ZodDefault<z.ZodNumber>;
|
|
795
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
796
|
+
warnings: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
797
|
+
started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
798
|
+
completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
799
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
800
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
801
|
+
}, "strip", z.ZodTypeAny, {
|
|
802
|
+
status: string;
|
|
803
|
+
agent_id: string;
|
|
804
|
+
memory_ids: string[];
|
|
805
|
+
job_id: string;
|
|
806
|
+
kind: string;
|
|
807
|
+
memos_written: number;
|
|
808
|
+
codegraph_memos_written: number;
|
|
809
|
+
codegraph_edges_written: number;
|
|
810
|
+
warnings: Record<string, unknown>[];
|
|
811
|
+
created_at?: string | null | undefined;
|
|
812
|
+
started_at?: string | null | undefined;
|
|
813
|
+
dataset_id?: string | null | undefined;
|
|
814
|
+
source_uri?: string | null | undefined;
|
|
815
|
+
content_type?: string | null | undefined;
|
|
816
|
+
filename?: string | null | undefined;
|
|
817
|
+
file_size?: number | null | undefined;
|
|
818
|
+
distill_job_id?: string | null | undefined;
|
|
819
|
+
error?: string | null | undefined;
|
|
820
|
+
completed_at?: string | null | undefined;
|
|
821
|
+
updated_at?: string | null | undefined;
|
|
822
|
+
}, {
|
|
823
|
+
status: string;
|
|
824
|
+
agent_id: string;
|
|
825
|
+
job_id: string;
|
|
826
|
+
kind: string;
|
|
827
|
+
created_at?: string | null | undefined;
|
|
828
|
+
memory_ids?: string[] | undefined;
|
|
829
|
+
started_at?: string | null | undefined;
|
|
830
|
+
dataset_id?: string | null | undefined;
|
|
831
|
+
source_uri?: string | null | undefined;
|
|
832
|
+
content_type?: string | null | undefined;
|
|
833
|
+
filename?: string | null | undefined;
|
|
834
|
+
file_size?: number | null | undefined;
|
|
835
|
+
memos_written?: number | undefined;
|
|
836
|
+
distill_job_id?: string | null | undefined;
|
|
837
|
+
codegraph_memos_written?: number | undefined;
|
|
838
|
+
codegraph_edges_written?: number | undefined;
|
|
839
|
+
error?: string | null | undefined;
|
|
840
|
+
warnings?: Record<string, unknown>[] | undefined;
|
|
841
|
+
completed_at?: string | null | undefined;
|
|
842
|
+
updated_at?: string | null | undefined;
|
|
843
|
+
}>;
|
|
844
|
+
type IngestJobStatusResponse = z.infer<typeof IngestJobStatusResponse>;
|
|
845
|
+
/** Distill enqueue ack. */
|
|
846
|
+
declare const DistillJobResponse: z.ZodObject<{
|
|
847
|
+
job_id: z.ZodString;
|
|
848
|
+
status: z.ZodString;
|
|
849
|
+
memory_ids: z.ZodArray<z.ZodString, "many">;
|
|
850
|
+
enqueued_at: z.ZodString;
|
|
851
|
+
}, "strip", z.ZodTypeAny, {
|
|
852
|
+
status: string;
|
|
853
|
+
memory_ids: string[];
|
|
854
|
+
job_id: string;
|
|
855
|
+
enqueued_at: string;
|
|
856
|
+
}, {
|
|
857
|
+
status: string;
|
|
858
|
+
memory_ids: string[];
|
|
859
|
+
job_id: string;
|
|
860
|
+
enqueued_at: string;
|
|
861
|
+
}>;
|
|
862
|
+
type DistillJobResponse = z.infer<typeof DistillJobResponse>;
|
|
863
|
+
/** Full distill job state. */
|
|
864
|
+
declare const DistillJobStatusResponse: z.ZodObject<{
|
|
865
|
+
job_id: z.ZodString;
|
|
866
|
+
agent_id: z.ZodString;
|
|
867
|
+
status: z.ZodString;
|
|
868
|
+
model: z.ZodString;
|
|
869
|
+
memory_ids: z.ZodArray<z.ZodString, "many">;
|
|
870
|
+
chunk_size: z.ZodNumber;
|
|
871
|
+
chunk_overlap: z.ZodNumber;
|
|
872
|
+
max_concurrency: z.ZodNumber;
|
|
873
|
+
chunks_total: z.ZodNumber;
|
|
874
|
+
chunks_failed: z.ZodNumber;
|
|
875
|
+
entities_extracted: z.ZodNumber;
|
|
876
|
+
relationships_extracted: z.ZodNumber;
|
|
877
|
+
memos_written: z.ZodNumber;
|
|
878
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
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
|
+
memos_written: number;
|
|
889
|
+
model: string;
|
|
890
|
+
chunk_size: number;
|
|
891
|
+
chunk_overlap: number;
|
|
892
|
+
max_concurrency: number;
|
|
893
|
+
chunks_total: number;
|
|
894
|
+
chunks_failed: number;
|
|
895
|
+
entities_extracted: number;
|
|
896
|
+
relationships_extracted: number;
|
|
897
|
+
created_at?: string | null | undefined;
|
|
898
|
+
started_at?: string | null | undefined;
|
|
899
|
+
error?: string | null | undefined;
|
|
900
|
+
completed_at?: string | null | undefined;
|
|
901
|
+
updated_at?: string | null | undefined;
|
|
902
|
+
}, {
|
|
903
|
+
status: string;
|
|
904
|
+
agent_id: string;
|
|
905
|
+
memory_ids: string[];
|
|
906
|
+
job_id: string;
|
|
907
|
+
memos_written: number;
|
|
908
|
+
model: string;
|
|
909
|
+
chunk_size: number;
|
|
910
|
+
chunk_overlap: number;
|
|
911
|
+
max_concurrency: number;
|
|
912
|
+
chunks_total: number;
|
|
913
|
+
chunks_failed: number;
|
|
914
|
+
entities_extracted: number;
|
|
915
|
+
relationships_extracted: number;
|
|
916
|
+
created_at?: string | null | undefined;
|
|
917
|
+
started_at?: string | null | undefined;
|
|
918
|
+
error?: string | null | undefined;
|
|
919
|
+
completed_at?: string | null | undefined;
|
|
920
|
+
updated_at?: string | null | undefined;
|
|
921
|
+
}>;
|
|
922
|
+
type DistillJobStatusResponse = z.infer<typeof DistillJobStatusResponse>;
|
|
923
|
+
/** Refine enqueue ack. */
|
|
924
|
+
declare const RefineJobResponse: z.ZodObject<{
|
|
925
|
+
job_id: z.ZodString;
|
|
926
|
+
status: z.ZodString;
|
|
927
|
+
dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
928
|
+
enqueued_at: z.ZodString;
|
|
929
|
+
}, "strip", z.ZodTypeAny, {
|
|
930
|
+
status: string;
|
|
931
|
+
job_id: string;
|
|
932
|
+
enqueued_at: string;
|
|
933
|
+
dataset_id?: string | null | undefined;
|
|
934
|
+
}, {
|
|
935
|
+
status: string;
|
|
936
|
+
job_id: string;
|
|
937
|
+
enqueued_at: string;
|
|
938
|
+
dataset_id?: string | null | undefined;
|
|
939
|
+
}>;
|
|
940
|
+
type RefineJobResponse = z.infer<typeof RefineJobResponse>;
|
|
941
|
+
/** Full refine job state. */
|
|
942
|
+
declare const RefineJobStatusResponse: z.ZodObject<{
|
|
943
|
+
job_id: z.ZodString;
|
|
944
|
+
status: z.ZodString;
|
|
945
|
+
dataset_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
946
|
+
trigger: z.ZodString;
|
|
947
|
+
memos_scanned: z.ZodDefault<z.ZodNumber>;
|
|
948
|
+
memos_deduped: z.ZodDefault<z.ZodNumber>;
|
|
949
|
+
edges_reweighted: z.ZodDefault<z.ZodNumber>;
|
|
950
|
+
edges_pruned: z.ZodDefault<z.ZodNumber>;
|
|
951
|
+
feedback_drained: z.ZodDefault<z.ZodNumber>;
|
|
952
|
+
job_metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
953
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
954
|
+
started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
955
|
+
completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
956
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
957
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
958
|
+
}, "strip", z.ZodTypeAny, {
|
|
959
|
+
status: string;
|
|
960
|
+
job_id: string;
|
|
961
|
+
trigger: string;
|
|
962
|
+
memos_scanned: number;
|
|
963
|
+
memos_deduped: number;
|
|
964
|
+
edges_reweighted: number;
|
|
965
|
+
edges_pruned: number;
|
|
966
|
+
feedback_drained: number;
|
|
967
|
+
job_metadata: Record<string, unknown>;
|
|
968
|
+
created_at?: string | null | undefined;
|
|
969
|
+
started_at?: string | null | undefined;
|
|
970
|
+
dataset_id?: string | null | undefined;
|
|
971
|
+
error?: string | null | undefined;
|
|
972
|
+
completed_at?: string | null | undefined;
|
|
973
|
+
updated_at?: string | null | undefined;
|
|
974
|
+
}, {
|
|
975
|
+
status: string;
|
|
976
|
+
job_id: string;
|
|
977
|
+
trigger: string;
|
|
978
|
+
created_at?: string | null | undefined;
|
|
979
|
+
started_at?: string | null | undefined;
|
|
980
|
+
dataset_id?: string | null | undefined;
|
|
981
|
+
error?: string | null | undefined;
|
|
982
|
+
completed_at?: string | null | undefined;
|
|
983
|
+
updated_at?: string | null | undefined;
|
|
984
|
+
memos_scanned?: number | undefined;
|
|
985
|
+
memos_deduped?: number | undefined;
|
|
986
|
+
edges_reweighted?: number | undefined;
|
|
987
|
+
edges_pruned?: number | undefined;
|
|
988
|
+
feedback_drained?: number | undefined;
|
|
989
|
+
job_metadata?: Record<string, unknown> | undefined;
|
|
990
|
+
}>;
|
|
991
|
+
type RefineJobStatusResponse = z.infer<typeof RefineJobStatusResponse>;
|
|
717
992
|
|
|
718
993
|
/**
|
|
719
994
|
* Z3rno TypeScript SDK client.
|
|
@@ -910,6 +1185,18 @@ declare class Z3rnoClient {
|
|
|
910
1185
|
filters?: Record<string, unknown>;
|
|
911
1186
|
topK?: number;
|
|
912
1187
|
similarityThreshold?: number;
|
|
1188
|
+
/**
|
|
1189
|
+
* Phase C: retrieval strategy. One of `AUTO | VECTOR | LEXICAL |
|
|
1190
|
+
* GRAPH | TRIPLET | TRACE | TEMPORAL | ASK | CYPHER`. Default
|
|
1191
|
+
* `"AUTO"` — server's LLM router picks per query.
|
|
1192
|
+
*/
|
|
1193
|
+
strategy?: string;
|
|
1194
|
+
/**
|
|
1195
|
+
* Phase C: cross-encoder re-ranking. When `true`, the server
|
|
1196
|
+
* re-ranks the strategy's top results. Requires
|
|
1197
|
+
* `sentence-transformers` on the server side.
|
|
1198
|
+
*/
|
|
1199
|
+
rerank?: boolean;
|
|
913
1200
|
}): Promise<RecallResponse>;
|
|
914
1201
|
/**
|
|
915
1202
|
* Forgets (deletes) one or more memories.
|
|
@@ -1106,6 +1393,31 @@ declare class Z3rnoClient {
|
|
|
1106
1393
|
page?: number;
|
|
1107
1394
|
pageSize?: number;
|
|
1108
1395
|
}): Promise<AuditPageResponse>;
|
|
1396
|
+
ingestText(params: {
|
|
1397
|
+
agentId: string;
|
|
1398
|
+
text: string;
|
|
1399
|
+
datasetId?: string;
|
|
1400
|
+
}): Promise<IngestJobResponse>;
|
|
1401
|
+
ingestUrl(params: {
|
|
1402
|
+
agentId: string;
|
|
1403
|
+
url: string;
|
|
1404
|
+
datasetId?: string;
|
|
1405
|
+
}): Promise<IngestJobResponse>;
|
|
1406
|
+
getIngestStatus(jobId: string): Promise<IngestJobStatusResponse>;
|
|
1407
|
+
distill(params: {
|
|
1408
|
+
agentId: string;
|
|
1409
|
+
memoryIds: string[];
|
|
1410
|
+
chunkSize?: number;
|
|
1411
|
+
chunkOverlap?: number;
|
|
1412
|
+
maxConcurrency?: number;
|
|
1413
|
+
summaryStyle?: string;
|
|
1414
|
+
includeSummary?: boolean;
|
|
1415
|
+
}): Promise<DistillJobResponse>;
|
|
1416
|
+
getDistillStatus(jobId: string): Promise<DistillJobStatusResponse>;
|
|
1417
|
+
refine(params?: {
|
|
1418
|
+
datasetId?: string;
|
|
1419
|
+
}): Promise<RefineJobResponse>;
|
|
1420
|
+
getRefineStatus(jobId: string): Promise<RefineJobStatusResponse>;
|
|
1109
1421
|
private request;
|
|
1110
1422
|
private sleep;
|
|
1111
1423
|
private handleResponse;
|
|
@@ -1310,4 +1622,4 @@ declare class Z3rnoConnectionError extends Z3rnoError {
|
|
|
1310
1622
|
constructor(message: string);
|
|
1311
1623
|
}
|
|
1312
1624
|
|
|
1313
|
-
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, EndSessionResponse, ForgetResponse, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RelationshipType, ServerError, SessionResponse, StoreMemoryRequest, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoConnectionError, Z3rnoError, Z3rnoTimeoutError };
|
|
1625
|
+
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, DistillJobResponse, DistillJobStatusResponse, EndSessionResponse, ForgetResponse, IngestJobResponse, IngestJobStatusResponse, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RefineJobResponse, RefineJobStatusResponse, RelationshipType, RetrievalStrategy, ServerError, SessionResponse, StoreMemoryRequest, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoConnectionError, Z3rnoError, Z3rnoTimeoutError };
|
package/dist/index.js
CHANGED
|
@@ -101,6 +101,17 @@ var RelationshipType = z.enum([
|
|
|
101
101
|
"related_to",
|
|
102
102
|
"caused_by"
|
|
103
103
|
]);
|
|
104
|
+
var RetrievalStrategy = z.enum([
|
|
105
|
+
"AUTO",
|
|
106
|
+
"VECTOR",
|
|
107
|
+
"LEXICAL",
|
|
108
|
+
"GRAPH",
|
|
109
|
+
"TRIPLET",
|
|
110
|
+
"TRACE",
|
|
111
|
+
"TEMPORAL",
|
|
112
|
+
"ASK",
|
|
113
|
+
"CYPHER"
|
|
114
|
+
]);
|
|
104
115
|
z.object({
|
|
105
116
|
/** UUID of the agent that owns this memory. */
|
|
106
117
|
agentId: z.string().uuid(),
|
|
@@ -146,7 +157,18 @@ z.object({
|
|
|
146
157
|
/** ISO 8601 timestamp for temporal queries (point-in-time recall). */
|
|
147
158
|
asOf: z.string().datetime().optional(),
|
|
148
159
|
/** Whether to include soft-deleted memories. */
|
|
149
|
-
includeDeleted: z.boolean().default(false)
|
|
160
|
+
includeDeleted: z.boolean().default(false),
|
|
161
|
+
/**
|
|
162
|
+
* Phase C retrieval strategy. `AUTO` (default) lets the server's
|
|
163
|
+
* LLM router pick the best fit. See {@link RetrievalStrategy}.
|
|
164
|
+
*/
|
|
165
|
+
strategy: RetrievalStrategy.default("AUTO"),
|
|
166
|
+
/**
|
|
167
|
+
* Phase C cross-encoder re-ranking. When `true`, the server
|
|
168
|
+
* re-ranks the top results via a cross-encoder. Requires the
|
|
169
|
+
* `sentence-transformers` extra on the server.
|
|
170
|
+
*/
|
|
171
|
+
rerank: z.boolean().default(false)
|
|
150
172
|
});
|
|
151
173
|
z.object({
|
|
152
174
|
/** UUID of the agent that owns the memories. */
|
|
@@ -202,7 +224,12 @@ var RecallResultItem = z.object({
|
|
|
202
224
|
/** ISO 8601 creation timestamp. */
|
|
203
225
|
created_at: z.string(),
|
|
204
226
|
/** Arbitrary metadata attached to the memory. */
|
|
205
|
-
metadata: z.record(z.unknown()).default({})
|
|
227
|
+
metadata: z.record(z.unknown()).default({}),
|
|
228
|
+
/**
|
|
229
|
+
* Phase C per-source signals — e.g. `{ vector: 0.83, lexical: 0.61 }`.
|
|
230
|
+
* Optional so older servers (v0.7.x) keep parsing.
|
|
231
|
+
*/
|
|
232
|
+
score_components: z.record(z.number()).default({})
|
|
206
233
|
});
|
|
207
234
|
var RecallResponse = z.object({
|
|
208
235
|
/** Ranked list of matching memories. */
|
|
@@ -210,7 +237,15 @@ var RecallResponse = z.object({
|
|
|
210
237
|
/** Total number of matches (may exceed `topK`). */
|
|
211
238
|
total: z.number(),
|
|
212
239
|
/** The query that was searched, if any. */
|
|
213
|
-
query: z.string().nullable().optional()
|
|
240
|
+
query: z.string().nullable().optional(),
|
|
241
|
+
/** Phase C: strategy that actually ran (after AUTO routing + re-rank). */
|
|
242
|
+
strategy_used: z.string().default("VECTOR"),
|
|
243
|
+
/** Phase C: AUTO's candidate list (e.g. `["AUTO->GRAPH"]`). */
|
|
244
|
+
strategies_considered: z.array(z.string()).default([]),
|
|
245
|
+
/** Phase C: whether the cross-encoder re-rank ran. */
|
|
246
|
+
reranked: z.boolean().default(false),
|
|
247
|
+
/** Phase C: end-to-end recall latency on the server (ms). */
|
|
248
|
+
elapsed_ms: z.number().default(0)
|
|
214
249
|
});
|
|
215
250
|
var ForgetResponse = z.object({
|
|
216
251
|
/** Number of memories deleted. */
|
|
@@ -306,6 +341,84 @@ var EndSessionResponse = z.object({
|
|
|
306
341
|
/** Number of memories created during the session. */
|
|
307
342
|
memory_count: z.number()
|
|
308
343
|
});
|
|
344
|
+
var IngestJobResponse = z.object({
|
|
345
|
+
job_id: z.string(),
|
|
346
|
+
kind: z.string(),
|
|
347
|
+
status: z.string(),
|
|
348
|
+
dataset_id: z.string().nullable().optional(),
|
|
349
|
+
enqueued_at: z.string()
|
|
350
|
+
});
|
|
351
|
+
var IngestJobStatusResponse = z.object({
|
|
352
|
+
job_id: z.string(),
|
|
353
|
+
agent_id: z.string(),
|
|
354
|
+
dataset_id: z.string().nullable().optional(),
|
|
355
|
+
kind: z.string(),
|
|
356
|
+
status: z.string(),
|
|
357
|
+
source_uri: z.string().nullable().optional(),
|
|
358
|
+
content_type: z.string().nullable().optional(),
|
|
359
|
+
filename: z.string().nullable().optional(),
|
|
360
|
+
file_size: z.number().nullable().optional(),
|
|
361
|
+
memory_ids: z.array(z.string()).default([]),
|
|
362
|
+
memos_written: z.number().default(0),
|
|
363
|
+
distill_job_id: z.string().nullable().optional(),
|
|
364
|
+
codegraph_memos_written: z.number().default(0),
|
|
365
|
+
codegraph_edges_written: z.number().default(0),
|
|
366
|
+
error: z.string().nullable().optional(),
|
|
367
|
+
warnings: z.array(z.record(z.unknown())).default([]),
|
|
368
|
+
started_at: z.string().nullable().optional(),
|
|
369
|
+
completed_at: z.string().nullable().optional(),
|
|
370
|
+
created_at: z.string().nullable().optional(),
|
|
371
|
+
updated_at: z.string().nullable().optional()
|
|
372
|
+
});
|
|
373
|
+
var DistillJobResponse = z.object({
|
|
374
|
+
job_id: z.string(),
|
|
375
|
+
status: z.string(),
|
|
376
|
+
memory_ids: z.array(z.string()),
|
|
377
|
+
enqueued_at: z.string()
|
|
378
|
+
});
|
|
379
|
+
var DistillJobStatusResponse = z.object({
|
|
380
|
+
job_id: z.string(),
|
|
381
|
+
agent_id: z.string(),
|
|
382
|
+
status: z.string(),
|
|
383
|
+
model: z.string(),
|
|
384
|
+
memory_ids: z.array(z.string()),
|
|
385
|
+
chunk_size: z.number(),
|
|
386
|
+
chunk_overlap: z.number(),
|
|
387
|
+
max_concurrency: z.number(),
|
|
388
|
+
chunks_total: z.number(),
|
|
389
|
+
chunks_failed: z.number(),
|
|
390
|
+
entities_extracted: z.number(),
|
|
391
|
+
relationships_extracted: z.number(),
|
|
392
|
+
memos_written: z.number(),
|
|
393
|
+
error: z.string().nullable().optional(),
|
|
394
|
+
started_at: z.string().nullable().optional(),
|
|
395
|
+
completed_at: z.string().nullable().optional(),
|
|
396
|
+
created_at: z.string().nullable().optional(),
|
|
397
|
+
updated_at: z.string().nullable().optional()
|
|
398
|
+
});
|
|
399
|
+
var RefineJobResponse = z.object({
|
|
400
|
+
job_id: z.string(),
|
|
401
|
+
status: z.string(),
|
|
402
|
+
dataset_id: z.string().nullable().optional(),
|
|
403
|
+
enqueued_at: z.string()
|
|
404
|
+
});
|
|
405
|
+
var RefineJobStatusResponse = z.object({
|
|
406
|
+
job_id: z.string(),
|
|
407
|
+
status: z.string(),
|
|
408
|
+
dataset_id: z.string().nullable().optional(),
|
|
409
|
+
trigger: z.string(),
|
|
410
|
+
memos_scanned: z.number().default(0),
|
|
411
|
+
memos_deduped: z.number().default(0),
|
|
412
|
+
edges_reweighted: z.number().default(0),
|
|
413
|
+
edges_pruned: z.number().default(0),
|
|
414
|
+
feedback_drained: z.number().default(0),
|
|
415
|
+
job_metadata: z.record(z.unknown()).default({}),
|
|
416
|
+
error: z.string().nullable().optional(),
|
|
417
|
+
started_at: z.string().nullable().optional(),
|
|
418
|
+
completed_at: z.string().nullable().optional(),
|
|
419
|
+
created_at: z.string().nullable().optional(),
|
|
420
|
+
updated_at: z.string().nullable().optional()
|
|
421
|
+
});
|
|
309
422
|
|
|
310
423
|
// src/client.ts
|
|
311
424
|
var Z3rnoClient = class {
|
|
@@ -436,7 +549,11 @@ var Z3rnoClient = class {
|
|
|
436
549
|
memory_type: params.memoryType,
|
|
437
550
|
filters: params.filters,
|
|
438
551
|
top_k: params.topK ?? 10,
|
|
439
|
-
similarity_threshold: params.similarityThreshold ?? 0
|
|
552
|
+
similarity_threshold: params.similarityThreshold ?? 0,
|
|
553
|
+
// Always send strategy + rerank. Older servers silently ignore
|
|
554
|
+
// unknown body fields.
|
|
555
|
+
strategy: params.strategy ?? "AUTO",
|
|
556
|
+
rerank: params.rerank ?? false
|
|
440
557
|
};
|
|
441
558
|
const resp = await this.request("POST", "/v1/memories/recall", body);
|
|
442
559
|
return RecallResponse.parse(resp);
|
|
@@ -681,6 +798,66 @@ var Z3rnoClient = class {
|
|
|
681
798
|
const resp = await this.request("GET", path);
|
|
682
799
|
return AuditPageResponse.parse(resp);
|
|
683
800
|
}
|
|
801
|
+
// --- Forge: ingest / distill / refine -------------------------------
|
|
802
|
+
//
|
|
803
|
+
// Wrap the server's POST /v1/ingest, /v1/distill, /v1/refine plus the
|
|
804
|
+
// matching GET status endpoints. The server gates each verb behind an
|
|
805
|
+
// operator flag (INGEST_ENABLED / DISTILL_ENABLED / REFINE_ENABLED);
|
|
806
|
+
// when off, these methods throw NotFoundError.
|
|
807
|
+
async ingestText(params) {
|
|
808
|
+
const body = {
|
|
809
|
+
kind: "text",
|
|
810
|
+
agent_id: params.agentId,
|
|
811
|
+
text: params.text
|
|
812
|
+
};
|
|
813
|
+
if (params.datasetId) body.dataset_id = params.datasetId;
|
|
814
|
+
const resp = await this.request("POST", "/v1/ingest", body);
|
|
815
|
+
return IngestJobResponse.parse(resp);
|
|
816
|
+
}
|
|
817
|
+
async ingestUrl(params) {
|
|
818
|
+
const body = {
|
|
819
|
+
kind: "url",
|
|
820
|
+
agent_id: params.agentId,
|
|
821
|
+
url: params.url
|
|
822
|
+
};
|
|
823
|
+
if (params.datasetId) body.dataset_id = params.datasetId;
|
|
824
|
+
const resp = await this.request("POST", "/v1/ingest", body);
|
|
825
|
+
return IngestJobResponse.parse(resp);
|
|
826
|
+
}
|
|
827
|
+
async getIngestStatus(jobId) {
|
|
828
|
+
const resp = await this.request("GET", `/v1/ingest/${jobId}`);
|
|
829
|
+
return IngestJobStatusResponse.parse(resp);
|
|
830
|
+
}
|
|
831
|
+
async distill(params) {
|
|
832
|
+
const body = {
|
|
833
|
+
agent_id: params.agentId,
|
|
834
|
+
memory_ids: params.memoryIds,
|
|
835
|
+
include_summary: params.includeSummary ?? true
|
|
836
|
+
};
|
|
837
|
+
if (params.chunkSize !== void 0) body.chunk_size = params.chunkSize;
|
|
838
|
+
if (params.chunkOverlap !== void 0)
|
|
839
|
+
body.chunk_overlap = params.chunkOverlap;
|
|
840
|
+
if (params.maxConcurrency !== void 0)
|
|
841
|
+
body.max_concurrency = params.maxConcurrency;
|
|
842
|
+
if (params.summaryStyle !== void 0)
|
|
843
|
+
body.summary_style = params.summaryStyle;
|
|
844
|
+
const resp = await this.request("POST", "/v1/distill", body);
|
|
845
|
+
return DistillJobResponse.parse(resp);
|
|
846
|
+
}
|
|
847
|
+
async getDistillStatus(jobId) {
|
|
848
|
+
const resp = await this.request("GET", `/v1/distill/${jobId}`);
|
|
849
|
+
return DistillJobStatusResponse.parse(resp);
|
|
850
|
+
}
|
|
851
|
+
async refine(params) {
|
|
852
|
+
const body = {};
|
|
853
|
+
if (params?.datasetId) body.dataset_id = params.datasetId;
|
|
854
|
+
const resp = await this.request("POST", "/v1/refine", body);
|
|
855
|
+
return RefineJobResponse.parse(resp);
|
|
856
|
+
}
|
|
857
|
+
async getRefineStatus(jobId) {
|
|
858
|
+
const resp = await this.request("GET", `/v1/refine/${jobId}`);
|
|
859
|
+
return RefineJobStatusResponse.parse(resp);
|
|
860
|
+
}
|
|
684
861
|
// --- HTTP layer ---
|
|
685
862
|
async request(method, path, body) {
|
|
686
863
|
let lastError;
|
|
@@ -798,6 +975,6 @@ var Z3rnoClient = class {
|
|
|
798
975
|
}
|
|
799
976
|
};
|
|
800
977
|
|
|
801
|
-
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, EndSessionResponse, ForgetResponse, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RelationshipType, ServerError, SessionResponse, ValidationError, Z3rnoClient, Z3rnoConnectionError, Z3rnoError, Z3rnoTimeoutError };
|
|
978
|
+
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, DistillJobResponse, DistillJobStatusResponse, EndSessionResponse, ForgetResponse, IngestJobResponse, IngestJobStatusResponse, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RefineJobResponse, RefineJobStatusResponse, RelationshipType, RetrievalStrategy, ServerError, SessionResponse, ValidationError, Z3rnoClient, Z3rnoConnectionError, Z3rnoError, Z3rnoTimeoutError };
|
|
802
979
|
//# sourceMappingURL=index.js.map
|
|
803
980
|
//# sourceMappingURL=index.js.map
|