@pairsystems/goodmem 0.1.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.js ADDED
@@ -0,0 +1,4358 @@
1
+ // DO NOT EDIT - generated by _clients_gen/typescript/emitter.py from api_ir.json.
2
+ // Regenerate with: cd clients/v2 && python -m _clients_gen.typescript.emitter
3
+ /**
4
+ * Credential kinds supported for upstream endpoint authentication.
5
+ */
6
+ export const CredentialKind = {
7
+ CREDENTIAL_KIND_UNSPECIFIED: "CREDENTIAL_KIND_UNSPECIFIED",
8
+ CREDENTIAL_KIND_API_KEY: "CREDENTIAL_KIND_API_KEY",
9
+ CREDENTIAL_KIND_GCP_ADC: "CREDENTIAL_KIND_GCP_ADC",
10
+ };
11
+ /**
12
+ * Type of embedding distribution produced by the embedder
13
+ */
14
+ export const DistributionType = {
15
+ DENSE: "DENSE",
16
+ SPARSE: "SPARSE",
17
+ };
18
+ /**
19
+ * Iterative scan modes for HNSW index search.
20
+ */
21
+ export const HnswIterativeScan = {
22
+ ITERATIVE_SCAN_UNSPECIFIED: "ITERATIVE_SCAN_UNSPECIFIED",
23
+ ITERATIVE_SCAN_OFF: "ITERATIVE_SCAN_OFF",
24
+ ITERATIVE_SCAN_RELAXED_ORDER: "ITERATIVE_SCAN_RELAXED_ORDER",
25
+ ITERATIVE_SCAN_STRICT_ORDER: "ITERATIVE_SCAN_STRICT_ORDER",
26
+ };
27
+ /**
28
+ * LLM provider types
29
+ */
30
+ export const LLMProviderType = {
31
+ OPENAI: "OPENAI",
32
+ LITELLM_PROXY: "LITELLM_PROXY",
33
+ OPEN_ROUTER: "OPEN_ROUTER",
34
+ VLLM: "VLLM",
35
+ OLLAMA: "OLLAMA",
36
+ LLAMA_CPP: "LLAMA_CPP",
37
+ CUSTOM_OPENAI_COMPATIBLE: "CUSTOM_OPENAI_COMPATIBLE",
38
+ };
39
+ /**
40
+ * Strategy for measuring chunk length during text splitting
41
+ */
42
+ export const LengthMeasurement = {
43
+ CHARACTER_COUNT: "CHARACTER_COUNT",
44
+ TOKEN_COUNT: "TOKEN_COUNT",
45
+ CUSTOM: "CUSTOM",
46
+ };
47
+ /**
48
+ * Content modality types supported by embedders
49
+ */
50
+ export const Modality = {
51
+ TEXT: "TEXT",
52
+ IMAGE: "IMAGE",
53
+ AUDIO: "AUDIO",
54
+ VIDEO: "VIDEO",
55
+ };
56
+ /**
57
+ * Normalized OCR layout category.
58
+ */
59
+ export const OcrCategory = {
60
+ UNSPECIFIED: "UNSPECIFIED",
61
+ CAPTION: "CAPTION",
62
+ FOOTNOTE: "FOOTNOTE",
63
+ FORMULA: "FORMULA",
64
+ LIST_ITEM: "LIST_ITEM",
65
+ PAGE_FOOTER: "PAGE_FOOTER",
66
+ PAGE_HEADER: "PAGE_HEADER",
67
+ PICTURE: "PICTURE",
68
+ SECTION_HEADER: "SECTION_HEADER",
69
+ TABLE: "TABLE",
70
+ TEXT: "TEXT",
71
+ TITLE: "TITLE",
72
+ OTHER: "OTHER",
73
+ UNKNOWN: "UNKNOWN",
74
+ };
75
+ /**
76
+ * OCR input format hint.
77
+ */
78
+ export const OcrInputFormat = {
79
+ AUTO: "AUTO",
80
+ PDF: "PDF",
81
+ TIFF: "TIFF",
82
+ PNG: "PNG",
83
+ JPEG: "JPEG",
84
+ BMP: "BMP",
85
+ };
86
+ /**
87
+ * Payload types supported by ping operations
88
+ */
89
+ export const PingPayloadType = {
90
+ PAYLOAD_TYPE_UNSPECIFIED: "PAYLOAD_TYPE_UNSPECIFIED",
91
+ TEXT: "TEXT",
92
+ JSON: "JSON",
93
+ BINARY: "BINARY",
94
+ };
95
+ /**
96
+ * Target types for ping operations
97
+ */
98
+ export const PingTargetType = {
99
+ TARGET_TYPE_UNSPECIFIED: "TARGET_TYPE_UNSPECIFIED",
100
+ EMBEDDER: "EMBEDDER",
101
+ RERANKER: "RERANKER",
102
+ LLM: "LLM",
103
+ };
104
+ /**
105
+ * Embedding provider types
106
+ */
107
+ export const ProviderType = {
108
+ OPENAI: "OPENAI",
109
+ VLLM: "VLLM",
110
+ TEI: "TEI",
111
+ LLAMA_CPP: "LLAMA_CPP",
112
+ VOYAGE: "VOYAGE",
113
+ COHERE: "COHERE",
114
+ JINA: "JINA",
115
+ };
116
+ /**
117
+ * Terminal background job statuses eligible for purge requests.
118
+ */
119
+ export const PurgeableBackgroundJobStatus = {
120
+ BACKGROUND_JOB_SUCCEEDED: "BACKGROUND_JOB_SUCCEEDED",
121
+ BACKGROUND_JOB_FAILED: "BACKGROUND_JOB_FAILED",
122
+ BACKGROUND_JOB_CANCELED: "BACKGROUND_JOB_CANCELED",
123
+ };
124
+ /**
125
+ * Strategy for handling separators after text splitting. KEEP_NONE is deprecated and treated as KEEP_END.
126
+ */
127
+ export const SeparatorKeepStrategy = {
128
+ KEEP_NONE: "KEEP_NONE",
129
+ KEEP_START: "KEEP_START",
130
+ KEEP_END: "KEEP_END",
131
+ };
132
+ export const SortOrder = {
133
+ ASCENDING: "ASCENDING",
134
+ DESCENDING: "DESCENDING",
135
+ SORT_ORDER_UNSPECIFIED: "SORT_ORDER_UNSPECIFIED",
136
+ };
137
+ const MODEL_REGISTRY = {
138
+ "embedders": {
139
+ "text-embedding-3-large": {
140
+ "providerType": "OPENAI",
141
+ "dimensions": {
142
+ "default": 1536,
143
+ "range": [
144
+ 1,
145
+ 3072
146
+ ]
147
+ },
148
+ "supportedModalities": [
149
+ "TEXT"
150
+ ],
151
+ "maxSequenceLength": 8192
152
+ },
153
+ "text-embedding-3-small": {
154
+ "providerType": "OPENAI",
155
+ "dimensions": {
156
+ "default": 1536,
157
+ "range": [
158
+ 1,
159
+ 1536
160
+ ]
161
+ },
162
+ "supportedModalities": [
163
+ "TEXT"
164
+ ],
165
+ "maxSequenceLength": 8192
166
+ },
167
+ "embed-v4.0": {
168
+ "providerType": "COHERE",
169
+ "dimensions": {
170
+ "default": 1536,
171
+ "allowed": [
172
+ 256,
173
+ 512,
174
+ 1024,
175
+ 1536
176
+ ]
177
+ },
178
+ "supportedModalities": [
179
+ "TEXT",
180
+ "IMAGE"
181
+ ],
182
+ "maxSequenceLength": 128000
183
+ },
184
+ "embed-english-v3.0": {
185
+ "providerType": "COHERE",
186
+ "dimensions": {
187
+ "default": 1024,
188
+ "allowed": [
189
+ 1024
190
+ ]
191
+ },
192
+ "supportedModalities": [
193
+ "TEXT",
194
+ "IMAGE"
195
+ ],
196
+ "maxSequenceLength": 512
197
+ },
198
+ "embed-english-light-v3.0": {
199
+ "providerType": "COHERE",
200
+ "dimensions": {
201
+ "default": 384,
202
+ "allowed": [
203
+ 384
204
+ ]
205
+ },
206
+ "supportedModalities": [
207
+ "TEXT",
208
+ "IMAGE"
209
+ ],
210
+ "maxSequenceLength": 512
211
+ },
212
+ "embed-multilingual-v3.0": {
213
+ "providerType": "COHERE",
214
+ "dimensions": {
215
+ "default": 1024,
216
+ "allowed": [
217
+ 1024
218
+ ]
219
+ },
220
+ "supportedModalities": [
221
+ "TEXT",
222
+ "IMAGE"
223
+ ],
224
+ "maxSequenceLength": 512
225
+ },
226
+ "embed-multilingual-light-v3.0": {
227
+ "providerType": "COHERE",
228
+ "dimensions": {
229
+ "default": 384,
230
+ "allowed": [
231
+ 384
232
+ ]
233
+ },
234
+ "supportedModalities": [
235
+ "TEXT",
236
+ "IMAGE"
237
+ ],
238
+ "maxSequenceLength": 512
239
+ },
240
+ "jina-embeddings-v4": {
241
+ "providerType": "JINA",
242
+ "dimensions": {
243
+ "default": 1024,
244
+ "allowed": [
245
+ 128,
246
+ 256,
247
+ 512,
248
+ 1024,
249
+ 2048
250
+ ]
251
+ },
252
+ "supportedModalities": [
253
+ "TEXT",
254
+ "IMAGE"
255
+ ],
256
+ "maxSequenceLength": 32768
257
+ },
258
+ "jina-embeddings-v3": {
259
+ "providerType": "JINA",
260
+ "dimensions": {
261
+ "default": 1024,
262
+ "allowed": [
263
+ 32,
264
+ 64,
265
+ 128,
266
+ 256,
267
+ 512,
268
+ 768,
269
+ 1024
270
+ ]
271
+ },
272
+ "supportedModalities": [
273
+ "TEXT"
274
+ ],
275
+ "maxSequenceLength": 8192
276
+ },
277
+ "jina-embeddings-v2-base-en": {
278
+ "providerType": "JINA",
279
+ "dimensions": {
280
+ "default": 768,
281
+ "allowed": [
282
+ 768
283
+ ]
284
+ },
285
+ "supportedModalities": [
286
+ "TEXT"
287
+ ],
288
+ "maxSequenceLength": 8192
289
+ },
290
+ "jina-embeddings-v2-base-es": {
291
+ "providerType": "JINA",
292
+ "dimensions": {
293
+ "default": 768,
294
+ "allowed": [
295
+ 768
296
+ ]
297
+ },
298
+ "supportedModalities": [
299
+ "TEXT"
300
+ ],
301
+ "maxSequenceLength": 8192
302
+ },
303
+ "jina-embeddings-v2-base-de": {
304
+ "providerType": "JINA",
305
+ "dimensions": {
306
+ "default": 768,
307
+ "allowed": [
308
+ 768
309
+ ]
310
+ },
311
+ "supportedModalities": [
312
+ "TEXT"
313
+ ],
314
+ "maxSequenceLength": 8192
315
+ },
316
+ "jina-embeddings-v2-base-zh": {
317
+ "providerType": "JINA",
318
+ "dimensions": {
319
+ "default": 768,
320
+ "allowed": [
321
+ 768
322
+ ]
323
+ },
324
+ "supportedModalities": [
325
+ "TEXT"
326
+ ],
327
+ "maxSequenceLength": 8192
328
+ },
329
+ "jina-embeddings-v2-base-code": {
330
+ "providerType": "JINA",
331
+ "dimensions": {
332
+ "default": 768,
333
+ "allowed": [
334
+ 768
335
+ ]
336
+ },
337
+ "supportedModalities": [
338
+ "TEXT"
339
+ ],
340
+ "maxSequenceLength": 8192
341
+ },
342
+ "jina-clip-v1": {
343
+ "providerType": "JINA",
344
+ "dimensions": {
345
+ "default": 768,
346
+ "allowed": [
347
+ 768
348
+ ]
349
+ },
350
+ "supportedModalities": [
351
+ "TEXT",
352
+ "IMAGE"
353
+ ],
354
+ "maxSequenceLength": 8192
355
+ },
356
+ "jina-clip-v2": {
357
+ "providerType": "JINA",
358
+ "dimensions": {
359
+ "default": 1024,
360
+ "allowed": [
361
+ 64,
362
+ 128,
363
+ 256,
364
+ 512,
365
+ 768,
366
+ 1024
367
+ ]
368
+ },
369
+ "supportedModalities": [
370
+ "TEXT",
371
+ "IMAGE"
372
+ ],
373
+ "maxSequenceLength": 8192
374
+ },
375
+ "voyage-4-large": {
376
+ "providerType": "VOYAGE",
377
+ "dimensions": {
378
+ "default": 1024,
379
+ "allowed": [
380
+ 256,
381
+ 512,
382
+ 1024,
383
+ 2048
384
+ ]
385
+ },
386
+ "supportedModalities": [
387
+ "TEXT"
388
+ ],
389
+ "maxSequenceLength": 32000
390
+ },
391
+ "voyage-4": {
392
+ "providerType": "VOYAGE",
393
+ "dimensions": {
394
+ "default": 1024,
395
+ "allowed": [
396
+ 256,
397
+ 512,
398
+ 1024,
399
+ 2048
400
+ ]
401
+ },
402
+ "supportedModalities": [
403
+ "TEXT"
404
+ ],
405
+ "maxSequenceLength": 32000
406
+ },
407
+ "voyage-4-lite": {
408
+ "providerType": "VOYAGE",
409
+ "dimensions": {
410
+ "default": 1024,
411
+ "allowed": [
412
+ 256,
413
+ 512,
414
+ 1024,
415
+ 2048
416
+ ]
417
+ },
418
+ "supportedModalities": [
419
+ "TEXT"
420
+ ],
421
+ "maxSequenceLength": 32000
422
+ },
423
+ "voyage-code-3": {
424
+ "providerType": "VOYAGE",
425
+ "dimensions": {
426
+ "default": 1024,
427
+ "allowed": [
428
+ 256,
429
+ 512,
430
+ 1024,
431
+ 2048
432
+ ]
433
+ },
434
+ "supportedModalities": [
435
+ "TEXT"
436
+ ],
437
+ "maxSequenceLength": 32000
438
+ },
439
+ "voyage-3-large": {
440
+ "providerType": "VOYAGE",
441
+ "dimensions": {
442
+ "default": 1024,
443
+ "allowed": [
444
+ 256,
445
+ 512,
446
+ 1024,
447
+ 2048
448
+ ]
449
+ },
450
+ "supportedModalities": [
451
+ "TEXT"
452
+ ],
453
+ "maxSequenceLength": 32000
454
+ },
455
+ "voyage-3.5": {
456
+ "providerType": "VOYAGE",
457
+ "dimensions": {
458
+ "default": 1024,
459
+ "allowed": [
460
+ 256,
461
+ 512,
462
+ 1024,
463
+ 2048
464
+ ]
465
+ },
466
+ "supportedModalities": [
467
+ "TEXT"
468
+ ],
469
+ "maxSequenceLength": 32000
470
+ },
471
+ "voyage-3.5-lite": {
472
+ "providerType": "VOYAGE",
473
+ "dimensions": {
474
+ "default": 1024,
475
+ "allowed": [
476
+ 256,
477
+ 512,
478
+ 1024,
479
+ 2048
480
+ ]
481
+ },
482
+ "supportedModalities": [
483
+ "TEXT"
484
+ ],
485
+ "maxSequenceLength": 32000
486
+ },
487
+ "voyage-3": {
488
+ "providerType": "VOYAGE",
489
+ "dimensions": {
490
+ "default": 1024,
491
+ "allowed": [
492
+ 1024
493
+ ]
494
+ },
495
+ "supportedModalities": [
496
+ "TEXT"
497
+ ],
498
+ "maxSequenceLength": 32000
499
+ },
500
+ "voyage-3-lite": {
501
+ "providerType": "VOYAGE",
502
+ "dimensions": {
503
+ "default": 512,
504
+ "allowed": [
505
+ 512
506
+ ]
507
+ },
508
+ "supportedModalities": [
509
+ "TEXT"
510
+ ],
511
+ "maxSequenceLength": 32000
512
+ },
513
+ "voyage-finance-2": {
514
+ "providerType": "VOYAGE",
515
+ "dimensions": {
516
+ "default": 1024,
517
+ "allowed": [
518
+ 1024
519
+ ]
520
+ },
521
+ "supportedModalities": [
522
+ "TEXT"
523
+ ],
524
+ "maxSequenceLength": 32000
525
+ },
526
+ "voyage-law-2": {
527
+ "providerType": "VOYAGE",
528
+ "dimensions": {
529
+ "default": 1024,
530
+ "allowed": [
531
+ 1024
532
+ ]
533
+ },
534
+ "supportedModalities": [
535
+ "TEXT"
536
+ ],
537
+ "maxSequenceLength": 16000
538
+ },
539
+ "voyage-code-2": {
540
+ "providerType": "VOYAGE",
541
+ "dimensions": {
542
+ "default": 1536,
543
+ "allowed": [
544
+ 1536
545
+ ]
546
+ },
547
+ "supportedModalities": [
548
+ "TEXT"
549
+ ],
550
+ "maxSequenceLength": 16000
551
+ },
552
+ "voyage-multilingual-2": {
553
+ "providerType": "VOYAGE",
554
+ "dimensions": {
555
+ "default": 1024,
556
+ "allowed": [
557
+ 1024
558
+ ]
559
+ },
560
+ "supportedModalities": [
561
+ "TEXT"
562
+ ],
563
+ "maxSequenceLength": 32000
564
+ }
565
+ },
566
+ "llms": {
567
+ "gpt-5.2": {
568
+ "providerType": "OPENAI",
569
+ "supportedModalities": [
570
+ "TEXT",
571
+ "IMAGE"
572
+ ],
573
+ "maxContextLength": 400000
574
+ },
575
+ "gpt-5.2-pro": {
576
+ "providerType": "OPENAI",
577
+ "supportedModalities": [
578
+ "TEXT",
579
+ "IMAGE"
580
+ ],
581
+ "maxContextLength": 400000
582
+ },
583
+ "gpt-5.1": {
584
+ "providerType": "OPENAI",
585
+ "supportedModalities": [
586
+ "TEXT",
587
+ "IMAGE"
588
+ ],
589
+ "maxContextLength": 400000
590
+ },
591
+ "gpt-5": {
592
+ "providerType": "OPENAI",
593
+ "supportedModalities": [
594
+ "TEXT",
595
+ "IMAGE"
596
+ ],
597
+ "maxContextLength": 400000
598
+ },
599
+ "gpt-5-mini": {
600
+ "providerType": "OPENAI",
601
+ "supportedModalities": [
602
+ "TEXT",
603
+ "IMAGE"
604
+ ],
605
+ "maxContextLength": 400000
606
+ },
607
+ "gpt-5-nano": {
608
+ "providerType": "OPENAI",
609
+ "supportedModalities": [
610
+ "TEXT",
611
+ "IMAGE"
612
+ ],
613
+ "maxContextLength": 400000
614
+ },
615
+ "o3": {
616
+ "providerType": "OPENAI",
617
+ "supportedModalities": [
618
+ "TEXT",
619
+ "IMAGE"
620
+ ],
621
+ "maxContextLength": 200000
622
+ },
623
+ "o3-mini": {
624
+ "providerType": "OPENAI",
625
+ "supportedModalities": [
626
+ "TEXT",
627
+ "IMAGE"
628
+ ],
629
+ "maxContextLength": 200000
630
+ },
631
+ "o4-mini": {
632
+ "providerType": "OPENAI",
633
+ "supportedModalities": [
634
+ "TEXT",
635
+ "IMAGE"
636
+ ],
637
+ "maxContextLength": 200000
638
+ },
639
+ "gpt-4.1": {
640
+ "providerType": "OPENAI",
641
+ "supportedModalities": [
642
+ "TEXT",
643
+ "IMAGE"
644
+ ],
645
+ "maxContextLength": 1047576
646
+ },
647
+ "gpt-4.1-mini": {
648
+ "providerType": "OPENAI",
649
+ "supportedModalities": [
650
+ "TEXT",
651
+ "IMAGE"
652
+ ],
653
+ "maxContextLength": 1047576
654
+ },
655
+ "gpt-4.1-nano": {
656
+ "providerType": "OPENAI",
657
+ "supportedModalities": [
658
+ "TEXT",
659
+ "IMAGE"
660
+ ],
661
+ "maxContextLength": 1047576
662
+ },
663
+ "gpt-4o": {
664
+ "providerType": "OPENAI",
665
+ "supportedModalities": [
666
+ "TEXT",
667
+ "IMAGE",
668
+ "AUDIO"
669
+ ],
670
+ "maxContextLength": 128000
671
+ },
672
+ "gpt-4o-mini": {
673
+ "providerType": "OPENAI",
674
+ "supportedModalities": [
675
+ "TEXT",
676
+ "IMAGE",
677
+ "AUDIO"
678
+ ],
679
+ "maxContextLength": 128000
680
+ },
681
+ "gpt-4-turbo": {
682
+ "providerType": "OPENAI",
683
+ "supportedModalities": [
684
+ "TEXT",
685
+ "IMAGE"
686
+ ],
687
+ "maxContextLength": 128000
688
+ },
689
+ "gpt-3.5-turbo": {
690
+ "providerType": "OPENAI",
691
+ "supportedModalities": [
692
+ "TEXT"
693
+ ],
694
+ "maxContextLength": 16385
695
+ },
696
+ "o1": {
697
+ "providerType": "OPENAI",
698
+ "supportedModalities": [
699
+ "TEXT"
700
+ ],
701
+ "maxContextLength": 200000
702
+ },
703
+ "o1-mini": {
704
+ "providerType": "OPENAI",
705
+ "supportedModalities": [
706
+ "TEXT"
707
+ ],
708
+ "maxContextLength": 128000
709
+ },
710
+ "o1-preview": {
711
+ "providerType": "OPENAI",
712
+ "supportedModalities": [
713
+ "TEXT"
714
+ ],
715
+ "maxContextLength": 128000
716
+ }
717
+ },
718
+ "rerankers": {
719
+ "rerank-v4.0-pro": {
720
+ "providerType": "COHERE",
721
+ "supportedModalities": [
722
+ "TEXT"
723
+ ]
724
+ },
725
+ "rerank-v4.0-fast": {
726
+ "providerType": "COHERE",
727
+ "supportedModalities": [
728
+ "TEXT"
729
+ ]
730
+ },
731
+ "rerank-v3.5": {
732
+ "providerType": "COHERE",
733
+ "supportedModalities": [
734
+ "TEXT"
735
+ ]
736
+ },
737
+ "rerank-english-v3.0": {
738
+ "providerType": "COHERE",
739
+ "supportedModalities": [
740
+ "TEXT"
741
+ ]
742
+ },
743
+ "rerank-multilingual-v3.0": {
744
+ "providerType": "COHERE",
745
+ "supportedModalities": [
746
+ "TEXT"
747
+ ]
748
+ },
749
+ "jina-reranker-v3": {
750
+ "providerType": "JINA",
751
+ "supportedModalities": [
752
+ "TEXT"
753
+ ]
754
+ },
755
+ "jina-reranker-v2-base-multilingual": {
756
+ "providerType": "JINA",
757
+ "supportedModalities": [
758
+ "TEXT"
759
+ ]
760
+ },
761
+ "jina-reranker-v1-base-en": {
762
+ "providerType": "JINA",
763
+ "supportedModalities": [
764
+ "TEXT"
765
+ ]
766
+ },
767
+ "jina-reranker-v1-turbo-en": {
768
+ "providerType": "JINA",
769
+ "supportedModalities": [
770
+ "TEXT"
771
+ ]
772
+ },
773
+ "jina-reranker-v1-tiny-en": {
774
+ "providerType": "JINA",
775
+ "supportedModalities": [
776
+ "TEXT"
777
+ ]
778
+ },
779
+ "rerank-2.5": {
780
+ "providerType": "VOYAGE",
781
+ "supportedModalities": [
782
+ "TEXT"
783
+ ]
784
+ },
785
+ "rerank-2.5-lite": {
786
+ "providerType": "VOYAGE",
787
+ "supportedModalities": [
788
+ "TEXT"
789
+ ]
790
+ },
791
+ "rerank-2": {
792
+ "providerType": "VOYAGE",
793
+ "supportedModalities": [
794
+ "TEXT"
795
+ ]
796
+ },
797
+ "rerank-2-lite": {
798
+ "providerType": "VOYAGE",
799
+ "supportedModalities": [
800
+ "TEXT"
801
+ ]
802
+ },
803
+ "rerank-1": {
804
+ "providerType": "VOYAGE",
805
+ "supportedModalities": [
806
+ "TEXT"
807
+ ]
808
+ },
809
+ "rerank-lite-1": {
810
+ "providerType": "VOYAGE",
811
+ "supportedModalities": [
812
+ "TEXT"
813
+ ]
814
+ }
815
+ }
816
+ };
817
+ const PROVIDER_REGISTRY = {
818
+ "COHERE": {
819
+ "defaultBaseUrl": "https://api.cohere.com",
820
+ "baseUrlsRequiringApiKey": [
821
+ "https://api.cohere.com"
822
+ ]
823
+ },
824
+ "JINA": {
825
+ "defaultBaseUrl": "https://api.jina.ai",
826
+ "baseUrlsRequiringApiKey": [
827
+ "https://api.jina.ai"
828
+ ]
829
+ },
830
+ "OPENAI": {
831
+ "defaultBaseUrl": "https://api.openai.com/v1",
832
+ "baseUrlsRequiringApiKey": [
833
+ "https://api.openai.com/v1",
834
+ "https://generativelanguage.googleapis.com/v1beta/openai",
835
+ "https://api.anthropic.com/v1",
836
+ "https://api.mistral.ai/v1"
837
+ ]
838
+ },
839
+ "VOYAGE": {
840
+ "defaultBaseUrl": "https://api.voyageai.com/v1",
841
+ "baseUrlsRequiringApiKey": [
842
+ "https://api.voyageai.com/v1"
843
+ ]
844
+ }
845
+ };
846
+ const PROVIDER_ENDPOINTS = {
847
+ "COHERE": "https://api.cohere.com",
848
+ "JINA": "https://api.jina.ai",
849
+ "OPENAI": "https://api.openai.com/v1",
850
+ "VOYAGE": "https://api.voyageai.com/v1"
851
+ };
852
+ const REGISTRY_CREATE_REQUIRED_FIELDS = {
853
+ "embedders": [
854
+ "displayName",
855
+ "providerType",
856
+ "endpointUrl",
857
+ "modelIdentifier",
858
+ "dimensionality",
859
+ "distributionType"
860
+ ],
861
+ "llms": [
862
+ "displayName",
863
+ "providerType",
864
+ "endpointUrl",
865
+ "modelIdentifier"
866
+ ],
867
+ "rerankers": [
868
+ "displayName",
869
+ "providerType",
870
+ "endpointUrl",
871
+ "modelIdentifier"
872
+ ]
873
+ };
874
+ const TIMEOUT_BUDGET_RULES = {
875
+ "admin.drain": {
876
+ "field": "timeoutSec",
877
+ "fieldDefault": 900,
878
+ "unit": "s",
879
+ "headroomMs": 30000,
880
+ "appliesWhenField": "waitForQuiesce"
881
+ },
882
+ "ping.once": {
883
+ "field": "timeoutMs",
884
+ "fieldDefault": null,
885
+ "unit": "ms",
886
+ "headroomMs": 30000
887
+ },
888
+ "ping.stream": {
889
+ "field": "timeoutMs",
890
+ "fieldDefault": null,
891
+ "unit": "ms",
892
+ "headroomMs": 30000
893
+ }
894
+ };
895
+ const MODEL_RULES = {
896
+ "ActiveLicenseMetadata": {
897
+ "ranges": [
898
+ {
899
+ "minimum": 0,
900
+ "field": "sizeBytes"
901
+ }
902
+ ]
903
+ },
904
+ "AdminPurgeJobsRequest": {
905
+ "ranges": [
906
+ {
907
+ "minimum": 0,
908
+ "field": "limit"
909
+ }
910
+ ]
911
+ },
912
+ "AdminPurgeJobsResponse": {
913
+ "ranges": [
914
+ {
915
+ "minimum": 0,
916
+ "field": "jobsPurged"
917
+ },
918
+ {
919
+ "minimum": 0,
920
+ "field": "attemptsPurged"
921
+ },
922
+ {
923
+ "minimum": 0,
924
+ "field": "referencesPurged"
925
+ }
926
+ ]
927
+ },
928
+ "ChunkingConfiguration": {
929
+ "oneOf": [
930
+ {
931
+ "fields": [
932
+ "none",
933
+ "recursive",
934
+ "sentence"
935
+ ],
936
+ "required": true,
937
+ "message": "ChunkingConfiguration: exactly one oneOf field must be set"
938
+ }
939
+ ]
940
+ },
941
+ "ContextItem": {
942
+ "oneOf": [
943
+ {
944
+ "fields": [
945
+ "text",
946
+ "binary"
947
+ ],
948
+ "required": true,
949
+ "message": "ContextItem: exactly one oneOf field must be set"
950
+ }
951
+ ]
952
+ },
953
+ "DocumentTimings": {
954
+ "ranges": [
955
+ {
956
+ "minimum": 0,
957
+ "field": "wallTimeMs"
958
+ },
959
+ {
960
+ "minimum": 0,
961
+ "field": "sumQueueWaitMs"
962
+ },
963
+ {
964
+ "minimum": 0,
965
+ "field": "sumRenderMs"
966
+ },
967
+ {
968
+ "minimum": 0,
969
+ "field": "sumOcrMs"
970
+ },
971
+ {
972
+ "minimum": 0,
973
+ "field": "sumPageTotalMs"
974
+ }
975
+ ]
976
+ },
977
+ "EmbedderCreationRequest": {
978
+ "ranges": [
979
+ {
980
+ "minimum": 1,
981
+ "field": "dimensionality"
982
+ },
983
+ {
984
+ "minimum": 1,
985
+ "field": "maxSequenceLength"
986
+ }
987
+ ]
988
+ },
989
+ "EmbedderResponse": {
990
+ "ranges": [
991
+ {
992
+ "minimum": 1,
993
+ "field": "dimensionality"
994
+ },
995
+ {
996
+ "minimum": 1,
997
+ "field": "maxSequenceLength"
998
+ }
999
+ ]
1000
+ },
1001
+ "HnswOptions": {
1002
+ "ranges": [
1003
+ {
1004
+ "minimum": 1,
1005
+ "maximum": 1000,
1006
+ "field": "efSearch"
1007
+ },
1008
+ {
1009
+ "minimum": 1,
1010
+ "maximum": 2147483647,
1011
+ "field": "maxScanTuples"
1012
+ },
1013
+ {
1014
+ "minimum": 1,
1015
+ "maximum": 1000,
1016
+ "field": "scanMemMultiplier"
1017
+ }
1018
+ ]
1019
+ },
1020
+ "ImageInfo": {
1021
+ "ranges": [
1022
+ {
1023
+ "minimum": 0,
1024
+ "field": "widthPx"
1025
+ },
1026
+ {
1027
+ "minimum": 0,
1028
+ "field": "heightPx"
1029
+ },
1030
+ {
1031
+ "minimum": 0,
1032
+ "field": "dpi"
1033
+ }
1034
+ ]
1035
+ },
1036
+ "LLMCreationRequest": {
1037
+ "ranges": [
1038
+ {
1039
+ "minimum": 1,
1040
+ "field": "maxContextLength"
1041
+ }
1042
+ ]
1043
+ },
1044
+ "LLMResponse": {
1045
+ "ranges": [
1046
+ {
1047
+ "minimum": 1,
1048
+ "field": "maxContextLength"
1049
+ }
1050
+ ]
1051
+ },
1052
+ "LLMSamplingParams": {
1053
+ "ranges": [
1054
+ {
1055
+ "minimum": 1,
1056
+ "field": "maxTokens"
1057
+ },
1058
+ {
1059
+ "minimum": 0,
1060
+ "maximum": 1,
1061
+ "field": "topP"
1062
+ },
1063
+ {
1064
+ "minimum": 1,
1065
+ "field": "topK"
1066
+ }
1067
+ ]
1068
+ },
1069
+ "LLMUpdateRequest": {
1070
+ "ranges": [
1071
+ {
1072
+ "minimum": 1,
1073
+ "field": "maxContextLength"
1074
+ }
1075
+ ],
1076
+ "mutex": [
1077
+ {
1078
+ "fields": [
1079
+ "replaceLabels",
1080
+ "mergeLabels"
1081
+ ],
1082
+ "required": false,
1083
+ "message": "LLMUpdateRequest: at most one of replaceLabels or mergeLabels may be set"
1084
+ }
1085
+ ]
1086
+ },
1087
+ "Memory": {
1088
+ "ranges": [
1089
+ {
1090
+ "minimum": 0,
1091
+ "field": "originalContentLength"
1092
+ },
1093
+ {
1094
+ "minimum": 0,
1095
+ "field": "pageImageCount"
1096
+ }
1097
+ ]
1098
+ },
1099
+ "MemoryChunkResponse": {
1100
+ "ranges": [
1101
+ {
1102
+ "minimum": 0,
1103
+ "field": "chunkSequenceNumber"
1104
+ },
1105
+ {
1106
+ "minimum": 0,
1107
+ "field": "startOffset"
1108
+ },
1109
+ {
1110
+ "minimum": 0,
1111
+ "field": "endOffset"
1112
+ }
1113
+ ]
1114
+ },
1115
+ "MemoryPageImage": {
1116
+ "ranges": [
1117
+ {
1118
+ "minimum": 0,
1119
+ "field": "pageIndex"
1120
+ },
1121
+ {
1122
+ "minimum": 0,
1123
+ "field": "dpi"
1124
+ },
1125
+ {
1126
+ "minimum": 0,
1127
+ "field": "imageContentLength"
1128
+ }
1129
+ ]
1130
+ },
1131
+ "OcrDocumentRequest": {
1132
+ "ranges": [
1133
+ {
1134
+ "minimum": 0,
1135
+ "field": "startPage"
1136
+ },
1137
+ {
1138
+ "minimum": 0,
1139
+ "field": "endPage"
1140
+ }
1141
+ ]
1142
+ },
1143
+ "OcrDocumentResponse": {
1144
+ "ranges": [
1145
+ {
1146
+ "minimum": 0,
1147
+ "field": "pageCount"
1148
+ }
1149
+ ]
1150
+ },
1151
+ "OcrPageResult": {
1152
+ "ranges": [
1153
+ {
1154
+ "minimum": 0,
1155
+ "field": "pageIndex"
1156
+ }
1157
+ ],
1158
+ "mutex": [
1159
+ {
1160
+ "fields": [
1161
+ "page",
1162
+ "status"
1163
+ ],
1164
+ "required": true,
1165
+ "message": "OcrPageResult: exactly one of page or status must be set"
1166
+ }
1167
+ ]
1168
+ },
1169
+ "PageTimings": {
1170
+ "ranges": [
1171
+ {
1172
+ "minimum": 0,
1173
+ "field": "queueWaitMs"
1174
+ },
1175
+ {
1176
+ "minimum": 0,
1177
+ "field": "renderMs"
1178
+ },
1179
+ {
1180
+ "minimum": 0,
1181
+ "field": "ocrMs"
1182
+ },
1183
+ {
1184
+ "minimum": 0,
1185
+ "field": "totalMs"
1186
+ }
1187
+ ]
1188
+ },
1189
+ "PingEvent": {
1190
+ "oneOf": [
1191
+ {
1192
+ "fields": [
1193
+ "result",
1194
+ "summary",
1195
+ "notice"
1196
+ ],
1197
+ "required": true,
1198
+ "message": "PingEvent: exactly one oneOf field must be set"
1199
+ }
1200
+ ]
1201
+ },
1202
+ "PingOnceRequest": {
1203
+ "ranges": [
1204
+ {
1205
+ "minimum": 0,
1206
+ "field": "payloadSizeBytes"
1207
+ },
1208
+ {
1209
+ "minimum": 0,
1210
+ "field": "timeoutMs"
1211
+ }
1212
+ ],
1213
+ "mutex": [
1214
+ {
1215
+ "fields": [
1216
+ "payload",
1217
+ "payloadSizeBytes"
1218
+ ],
1219
+ "required": false,
1220
+ "message": "PingOnceRequest: at most one of payload or payloadSizeBytes may be set"
1221
+ }
1222
+ ]
1223
+ },
1224
+ "PingResult": {
1225
+ "ranges": [
1226
+ {
1227
+ "minimum": 0,
1228
+ "field": "seq"
1229
+ },
1230
+ {
1231
+ "minimum": 0,
1232
+ "field": "bytesSent"
1233
+ },
1234
+ {
1235
+ "minimum": 0,
1236
+ "field": "bytesReceived"
1237
+ },
1238
+ {
1239
+ "minimum": 0,
1240
+ "field": "httpStatus"
1241
+ },
1242
+ {
1243
+ "minimum": 0,
1244
+ "field": "rttMs"
1245
+ }
1246
+ ]
1247
+ },
1248
+ "PingStreamRequest": {
1249
+ "ranges": [
1250
+ {
1251
+ "minimum": 0,
1252
+ "field": "count"
1253
+ },
1254
+ {
1255
+ "minimum": 0,
1256
+ "field": "intervalMs"
1257
+ },
1258
+ {
1259
+ "minimum": 0,
1260
+ "field": "timeoutMs"
1261
+ },
1262
+ {
1263
+ "minimum": 0,
1264
+ "field": "payloadSizeBytes"
1265
+ },
1266
+ {
1267
+ "minimum": 1,
1268
+ "field": "maxInFlight"
1269
+ }
1270
+ ],
1271
+ "mutex": [
1272
+ {
1273
+ "fields": [
1274
+ "payload",
1275
+ "payloadSizeBytes"
1276
+ ],
1277
+ "required": false,
1278
+ "message": "PingStreamRequest: at most one of payload or payloadSizeBytes may be set"
1279
+ }
1280
+ ]
1281
+ },
1282
+ "PingSummary": {
1283
+ "ranges": [
1284
+ {
1285
+ "minimum": 0,
1286
+ "field": "requests"
1287
+ },
1288
+ {
1289
+ "minimum": 0,
1290
+ "field": "responses"
1291
+ },
1292
+ {
1293
+ "minimum": 0,
1294
+ "field": "ok"
1295
+ },
1296
+ {
1297
+ "minimum": 0,
1298
+ "field": "timeouts"
1299
+ },
1300
+ {
1301
+ "minimum": 0,
1302
+ "field": "errors"
1303
+ },
1304
+ {
1305
+ "minimum": 0,
1306
+ "field": "rttMinMs"
1307
+ },
1308
+ {
1309
+ "minimum": 0,
1310
+ "field": "rttAvgMs"
1311
+ },
1312
+ {
1313
+ "minimum": 0,
1314
+ "field": "rttP50Ms"
1315
+ },
1316
+ {
1317
+ "minimum": 0,
1318
+ "field": "rttP90Ms"
1319
+ },
1320
+ {
1321
+ "minimum": 0,
1322
+ "field": "rttP99Ms"
1323
+ },
1324
+ {
1325
+ "minimum": 0,
1326
+ "field": "rttMaxMs"
1327
+ },
1328
+ {
1329
+ "minimum": 0,
1330
+ "field": "requestsPerSecond"
1331
+ },
1332
+ {
1333
+ "minimum": 0,
1334
+ "field": "bytesPerSecond"
1335
+ }
1336
+ ]
1337
+ },
1338
+ "PingTiming": {
1339
+ "ranges": [
1340
+ {
1341
+ "minimum": 0,
1342
+ "field": "clientSendTimeUnixNanos"
1343
+ },
1344
+ {
1345
+ "minimum": 0,
1346
+ "field": "serverReceivedTimeUnixNanos"
1347
+ },
1348
+ {
1349
+ "minimum": 0,
1350
+ "field": "serverSendTimeUnixNanos"
1351
+ },
1352
+ {
1353
+ "minimum": 0,
1354
+ "field": "clientReceiveTimeUnixNanos"
1355
+ }
1356
+ ]
1357
+ },
1358
+ "RecursiveChunkingConfiguration": {
1359
+ "ranges": [
1360
+ {
1361
+ "minimum": 1,
1362
+ "field": "chunkSize"
1363
+ },
1364
+ {
1365
+ "minimum": 0,
1366
+ "field": "chunkOverlap"
1367
+ }
1368
+ ]
1369
+ },
1370
+ "RetrievedItem": {
1371
+ "oneOf": [
1372
+ {
1373
+ "fields": [
1374
+ "memory",
1375
+ "chunk"
1376
+ ],
1377
+ "required": true,
1378
+ "message": "RetrievedItem: exactly one oneOf field must be set"
1379
+ }
1380
+ ]
1381
+ },
1382
+ "SentenceChunkingConfiguration": {
1383
+ "ranges": [
1384
+ {
1385
+ "minimum": 1,
1386
+ "field": "maxChunkSize"
1387
+ },
1388
+ {
1389
+ "minimum": 0,
1390
+ "field": "minChunkSize"
1391
+ }
1392
+ ]
1393
+ },
1394
+ "SpaceEmbedderConfig": {
1395
+ "ranges": [
1396
+ {
1397
+ "minimum": 0,
1398
+ "field": "defaultRetrievalWeight"
1399
+ }
1400
+ ]
1401
+ },
1402
+ "SystemInfoResponse": {
1403
+ "ranges": [
1404
+ {
1405
+ "minimum": 0,
1406
+ "field": "major"
1407
+ },
1408
+ {
1409
+ "minimum": 0,
1410
+ "field": "minor"
1411
+ },
1412
+ {
1413
+ "minimum": 0,
1414
+ "field": "patch"
1415
+ }
1416
+ ]
1417
+ },
1418
+ "TokenBudget": {
1419
+ "ranges": [
1420
+ {
1421
+ "minimum": 1,
1422
+ "field": "tokens"
1423
+ }
1424
+ ]
1425
+ },
1426
+ "UpdateEmbedderRequest": {
1427
+ "ranges": [
1428
+ {
1429
+ "minimum": 1,
1430
+ "field": "dimensionality"
1431
+ },
1432
+ {
1433
+ "minimum": 1,
1434
+ "field": "maxSequenceLength"
1435
+ }
1436
+ ],
1437
+ "mutex": [
1438
+ {
1439
+ "fields": [
1440
+ "replaceLabels",
1441
+ "mergeLabels"
1442
+ ],
1443
+ "required": false,
1444
+ "message": "UpdateEmbedderRequest: at most one of replaceLabels or mergeLabels may be set"
1445
+ }
1446
+ ]
1447
+ },
1448
+ "ApiKeyAuth": {
1449
+ "mutex": [
1450
+ {
1451
+ "fields": [
1452
+ "inlineSecret",
1453
+ "secretRef"
1454
+ ],
1455
+ "required": true,
1456
+ "message": "ApiKeyAuth: exactly one of inlineSecret or secretRef must be set"
1457
+ }
1458
+ ]
1459
+ },
1460
+ "EndpointAuthentication": {
1461
+ "mutex": [
1462
+ {
1463
+ "fields": [
1464
+ "apiKey",
1465
+ "gcpAdc"
1466
+ ],
1467
+ "required": false,
1468
+ "message": "EndpointAuthentication: at most one credential payload (apiKey or gcpAdc) may be set; kind discriminator (CREDENTIAL_KIND_*) decides which is required. Empty payload is permitted for UNSPECIFIED kind"
1469
+ }
1470
+ ]
1471
+ },
1472
+ "JsonMemoryCreationRequest": {
1473
+ "mutex": [
1474
+ {
1475
+ "fields": [
1476
+ "originalContent",
1477
+ "originalContentB64"
1478
+ ],
1479
+ "required": true,
1480
+ "message": "JsonMemoryCreationRequest: exactly one of originalContent or originalContentB64 must be set"
1481
+ }
1482
+ ],
1483
+ "requiredCompanions": [
1484
+ {
1485
+ "trigger": "originalContentB64",
1486
+ "required": "contentType",
1487
+ "message": "JsonMemoryCreationRequest: contentType is required when originalContentB64 is set"
1488
+ }
1489
+ ]
1490
+ },
1491
+ "UpdateApiKeyRequest": {
1492
+ "mutex": [
1493
+ {
1494
+ "fields": [
1495
+ "replaceLabels",
1496
+ "mergeLabels"
1497
+ ],
1498
+ "required": false,
1499
+ "message": "UpdateApiKeyRequest: at most one of replaceLabels or mergeLabels may be set"
1500
+ }
1501
+ ]
1502
+ },
1503
+ "UpdateRerankerRequest": {
1504
+ "mutex": [
1505
+ {
1506
+ "fields": [
1507
+ "replaceLabels",
1508
+ "mergeLabels"
1509
+ ],
1510
+ "required": false,
1511
+ "message": "UpdateRerankerRequest: at most one of replaceLabels or mergeLabels may be set"
1512
+ }
1513
+ ]
1514
+ },
1515
+ "UpdateSpaceRequest": {
1516
+ "mutex": [
1517
+ {
1518
+ "fields": [
1519
+ "replaceLabels",
1520
+ "mergeLabels"
1521
+ ],
1522
+ "required": false,
1523
+ "message": "UpdateSpaceRequest: at most one of replaceLabels or mergeLabels may be set"
1524
+ }
1525
+ ]
1526
+ },
1527
+ "MemoryCreationRequest": {
1528
+ "requiredCompanions": [
1529
+ {
1530
+ "trigger": "originalContentB64",
1531
+ "required": "contentType",
1532
+ "message": "MemoryCreationRequest: contentType is required when originalContentB64 is set"
1533
+ }
1534
+ ]
1535
+ }
1536
+ };
1537
+ const MODEL_FIELDS = {
1538
+ "AdminPurgeJobsRequest": {
1539
+ "statuses": {
1540
+ "model": "PurgeableBackgroundJobStatus",
1541
+ "array": true
1542
+ }
1543
+ },
1544
+ "AdminReloadLicenseResponse": {
1545
+ "activeLicense": {
1546
+ "model": "ActiveLicenseMetadata",
1547
+ "array": false
1548
+ }
1549
+ },
1550
+ "ApiKeyAuth": {
1551
+ "secretRef": {
1552
+ "model": "SecretReference",
1553
+ "array": false
1554
+ }
1555
+ },
1556
+ "BatchDeleteMemorySelectorRequest": {
1557
+ "filterSelector": {
1558
+ "model": "FilteredDeleteMemorySelectorRequest",
1559
+ "array": false
1560
+ }
1561
+ },
1562
+ "BatchMemoryDeletionRequest": {
1563
+ "requests": {
1564
+ "model": "BatchDeleteMemorySelectorRequest",
1565
+ "array": true
1566
+ }
1567
+ },
1568
+ "BatchMemoryResponse": {
1569
+ "results": {
1570
+ "model": "BatchMemoryResult",
1571
+ "array": true
1572
+ }
1573
+ },
1574
+ "BatchMemoryResult": {
1575
+ "memory": {
1576
+ "model": "Memory",
1577
+ "array": false
1578
+ },
1579
+ "error": {
1580
+ "model": "ErrorDetail",
1581
+ "array": false
1582
+ }
1583
+ },
1584
+ "ChunkReference": {
1585
+ "chunk": {
1586
+ "model": "MemoryChunkResponse",
1587
+ "array": false
1588
+ }
1589
+ },
1590
+ "ChunkingConfiguration": {
1591
+ "none": {
1592
+ "model": "NoChunkingConfiguration",
1593
+ "array": false
1594
+ },
1595
+ "recursive": {
1596
+ "model": "RecursiveChunkingConfiguration",
1597
+ "array": false
1598
+ },
1599
+ "sentence": {
1600
+ "model": "SentenceChunkingConfiguration",
1601
+ "array": false
1602
+ }
1603
+ },
1604
+ "ContextItem": {
1605
+ "binary": {
1606
+ "model": "BinaryContent",
1607
+ "array": false
1608
+ }
1609
+ },
1610
+ "CreateApiKeyResponse": {
1611
+ "apiKeyMetadata": {
1612
+ "model": "ApiKeyResponse",
1613
+ "array": false
1614
+ }
1615
+ },
1616
+ "CreateLLMResponse": {
1617
+ "llm": {
1618
+ "model": "LLMResponse",
1619
+ "array": false
1620
+ },
1621
+ "statuses": {
1622
+ "model": "GoodMemStatus",
1623
+ "array": true
1624
+ }
1625
+ },
1626
+ "CreateRetrieveMemoryLogPolicyRequest": {
1627
+ "condition": {
1628
+ "model": "RetrieveMemoryLogPolicyCondition",
1629
+ "array": false
1630
+ }
1631
+ },
1632
+ "EmbedderCreationRequest": {
1633
+ "providerType": {
1634
+ "model": "ProviderType",
1635
+ "array": false
1636
+ },
1637
+ "distributionType": {
1638
+ "model": "DistributionType",
1639
+ "array": false
1640
+ },
1641
+ "supportedModalities": {
1642
+ "model": "Modality",
1643
+ "array": true
1644
+ },
1645
+ "credentials": {
1646
+ "model": "EndpointAuthentication",
1647
+ "array": false
1648
+ }
1649
+ },
1650
+ "EmbedderResponse": {
1651
+ "providerType": {
1652
+ "model": "ProviderType",
1653
+ "array": false
1654
+ },
1655
+ "distributionType": {
1656
+ "model": "DistributionType",
1657
+ "array": false
1658
+ },
1659
+ "supportedModalities": {
1660
+ "model": "Modality",
1661
+ "array": true
1662
+ },
1663
+ "credentials": {
1664
+ "model": "EndpointAuthentication",
1665
+ "array": false
1666
+ }
1667
+ },
1668
+ "EndpointAuthentication": {
1669
+ "kind": {
1670
+ "model": "CredentialKind",
1671
+ "array": false
1672
+ },
1673
+ "apiKey": {
1674
+ "model": "ApiKeyAuth",
1675
+ "array": false
1676
+ },
1677
+ "gcpAdc": {
1678
+ "model": "GcpAdcAuth",
1679
+ "array": false
1680
+ }
1681
+ },
1682
+ "HnswOptions": {
1683
+ "iterativeScan": {
1684
+ "model": "HnswIterativeScan",
1685
+ "array": false
1686
+ }
1687
+ },
1688
+ "JsonBatchMemoryCreationRequest": {
1689
+ "requests": {
1690
+ "model": "JsonMemoryCreationRequest",
1691
+ "array": true
1692
+ }
1693
+ },
1694
+ "JsonMemoryCreationRequest": {
1695
+ "chunkingConfig": {
1696
+ "model": "ChunkingConfiguration",
1697
+ "array": false
1698
+ }
1699
+ },
1700
+ "LLMCreationRequest": {
1701
+ "providerType": {
1702
+ "model": "LLMProviderType",
1703
+ "array": false
1704
+ },
1705
+ "supportedModalities": {
1706
+ "model": "Modality",
1707
+ "array": true
1708
+ },
1709
+ "credentials": {
1710
+ "model": "EndpointAuthentication",
1711
+ "array": false
1712
+ },
1713
+ "capabilities": {
1714
+ "model": "LLMCapabilities",
1715
+ "array": false
1716
+ },
1717
+ "defaultSamplingParams": {
1718
+ "model": "LLMSamplingParams",
1719
+ "array": false
1720
+ }
1721
+ },
1722
+ "LLMResponse": {
1723
+ "providerType": {
1724
+ "model": "LLMProviderType",
1725
+ "array": false
1726
+ },
1727
+ "supportedModalities": {
1728
+ "model": "Modality",
1729
+ "array": true
1730
+ },
1731
+ "credentials": {
1732
+ "model": "EndpointAuthentication",
1733
+ "array": false
1734
+ },
1735
+ "capabilities": {
1736
+ "model": "LLMCapabilities",
1737
+ "array": false
1738
+ },
1739
+ "defaultSamplingParams": {
1740
+ "model": "LLMSamplingParams",
1741
+ "array": false
1742
+ }
1743
+ },
1744
+ "LLMUpdateRequest": {
1745
+ "supportedModalities": {
1746
+ "model": "Modality",
1747
+ "array": true
1748
+ },
1749
+ "credentials": {
1750
+ "model": "EndpointAuthentication",
1751
+ "array": false
1752
+ },
1753
+ "capabilities": {
1754
+ "model": "LLMCapabilities",
1755
+ "array": false
1756
+ },
1757
+ "defaultSamplingParams": {
1758
+ "model": "LLMSamplingParams",
1759
+ "array": false
1760
+ }
1761
+ },
1762
+ "ListApiKeysResponse": {
1763
+ "keys": {
1764
+ "model": "ApiKeyResponse",
1765
+ "array": true
1766
+ }
1767
+ },
1768
+ "ListEmbeddersResponse": {
1769
+ "embedders": {
1770
+ "model": "EmbedderResponse",
1771
+ "array": true
1772
+ }
1773
+ },
1774
+ "ListLLMsResponse": {
1775
+ "llms": {
1776
+ "model": "LLMResponse",
1777
+ "array": true
1778
+ }
1779
+ },
1780
+ "ListMemoryPageImagesResponse": {
1781
+ "pageImages": {
1782
+ "model": "MemoryPageImage",
1783
+ "array": true
1784
+ }
1785
+ },
1786
+ "ListRerankersResponse": {
1787
+ "rerankers": {
1788
+ "model": "RerankerResponse",
1789
+ "array": true
1790
+ }
1791
+ },
1792
+ "ListRetrieveMemoryLogPoliciesResponse": {
1793
+ "policies": {
1794
+ "model": "RetrieveMemoryLogPolicy",
1795
+ "array": true
1796
+ }
1797
+ },
1798
+ "ListSpacesResponse": {
1799
+ "spaces": {
1800
+ "model": "Space",
1801
+ "array": true
1802
+ }
1803
+ },
1804
+ "Memory": {
1805
+ "chunkingConfig": {
1806
+ "model": "ChunkingConfiguration",
1807
+ "array": false
1808
+ },
1809
+ "processingHistory": {
1810
+ "model": "ProcessingHistory",
1811
+ "array": false
1812
+ }
1813
+ },
1814
+ "MemoryCreationRequest": {
1815
+ "chunkingConfig": {
1816
+ "model": "ChunkingConfiguration",
1817
+ "array": false
1818
+ }
1819
+ },
1820
+ "MemoryListResponse": {
1821
+ "memories": {
1822
+ "model": "Memory",
1823
+ "array": true
1824
+ }
1825
+ },
1826
+ "OcrCell": {
1827
+ "bbox": {
1828
+ "model": "BoundingBox",
1829
+ "array": false
1830
+ },
1831
+ "category": {
1832
+ "model": "OcrCategory",
1833
+ "array": false
1834
+ }
1835
+ },
1836
+ "OcrDocumentRequest": {
1837
+ "format": {
1838
+ "model": "OcrInputFormat",
1839
+ "array": false
1840
+ }
1841
+ },
1842
+ "OcrDocumentResponse": {
1843
+ "detectedFormat": {
1844
+ "model": "OcrInputFormat",
1845
+ "array": false
1846
+ },
1847
+ "pages": {
1848
+ "model": "OcrPageResult",
1849
+ "array": true
1850
+ },
1851
+ "timings": {
1852
+ "model": "DocumentTimings",
1853
+ "array": false
1854
+ }
1855
+ },
1856
+ "OcrLayout": {
1857
+ "cells": {
1858
+ "model": "OcrCell",
1859
+ "array": true
1860
+ }
1861
+ },
1862
+ "OcrPage": {
1863
+ "layout": {
1864
+ "model": "OcrLayout",
1865
+ "array": false
1866
+ },
1867
+ "timings": {
1868
+ "model": "PageTimings",
1869
+ "array": false
1870
+ },
1871
+ "image": {
1872
+ "model": "ImageInfo",
1873
+ "array": false
1874
+ }
1875
+ },
1876
+ "OcrPageResult": {
1877
+ "page": {
1878
+ "model": "OcrPage",
1879
+ "array": false
1880
+ },
1881
+ "status": {
1882
+ "model": "RpcStatus",
1883
+ "array": false
1884
+ }
1885
+ },
1886
+ "PingEndpointInfo": {
1887
+ "targetType": {
1888
+ "model": "PingTargetType",
1889
+ "array": false
1890
+ }
1891
+ },
1892
+ "PingEvent": {
1893
+ "result": {
1894
+ "model": "PingResult",
1895
+ "array": false
1896
+ },
1897
+ "summary": {
1898
+ "model": "PingSummary",
1899
+ "array": false
1900
+ },
1901
+ "notice": {
1902
+ "model": "PingNotice",
1903
+ "array": false
1904
+ }
1905
+ },
1906
+ "PingOnceRequest": {
1907
+ "targetTypeHint": {
1908
+ "model": "PingTargetType",
1909
+ "array": false
1910
+ },
1911
+ "payloadType": {
1912
+ "model": "PingPayloadType",
1913
+ "array": false
1914
+ }
1915
+ },
1916
+ "PingResult": {
1917
+ "endpoint": {
1918
+ "model": "PingEndpointInfo",
1919
+ "array": false
1920
+ },
1921
+ "timing": {
1922
+ "model": "PingTiming",
1923
+ "array": false
1924
+ }
1925
+ },
1926
+ "PingStreamRequest": {
1927
+ "targetTypeHint": {
1928
+ "model": "PingTargetType",
1929
+ "array": false
1930
+ },
1931
+ "payloadType": {
1932
+ "model": "PingPayloadType",
1933
+ "array": false
1934
+ }
1935
+ },
1936
+ "PingSummary": {
1937
+ "endpoint": {
1938
+ "model": "PingEndpointInfo",
1939
+ "array": false
1940
+ }
1941
+ },
1942
+ "ProcessingHistory": {
1943
+ "latestJob": {
1944
+ "model": "BackgroundJobSummary",
1945
+ "array": false
1946
+ },
1947
+ "attempts": {
1948
+ "model": "BackgroundJobAttempt",
1949
+ "array": true
1950
+ }
1951
+ },
1952
+ "RecursiveChunkingConfiguration": {
1953
+ "keepStrategy": {
1954
+ "model": "SeparatorKeepStrategy",
1955
+ "array": false
1956
+ },
1957
+ "lengthMeasurement": {
1958
+ "model": "LengthMeasurement",
1959
+ "array": false
1960
+ }
1961
+ },
1962
+ "RerankerCreationRequest": {
1963
+ "providerType": {
1964
+ "model": "ProviderType",
1965
+ "array": false
1966
+ },
1967
+ "supportedModalities": {
1968
+ "model": "Modality",
1969
+ "array": true
1970
+ },
1971
+ "credentials": {
1972
+ "model": "EndpointAuthentication",
1973
+ "array": false
1974
+ }
1975
+ },
1976
+ "RerankerResponse": {
1977
+ "providerType": {
1978
+ "model": "ProviderType",
1979
+ "array": false
1980
+ },
1981
+ "supportedModalities": {
1982
+ "model": "Modality",
1983
+ "array": true
1984
+ },
1985
+ "credentials": {
1986
+ "model": "EndpointAuthentication",
1987
+ "array": false
1988
+ }
1989
+ },
1990
+ "RetrieveMemoryEvent": {
1991
+ "resultSetBoundary": {
1992
+ "model": "ResultSetBoundary",
1993
+ "array": false
1994
+ },
1995
+ "abstractReply": {
1996
+ "model": "AbstractReply",
1997
+ "array": false
1998
+ },
1999
+ "retrievedItem": {
2000
+ "model": "RetrievedItem",
2001
+ "array": false
2002
+ },
2003
+ "memoryDefinition": {
2004
+ "model": "Memory",
2005
+ "array": false
2006
+ },
2007
+ "status": {
2008
+ "model": "GoodMemStatus",
2009
+ "array": false
2010
+ }
2011
+ },
2012
+ "RetrieveMemoryLogPolicy": {
2013
+ "condition": {
2014
+ "model": "RetrieveMemoryLogPolicyCondition",
2015
+ "array": false
2016
+ }
2017
+ },
2018
+ "RetrieveMemoryLogPolicyCondition": {
2019
+ "anyOf": {
2020
+ "model": "RetrieveMemoryLogPolicyConditionClause",
2021
+ "array": true
2022
+ }
2023
+ },
2024
+ "RetrieveMemoryRequest": {
2025
+ "context": {
2026
+ "model": "ContextItem",
2027
+ "array": true
2028
+ },
2029
+ "spaceKeys": {
2030
+ "model": "SpaceKey",
2031
+ "array": true
2032
+ },
2033
+ "outputBudget": {
2034
+ "model": "TokenBudget",
2035
+ "array": false
2036
+ },
2037
+ "hnsw": {
2038
+ "model": "HnswOptions",
2039
+ "array": false
2040
+ },
2041
+ "postProcessor": {
2042
+ "model": "PostProcessor",
2043
+ "array": false
2044
+ },
2045
+ "logging": {
2046
+ "model": "LoggingOptions",
2047
+ "array": false
2048
+ }
2049
+ },
2050
+ "RetrievedItem": {
2051
+ "memory": {
2052
+ "model": "Memory",
2053
+ "array": false
2054
+ },
2055
+ "chunk": {
2056
+ "model": "ChunkReference",
2057
+ "array": false
2058
+ }
2059
+ },
2060
+ "SentenceChunkingConfiguration": {
2061
+ "lengthMeasurement": {
2062
+ "model": "LengthMeasurement",
2063
+ "array": false
2064
+ }
2065
+ },
2066
+ "Space": {
2067
+ "spaceEmbedders": {
2068
+ "model": "SpaceEmbedder",
2069
+ "array": true
2070
+ },
2071
+ "defaultChunkingConfig": {
2072
+ "model": "ChunkingConfiguration",
2073
+ "array": false
2074
+ }
2075
+ },
2076
+ "SpaceCreationRequest": {
2077
+ "spaceEmbedders": {
2078
+ "model": "SpaceEmbedderConfig",
2079
+ "array": true
2080
+ },
2081
+ "defaultChunkingConfig": {
2082
+ "model": "ChunkingConfiguration",
2083
+ "array": false
2084
+ }
2085
+ },
2086
+ "SpaceKey": {
2087
+ "embedderWeights": {
2088
+ "model": "EmbedderWeight",
2089
+ "array": true
2090
+ }
2091
+ },
2092
+ "UpdateEmbedderRequest": {
2093
+ "distributionType": {
2094
+ "model": "DistributionType",
2095
+ "array": false
2096
+ },
2097
+ "credentials": {
2098
+ "model": "EndpointAuthentication",
2099
+ "array": false
2100
+ }
2101
+ },
2102
+ "UpdateRerankerRequest": {
2103
+ "supportedModalities": {
2104
+ "model": "Modality",
2105
+ "array": true
2106
+ },
2107
+ "credentials": {
2108
+ "model": "EndpointAuthentication",
2109
+ "array": false
2110
+ }
2111
+ }
2112
+ };
2113
+ const MODEL_ENUM_FIELDS = {
2114
+ "AdminDrainResponse": {
2115
+ "state": {
2116
+ "values": [
2117
+ "STARTING",
2118
+ "READY",
2119
+ "DRAINING",
2120
+ "QUIESCED"
2121
+ ],
2122
+ "array": false
2123
+ }
2124
+ },
2125
+ "AdminPurgeJobsRequest": {
2126
+ "statuses": {
2127
+ "values": [
2128
+ "BACKGROUND_JOB_SUCCEEDED",
2129
+ "BACKGROUND_JOB_FAILED",
2130
+ "BACKGROUND_JOB_CANCELED"
2131
+ ],
2132
+ "array": true
2133
+ }
2134
+ },
2135
+ "AdminReloadLicenseResponse": {
2136
+ "status": {
2137
+ "values": [
2138
+ "LOADED",
2139
+ "UNCHANGED",
2140
+ "FAILED",
2141
+ "NOT_FOUND"
2142
+ ],
2143
+ "array": false
2144
+ }
2145
+ },
2146
+ "ApiKeyResponse": {
2147
+ "status": {
2148
+ "values": [
2149
+ "STATUS_UNSPECIFIED",
2150
+ "ACTIVE",
2151
+ "INACTIVE"
2152
+ ],
2153
+ "array": false
2154
+ }
2155
+ },
2156
+ "BackgroundJobSummary": {
2157
+ "status": {
2158
+ "values": [
2159
+ "BACKGROUND_JOB_STATUS_UNSPECIFIED",
2160
+ "BACKGROUND_JOB_PENDING",
2161
+ "BACKGROUND_JOB_RUNNING",
2162
+ "BACKGROUND_JOB_SUCCEEDED",
2163
+ "BACKGROUND_JOB_FAILED",
2164
+ "BACKGROUND_JOB_CANCELED"
2165
+ ],
2166
+ "array": false
2167
+ }
2168
+ },
2169
+ "EmbedderCreationRequest": {
2170
+ "providerType": {
2171
+ "values": [
2172
+ "OPENAI",
2173
+ "VLLM",
2174
+ "TEI",
2175
+ "LLAMA_CPP",
2176
+ "VOYAGE",
2177
+ "COHERE",
2178
+ "JINA"
2179
+ ],
2180
+ "array": false
2181
+ },
2182
+ "distributionType": {
2183
+ "values": [
2184
+ "DENSE",
2185
+ "SPARSE"
2186
+ ],
2187
+ "array": false
2188
+ },
2189
+ "supportedModalities": {
2190
+ "values": [
2191
+ "TEXT",
2192
+ "IMAGE",
2193
+ "AUDIO",
2194
+ "VIDEO"
2195
+ ],
2196
+ "array": true
2197
+ }
2198
+ },
2199
+ "EmbedderResponse": {
2200
+ "providerType": {
2201
+ "values": [
2202
+ "OPENAI",
2203
+ "VLLM",
2204
+ "TEI",
2205
+ "LLAMA_CPP",
2206
+ "VOYAGE",
2207
+ "COHERE",
2208
+ "JINA"
2209
+ ],
2210
+ "array": false
2211
+ },
2212
+ "distributionType": {
2213
+ "values": [
2214
+ "DENSE",
2215
+ "SPARSE"
2216
+ ],
2217
+ "array": false
2218
+ },
2219
+ "supportedModalities": {
2220
+ "values": [
2221
+ "TEXT",
2222
+ "IMAGE",
2223
+ "AUDIO",
2224
+ "VIDEO"
2225
+ ],
2226
+ "array": true
2227
+ }
2228
+ },
2229
+ "EndpointAuthentication": {
2230
+ "kind": {
2231
+ "values": [
2232
+ "CREDENTIAL_KIND_UNSPECIFIED",
2233
+ "CREDENTIAL_KIND_API_KEY",
2234
+ "CREDENTIAL_KIND_GCP_ADC"
2235
+ ],
2236
+ "array": false
2237
+ }
2238
+ },
2239
+ "FilteredDeleteMemorySelectorRequest": {
2240
+ "statusFilter": {
2241
+ "values": [
2242
+ "PENDING",
2243
+ "PROCESSING",
2244
+ "COMPLETED",
2245
+ "FAILED"
2246
+ ],
2247
+ "array": false
2248
+ }
2249
+ },
2250
+ "GoodMemStatus": {
2251
+ "code": {
2252
+ "values": [
2253
+ "GOODMEM_STATUS_CODE_UNSPECIFIED",
2254
+ "INVALID_ARGUMENT",
2255
+ "NOT_FOUND",
2256
+ "PERMISSION_DENIED",
2257
+ "FAILED_PRECONDITION",
2258
+ "EMBEDDER_FAILED",
2259
+ "EMBEDDER_UNAVAILABLE",
2260
+ "EMBEDDER_TIMEOUT",
2261
+ "VECTOR_SEARCH_FAILED",
2262
+ "VECTOR_SEARCH_PARTIAL",
2263
+ "VECTOR_SEARCH_TIMEOUT",
2264
+ "SPACE_INACCESSIBLE",
2265
+ "SPACE_NOT_FOUND",
2266
+ "SPACE_NO_EMBEDDERS",
2267
+ "CHUNK_NOT_FOUND",
2268
+ "MEMORY_LOAD_FAILED",
2269
+ "MEMORY_CONTENT_UNAVAILABLE",
2270
+ "RERANKING_FAILED",
2271
+ "SUMMARIZATION_FAILED",
2272
+ "SUMMARIZATION_TIMEOUT",
2273
+ "RATE_LIMITED",
2274
+ "RESOURCE_EXHAUSTED",
2275
+ "CONFIGURATION_ERROR",
2276
+ "LLM_CAPABILITY_INFERRED",
2277
+ "FEATURE_DISABLED"
2278
+ ],
2279
+ "array": false
2280
+ }
2281
+ },
2282
+ "HnswOptions": {
2283
+ "iterativeScan": {
2284
+ "values": [
2285
+ "ITERATIVE_SCAN_UNSPECIFIED",
2286
+ "ITERATIVE_SCAN_OFF",
2287
+ "ITERATIVE_SCAN_RELAXED_ORDER",
2288
+ "ITERATIVE_SCAN_STRICT_ORDER"
2289
+ ],
2290
+ "array": false
2291
+ }
2292
+ },
2293
+ "LLMCreationRequest": {
2294
+ "providerType": {
2295
+ "values": [
2296
+ "OPENAI",
2297
+ "LITELLM_PROXY",
2298
+ "OPEN_ROUTER",
2299
+ "VLLM",
2300
+ "OLLAMA",
2301
+ "LLAMA_CPP",
2302
+ "CUSTOM_OPENAI_COMPATIBLE"
2303
+ ],
2304
+ "array": false
2305
+ },
2306
+ "supportedModalities": {
2307
+ "values": [
2308
+ "TEXT",
2309
+ "IMAGE",
2310
+ "AUDIO",
2311
+ "VIDEO"
2312
+ ],
2313
+ "array": true
2314
+ }
2315
+ },
2316
+ "LLMResponse": {
2317
+ "providerType": {
2318
+ "values": [
2319
+ "OPENAI",
2320
+ "LITELLM_PROXY",
2321
+ "OPEN_ROUTER",
2322
+ "VLLM",
2323
+ "OLLAMA",
2324
+ "LLAMA_CPP",
2325
+ "CUSTOM_OPENAI_COMPATIBLE"
2326
+ ],
2327
+ "array": false
2328
+ },
2329
+ "supportedModalities": {
2330
+ "values": [
2331
+ "TEXT",
2332
+ "IMAGE",
2333
+ "AUDIO",
2334
+ "VIDEO"
2335
+ ],
2336
+ "array": true
2337
+ }
2338
+ },
2339
+ "LLMUpdateRequest": {
2340
+ "supportedModalities": {
2341
+ "values": [
2342
+ "TEXT",
2343
+ "IMAGE",
2344
+ "AUDIO",
2345
+ "VIDEO"
2346
+ ],
2347
+ "array": true
2348
+ }
2349
+ },
2350
+ "Memory": {
2351
+ "processingStatus": {
2352
+ "values": [
2353
+ "UNSPECIFIED",
2354
+ "PENDING",
2355
+ "PROCESSING",
2356
+ "COMPLETED",
2357
+ "FAILED"
2358
+ ],
2359
+ "array": false
2360
+ },
2361
+ "pageImageStatus": {
2362
+ "values": [
2363
+ "UNSPECIFIED",
2364
+ "PENDING",
2365
+ "PROCESSING",
2366
+ "COMPLETED",
2367
+ "FAILED"
2368
+ ],
2369
+ "array": false
2370
+ }
2371
+ },
2372
+ "MemoryChunkResponse": {
2373
+ "vectorStatus": {
2374
+ "values": [
2375
+ "UNSPECIFIED",
2376
+ "PENDING",
2377
+ "PROCESSING",
2378
+ "COMPLETED",
2379
+ "FAILED"
2380
+ ],
2381
+ "array": false
2382
+ }
2383
+ },
2384
+ "OcrCell": {
2385
+ "category": {
2386
+ "values": [
2387
+ "UNSPECIFIED",
2388
+ "CAPTION",
2389
+ "FOOTNOTE",
2390
+ "FORMULA",
2391
+ "LIST_ITEM",
2392
+ "PAGE_FOOTER",
2393
+ "PAGE_HEADER",
2394
+ "PICTURE",
2395
+ "SECTION_HEADER",
2396
+ "TABLE",
2397
+ "TEXT",
2398
+ "TITLE",
2399
+ "OTHER",
2400
+ "UNKNOWN"
2401
+ ],
2402
+ "array": false
2403
+ }
2404
+ },
2405
+ "OcrDocumentRequest": {
2406
+ "format": {
2407
+ "values": [
2408
+ "AUTO",
2409
+ "PDF",
2410
+ "TIFF",
2411
+ "PNG",
2412
+ "JPEG",
2413
+ "BMP"
2414
+ ],
2415
+ "array": false
2416
+ }
2417
+ },
2418
+ "OcrDocumentResponse": {
2419
+ "detectedFormat": {
2420
+ "values": [
2421
+ "AUTO",
2422
+ "PDF",
2423
+ "TIFF",
2424
+ "PNG",
2425
+ "JPEG",
2426
+ "BMP"
2427
+ ],
2428
+ "array": false
2429
+ }
2430
+ },
2431
+ "PingEndpointInfo": {
2432
+ "targetType": {
2433
+ "values": [
2434
+ "TARGET_TYPE_UNSPECIFIED",
2435
+ "EMBEDDER",
2436
+ "RERANKER",
2437
+ "LLM"
2438
+ ],
2439
+ "array": false
2440
+ }
2441
+ },
2442
+ "PingOnceRequest": {
2443
+ "targetTypeHint": {
2444
+ "values": [
2445
+ "TARGET_TYPE_UNSPECIFIED",
2446
+ "EMBEDDER",
2447
+ "RERANKER",
2448
+ "LLM"
2449
+ ],
2450
+ "array": false
2451
+ },
2452
+ "payloadType": {
2453
+ "values": [
2454
+ "PAYLOAD_TYPE_UNSPECIFIED",
2455
+ "TEXT",
2456
+ "JSON",
2457
+ "BINARY"
2458
+ ],
2459
+ "array": false
2460
+ }
2461
+ },
2462
+ "PingStreamRequest": {
2463
+ "targetTypeHint": {
2464
+ "values": [
2465
+ "TARGET_TYPE_UNSPECIFIED",
2466
+ "EMBEDDER",
2467
+ "RERANKER",
2468
+ "LLM"
2469
+ ],
2470
+ "array": false
2471
+ },
2472
+ "payloadType": {
2473
+ "values": [
2474
+ "PAYLOAD_TYPE_UNSPECIFIED",
2475
+ "TEXT",
2476
+ "JSON",
2477
+ "BINARY"
2478
+ ],
2479
+ "array": false
2480
+ }
2481
+ },
2482
+ "RecursiveChunkingConfiguration": {
2483
+ "keepStrategy": {
2484
+ "values": [
2485
+ "KEEP_NONE",
2486
+ "KEEP_START",
2487
+ "KEEP_END"
2488
+ ],
2489
+ "array": false
2490
+ },
2491
+ "lengthMeasurement": {
2492
+ "values": [
2493
+ "CHARACTER_COUNT",
2494
+ "TOKEN_COUNT",
2495
+ "CUSTOM"
2496
+ ],
2497
+ "array": false
2498
+ }
2499
+ },
2500
+ "RerankerCreationRequest": {
2501
+ "providerType": {
2502
+ "values": [
2503
+ "OPENAI",
2504
+ "VLLM",
2505
+ "TEI",
2506
+ "LLAMA_CPP",
2507
+ "VOYAGE",
2508
+ "COHERE",
2509
+ "JINA"
2510
+ ],
2511
+ "array": false
2512
+ },
2513
+ "supportedModalities": {
2514
+ "values": [
2515
+ "TEXT",
2516
+ "IMAGE",
2517
+ "AUDIO",
2518
+ "VIDEO"
2519
+ ],
2520
+ "array": true
2521
+ }
2522
+ },
2523
+ "RerankerResponse": {
2524
+ "providerType": {
2525
+ "values": [
2526
+ "OPENAI",
2527
+ "VLLM",
2528
+ "TEI",
2529
+ "LLAMA_CPP",
2530
+ "VOYAGE",
2531
+ "COHERE",
2532
+ "JINA"
2533
+ ],
2534
+ "array": false
2535
+ },
2536
+ "supportedModalities": {
2537
+ "values": [
2538
+ "TEXT",
2539
+ "IMAGE",
2540
+ "AUDIO",
2541
+ "VIDEO"
2542
+ ],
2543
+ "array": true
2544
+ }
2545
+ },
2546
+ "ResultSetBoundary": {
2547
+ "kind": {
2548
+ "values": [
2549
+ "BEGIN",
2550
+ "END"
2551
+ ],
2552
+ "array": false
2553
+ }
2554
+ },
2555
+ "SentenceChunkingConfiguration": {
2556
+ "lengthMeasurement": {
2557
+ "values": [
2558
+ "CHARACTER_COUNT",
2559
+ "TOKEN_COUNT",
2560
+ "CUSTOM"
2561
+ ],
2562
+ "array": false
2563
+ }
2564
+ },
2565
+ "UpdateApiKeyRequest": {
2566
+ "status": {
2567
+ "values": [
2568
+ "ACTIVE",
2569
+ "INACTIVE"
2570
+ ],
2571
+ "array": false
2572
+ }
2573
+ },
2574
+ "UpdateEmbedderRequest": {
2575
+ "distributionType": {
2576
+ "values": [
2577
+ "DENSE",
2578
+ "SPARSE"
2579
+ ],
2580
+ "array": false
2581
+ }
2582
+ },
2583
+ "UpdateRerankerRequest": {
2584
+ "supportedModalities": {
2585
+ "values": [
2586
+ "TEXT",
2587
+ "IMAGE",
2588
+ "AUDIO",
2589
+ "VIDEO"
2590
+ ],
2591
+ "array": true
2592
+ }
2593
+ }
2594
+ };
2595
+ const MODEL_FREEFORM_FIELDS = {
2596
+ "JsonMemoryCreationRequest": [
2597
+ "metadata"
2598
+ ],
2599
+ "LLMCreationRequest": [
2600
+ "clientConfig"
2601
+ ],
2602
+ "LLMResponse": [
2603
+ "clientConfig"
2604
+ ],
2605
+ "LLMUpdateRequest": [
2606
+ "clientConfig"
2607
+ ],
2608
+ "LoggingOptions": [
2609
+ "callerAttributes"
2610
+ ],
2611
+ "Memory": [
2612
+ "metadata"
2613
+ ],
2614
+ "MemoryChunkResponse": [
2615
+ "metadata"
2616
+ ],
2617
+ "MemoryCreationRequest": [
2618
+ "metadata"
2619
+ ],
2620
+ "PostProcessor": [
2621
+ "config"
2622
+ ]
2623
+ };
2624
+ const SENSITIVE_FIELDS = {
2625
+ "CreateApiKeyResponse": [
2626
+ "rawApiKey"
2627
+ ],
2628
+ "SystemInitResponse": [
2629
+ "rootApiKey"
2630
+ ],
2631
+ "ApiKeyAuth": [
2632
+ "inlineSecret"
2633
+ ]
2634
+ };
2635
+ export const DEFAULT_MAX_STREAM_LINE_BYTES = 8 * 1024 * 1024;
2636
+ export const DEFAULT_CHUNKING_CONFIG = {
2637
+ recursive: {
2638
+ chunkSize: 512,
2639
+ chunkOverlap: 64,
2640
+ keepStrategy: "KEEP_END",
2641
+ lengthMeasurement: "CHARACTER_COUNT",
2642
+ },
2643
+ };
2644
+ function apiKeyToCredentials(apiKey) {
2645
+ return {
2646
+ kind: "CREDENTIAL_KIND_API_KEY",
2647
+ apiKey: { inlineSecret: apiKey },
2648
+ };
2649
+ }
2650
+ function withoutProviderApiKey(options) {
2651
+ if (!options)
2652
+ return undefined;
2653
+ const { apiKey: _apiKey, ...requestOptions } = options;
2654
+ return requestOptions;
2655
+ }
2656
+ function withDefaultSpaceChunkingConfig(request) {
2657
+ if (isSet(request.defaultChunkingConfig))
2658
+ return request;
2659
+ return { ...request, defaultChunkingConfig: DEFAULT_CHUNKING_CONFIG };
2660
+ }
2661
+ function normalizeMemoryCreateRequest(request, methodName) {
2662
+ const body = { ...request };
2663
+ if (isSet(body.originalContent) && !isSet(body.contentType)) {
2664
+ body.contentType = "text/plain";
2665
+ }
2666
+ if (isSet(body.originalContentB64) && !isSet(body.contentType)) {
2667
+ throw new TypeError(`${methodName} requires contentType when originalContentB64 is set.`);
2668
+ }
2669
+ return body;
2670
+ }
2671
+ function normalizeMemoryBatchCreateRequest(request) {
2672
+ return {
2673
+ requests: request.requests.map((item) => normalizeMemoryCreateRequest(item, "memories.batchCreate")),
2674
+ };
2675
+ }
2676
+ function inferCreateRequest(registryType, request, apiKey) {
2677
+ const body = { ...request };
2678
+ if (apiKey !== undefined && apiKey !== null && isSet(body.credentials)) {
2679
+ throw new TypeError(`${registryType}.create received both request.credentials and requestOptions.apiKey; pass credentials in exactly one place.`);
2680
+ }
2681
+ const modelIdentifier = typeof body.modelIdentifier === "string" ? body.modelIdentifier : undefined;
2682
+ const entry = modelIdentifier ? MODEL_REGISTRY[registryType]?.[modelIdentifier] : undefined;
2683
+ if (entry) {
2684
+ for (const [field, value] of Object.entries(entry)) {
2685
+ if (field === "dimensions") {
2686
+ const dimensions = value;
2687
+ if (!isSet(body.dimensionality) && dimensions?.default !== undefined) {
2688
+ body.dimensionality = dimensions.default;
2689
+ }
2690
+ }
2691
+ else if (!isSet(body[field])) {
2692
+ body[field] = value;
2693
+ }
2694
+ }
2695
+ }
2696
+ if (!isSet(body.endpointUrl) && typeof body.providerType === "string") {
2697
+ const endpointUrl = PROVIDER_ENDPOINTS[body.providerType];
2698
+ if (endpointUrl)
2699
+ body.endpointUrl = endpointUrl;
2700
+ }
2701
+ if (registryType === "embedders" && !isSet(body.distributionType)) {
2702
+ body.distributionType = "DENSE";
2703
+ }
2704
+ if (apiKey !== undefined && apiKey !== null && !isSet(body.credentials)) {
2705
+ body.credentials = apiKeyToCredentials(apiKey);
2706
+ }
2707
+ const endpointUrl = typeof body.endpointUrl === "string" ? body.endpointUrl : undefined;
2708
+ if (endpointUrl && endpointRequiresApiKey(endpointUrl) && !isSet(body.credentials)) {
2709
+ const host = endpointHost(endpointUrl) ?? endpointUrl;
2710
+ throw new TypeError(`${registryType}.create endpoint ${host} requires credentials; pass requestOptions.apiKey or request.credentials.`);
2711
+ }
2712
+ const missing = (REGISTRY_CREATE_REQUIRED_FIELDS[registryType] ?? []).filter((field) => !isSet(body[field]));
2713
+ if (missing.length > 0) {
2714
+ const modelHint = modelIdentifier ? ` for modelIdentifier '${modelIdentifier}'` : "";
2715
+ throw new TypeError(`Unable to infer ${registryType}.create required field(s)${modelHint}: ${missing.join(", ")}. `
2716
+ + "Provide explicit values or use a modelIdentifier from the bundled registry.");
2717
+ }
2718
+ return body;
2719
+ }
2720
+ function endpointHost(endpointUrl) {
2721
+ try {
2722
+ return new URL(endpointUrl).host;
2723
+ }
2724
+ catch {
2725
+ return undefined;
2726
+ }
2727
+ }
2728
+ function endpointRequiresApiKey(endpointUrl) {
2729
+ const host = endpointHost(endpointUrl);
2730
+ if (!host)
2731
+ return false;
2732
+ for (const provider of Object.values(PROVIDER_REGISTRY)) {
2733
+ for (const baseUrl of provider.baseUrlsRequiringApiKey ?? []) {
2734
+ if (endpointHost(baseUrl) === host)
2735
+ return true;
2736
+ }
2737
+ }
2738
+ return false;
2739
+ }
2740
+ const CHAT_POST_PROCESSOR_FACTORY = "com.goodmem.retrieval.postprocess.ChatPostProcessorFactory";
2741
+ function hasValue(value) {
2742
+ return value !== undefined && value !== null;
2743
+ }
2744
+ function rejectRetrieveOrphans(options) {
2745
+ const llmOrphans = [];
2746
+ if (!hasValue(options.llmId)) {
2747
+ if (hasValue(options.llmTemp))
2748
+ llmOrphans.push("llmTemp");
2749
+ if (hasValue(options.genTokenBudget))
2750
+ llmOrphans.push("genTokenBudget");
2751
+ if (hasValue(options.prompt))
2752
+ llmOrphans.push("prompt");
2753
+ if (hasValue(options.sysPrompt))
2754
+ llmOrphans.push("sysPrompt");
2755
+ }
2756
+ const rerankerOrphans = [];
2757
+ if (!hasValue(options.rerankerId) && hasValue(options.relevanceThreshold)) {
2758
+ rerankerOrphans.push("relevanceThreshold");
2759
+ }
2760
+ const pipelineOrphans = [];
2761
+ if (!hasValue(options.llmId) && !hasValue(options.rerankerId)) {
2762
+ if (hasValue(options.maxResults))
2763
+ pipelineOrphans.push("maxResults");
2764
+ if (hasValue(options.chronologicalResort))
2765
+ pipelineOrphans.push("chronologicalResort");
2766
+ }
2767
+ if (llmOrphans.length === 0 && rerankerOrphans.length === 0 && pipelineOrphans.length === 0)
2768
+ return;
2769
+ const messages = [];
2770
+ if (llmOrphans.length)
2771
+ messages.push(`${llmOrphans.join(", ")} require llmId to be set`);
2772
+ if (rerankerOrphans.length)
2773
+ messages.push(`${rerankerOrphans.join(", ")} require rerankerId to be set`);
2774
+ if (pipelineOrphans.length) {
2775
+ messages.push(`${pipelineOrphans.join(", ")} require at least one of llmId or rerankerId to be set`);
2776
+ }
2777
+ throw new TypeError(`memories.retrieve flat options: ${messages.join("; ")}.`);
2778
+ }
2779
+ function buildRetrieveRequest(message, options) {
2780
+ if (typeof message !== "string" || message.length === 0) {
2781
+ throw new TypeError("memories.retrieve(message, options) requires a non-empty message string.");
2782
+ }
2783
+ if (!options || !Array.isArray(options.spaceIds) || options.spaceIds.length === 0) {
2784
+ throw new TypeError("memories.retrieve(message, options) requires options.spaceIds with at least one space id.");
2785
+ }
2786
+ for (const [index, spaceId] of options.spaceIds.entries()) {
2787
+ if (typeof spaceId !== "string" || spaceId.length === 0) {
2788
+ throw new TypeError(`memories.retrieve options.spaceIds[${index}] must be a non-empty string.`);
2789
+ }
2790
+ }
2791
+ rejectRetrieveOrphans(options);
2792
+ const { spaceIds, llmId, rerankerId, llmTemp, genTokenBudget, relevanceThreshold, maxResults, prompt, sysPrompt, chronologicalResort, ...rest } = options;
2793
+ const config = {};
2794
+ if (hasValue(llmId))
2795
+ config.llm_id = llmId;
2796
+ if (hasValue(rerankerId))
2797
+ config.reranker_id = rerankerId;
2798
+ if (hasValue(llmTemp))
2799
+ config.llm_temp = llmTemp;
2800
+ if (hasValue(genTokenBudget))
2801
+ config.gen_token_budget = genTokenBudget;
2802
+ if (hasValue(relevanceThreshold))
2803
+ config.relevance_threshold = relevanceThreshold;
2804
+ if (hasValue(maxResults))
2805
+ config.max_results = maxResults;
2806
+ if (hasValue(prompt))
2807
+ config.prompt = prompt;
2808
+ if (hasValue(sysPrompt))
2809
+ config.sys_prompt = sysPrompt;
2810
+ if (hasValue(chronologicalResort))
2811
+ config.chronological_resort = chronologicalResort;
2812
+ const body = {
2813
+ ...rest,
2814
+ message,
2815
+ spaceKeys: spaceIds.map((spaceId) => ({ spaceId })),
2816
+ };
2817
+ if (Object.keys(config).length > 0) {
2818
+ body.postProcessor = { name: CHAT_POST_PROCESSOR_FACTORY, config };
2819
+ }
2820
+ return body;
2821
+ }
2822
+ function isFormDataBody(value) {
2823
+ return typeof FormData !== "undefined" && value instanceof FormData;
2824
+ }
2825
+ function newUploadFormData() {
2826
+ if (typeof FormData === "undefined") {
2827
+ throw new TypeError("FormData is not available in this runtime; use memories.create with originalContentB64 instead.");
2828
+ }
2829
+ return new FormData();
2830
+ }
2831
+ function normalizeUploadContentType(value) {
2832
+ if (typeof value !== "string")
2833
+ return undefined;
2834
+ const trimmed = value.trim();
2835
+ return trimmed.length > 0 ? trimmed : undefined;
2836
+ }
2837
+ function inferFileContentType(file, explicitContentType) {
2838
+ const contentType = normalizeUploadContentType(explicitContentType)
2839
+ ?? normalizeUploadContentType(file.type);
2840
+ if (!contentType) {
2841
+ throw new TypeError("memories.createFromFile requires contentType when file.type is empty.");
2842
+ }
2843
+ return contentType;
2844
+ }
2845
+ function requireBytesContentType(contentType) {
2846
+ const normalized = normalizeUploadContentType(contentType);
2847
+ if (!normalized) {
2848
+ throw new TypeError("memories.createFromBytes requires contentType for Uint8Array/ArrayBuffer content.");
2849
+ }
2850
+ return normalized;
2851
+ }
2852
+ function bytesToBlob(bytes, contentType) {
2853
+ if (typeof Blob === "undefined") {
2854
+ throw new TypeError("Blob is not available in this runtime; use memories.create with originalContentB64 instead.");
2855
+ }
2856
+ return new Blob([bytes], { type: contentType });
2857
+ }
2858
+ function bytesToBase64(bytes) {
2859
+ const array = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
2860
+ const bufferCtor = globalThis.Buffer;
2861
+ if (bufferCtor) {
2862
+ return bufferCtor.from(array).toString("base64");
2863
+ }
2864
+ if (typeof btoa === "function") {
2865
+ const chunkSize = 0x8000;
2866
+ let binary = "";
2867
+ for (let offset = 0; offset < array.length; offset += chunkSize) {
2868
+ const chunk = array.subarray(offset, offset + chunkSize);
2869
+ binary += String.fromCharCode(...chunk);
2870
+ }
2871
+ return btoa(binary);
2872
+ }
2873
+ throw new TypeError("Base64 encoding is not available in this runtime.");
2874
+ }
2875
+ async function blobToBase64(file, methodName) {
2876
+ if (!file || typeof file.arrayBuffer !== "function") {
2877
+ throw new TypeError(`${methodName} requires a Blob/File-compatible object with arrayBuffer().`);
2878
+ }
2879
+ return bytesToBase64(await file.arrayBuffer());
2880
+ }
2881
+ async function loadNodeFsForUpload(methodName = "memories.createFromPath") {
2882
+ try {
2883
+ const dynamicImport = new Function("specifier", "return import(specifier)");
2884
+ return await dynamicImport("node:fs");
2885
+ }
2886
+ catch (error) {
2887
+ throw new TypeError(`${methodName} requires a Node.js runtime with node:fs. `
2888
+ + "In browsers, use memories.createFromFile with a Blob/File or memories.createFromBytes instead.", { cause: error });
2889
+ }
2890
+ }
2891
+ async function loadNodeFsForOcr() {
2892
+ try {
2893
+ const dynamicImport = new Function("specifier", "return import(specifier)");
2894
+ return await dynamicImport("node:fs");
2895
+ }
2896
+ catch (error) {
2897
+ throw new TypeError("ocr.documentFromPath requires a Node.js runtime with node:fs. "
2898
+ + "In browsers, use ocr.documentFromFile with a Blob/File or ocr.documentFromBytes instead.", { cause: error });
2899
+ }
2900
+ }
2901
+ const PATH_MIME_TYPES = {
2902
+ avif: "image/avif",
2903
+ bmp: "image/bmp",
2904
+ csv: "text/csv",
2905
+ doc: "application/msword",
2906
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2907
+ gif: "image/gif",
2908
+ gz: "application/gzip",
2909
+ heic: "image/heic",
2910
+ heif: "image/heif",
2911
+ htm: "text/html",
2912
+ html: "text/html",
2913
+ jpeg: "image/jpeg",
2914
+ jpg: "image/jpeg",
2915
+ json: "application/json",
2916
+ jsonl: "application/x-ndjson",
2917
+ m4a: "audio/mp4",
2918
+ markdown: "text/markdown",
2919
+ md: "text/markdown",
2920
+ mov: "video/quicktime",
2921
+ mp3: "audio/mpeg",
2922
+ mp4: "video/mp4",
2923
+ pdf: "application/pdf",
2924
+ png: "image/png",
2925
+ ppt: "application/vnd.ms-powerpoint",
2926
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
2927
+ svg: "image/svg+xml",
2928
+ tar: "application/x-tar",
2929
+ text: "text/plain",
2930
+ tif: "image/tiff",
2931
+ tiff: "image/tiff",
2932
+ ts: "text/typescript",
2933
+ tsv: "text/tab-separated-values",
2934
+ txt: "text/plain",
2935
+ wav: "audio/wav",
2936
+ webm: "video/webm",
2937
+ webp: "image/webp",
2938
+ xls: "application/vnd.ms-excel",
2939
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2940
+ xml: "application/xml",
2941
+ zip: "application/zip",
2942
+ };
2943
+ function parseFileUrlString(path) {
2944
+ try {
2945
+ const url = new URL(path);
2946
+ return url.protocol === "file:" ? url : undefined;
2947
+ }
2948
+ catch {
2949
+ return undefined;
2950
+ }
2951
+ }
2952
+ function uploadPathname(path) {
2953
+ if (path instanceof URL)
2954
+ return path.pathname;
2955
+ return parseFileUrlString(path)?.pathname ?? path;
2956
+ }
2957
+ function extensionFromUploadPath(path) {
2958
+ const rawPath = uploadPathname(path);
2959
+ const trimmed = rawPath.replace(/[\\/]+$/, "");
2960
+ const candidate = trimmed.split(/[\\/]/).pop() ?? "";
2961
+ const match = /\.([A-Za-z0-9]+)$/.exec(candidate);
2962
+ return match?.[1]?.toLowerCase();
2963
+ }
2964
+ function inferPathContentType(path, explicitContentType) {
2965
+ const explicit = normalizeUploadContentType(explicitContentType);
2966
+ if (explicit)
2967
+ return explicit;
2968
+ const extension = extensionFromUploadPath(path);
2969
+ return extension ? PATH_MIME_TYPES[extension] ?? "application/octet-stream" : "application/octet-stream";
2970
+ }
2971
+ function requireUploadPath(path, methodName = "memories.createFromPath") {
2972
+ if (typeof path === "string" && path.trim().length > 0)
2973
+ return parseFileUrlString(path) ?? path;
2974
+ if (path instanceof URL)
2975
+ return path;
2976
+ throw new TypeError(`${methodName} requires a non-empty path.`);
2977
+ }
2978
+ function requireOcrPath(path) {
2979
+ if (typeof path === "string" && path.trim().length > 0)
2980
+ return path;
2981
+ if (path instanceof URL)
2982
+ return path;
2983
+ throw new TypeError("ocr.documentFromPath requires a non-empty path.");
2984
+ }
2985
+ function uploadFilenameFromPath(path, explicitFilename) {
2986
+ const explicit = typeof explicitFilename === "string" ? explicitFilename.trim() : "";
2987
+ if (explicit)
2988
+ return explicit;
2989
+ const rawPath = uploadPathname(path);
2990
+ const trimmed = rawPath.replace(/[\\/]+$/, "");
2991
+ const candidate = trimmed.split(/[\\/]/).pop();
2992
+ if (!candidate)
2993
+ return "memory.bin";
2994
+ try {
2995
+ return decodeURIComponent(candidate);
2996
+ }
2997
+ catch {
2998
+ return candidate;
2999
+ }
3000
+ }
3001
+ async function pathToBlob(path, contentType, methodName = "memories.createFromPath") {
3002
+ const fs = await loadNodeFsForUpload(methodName);
3003
+ if (typeof fs.openAsBlob === "function") {
3004
+ try {
3005
+ return await fs.openAsBlob(path, { type: contentType });
3006
+ }
3007
+ catch (error) {
3008
+ throw new TypeError(`${methodName} could not open the file with fs.openAsBlob. `
3009
+ + "Verify the path is readable, or use memories.createFromFile with a Blob/File or memories.createFromBytes.", { cause: error });
3010
+ }
3011
+ }
3012
+ if (typeof fs.promises?.readFile === "function") {
3013
+ try {
3014
+ const bytes = await fs.promises.readFile(path);
3015
+ return bytesToBlob(bytes, contentType);
3016
+ }
3017
+ catch (error) {
3018
+ throw new TypeError(`${methodName} could not read the file with fs.promises.readFile. `
3019
+ + "Verify the path is readable, or use memories.createFromFile with a Blob/File or memories.createFromBytes.", { cause: error });
3020
+ }
3021
+ }
3022
+ throw new TypeError(`${methodName} requires Node.js fs.openAsBlob or fs.promises.readFile. `
3023
+ + "Upgrade Node, or use memories.createFromFile with a Blob/File, memories.createFromBytes, or memories.create with originalContentB64.");
3024
+ }
3025
+ async function ocrPathToBase64(path) {
3026
+ const uploadPath = requireOcrPath(path);
3027
+ const fs = await loadNodeFsForOcr();
3028
+ if (typeof fs.promises?.readFile !== "function") {
3029
+ throw new TypeError("ocr.documentFromPath requires Node.js fs.promises.readFile. "
3030
+ + "Upgrade Node, or use ocr.documentFromFile with a Blob/File or ocr.documentFromBytes.");
3031
+ }
3032
+ try {
3033
+ const bytes = await fs.promises.readFile(uploadPath);
3034
+ return bytesToBase64(bytes);
3035
+ }
3036
+ catch (error) {
3037
+ throw new TypeError("ocr.documentFromPath could not read the file with fs.promises.readFile. "
3038
+ + "Verify the path is readable, or use ocr.documentFromFile with a Blob/File or ocr.documentFromBytes.", { cause: error });
3039
+ }
3040
+ }
3041
+ function uploadFilename(file, explicitFilename) {
3042
+ const explicit = typeof explicitFilename === "string" ? explicitFilename.trim() : "";
3043
+ if (explicit)
3044
+ return explicit;
3045
+ const fileName = file.name;
3046
+ return typeof fileName === "string" && fileName.trim() ? fileName : "memory.bin";
3047
+ }
3048
+ function appendUploadFile(formData, fieldName, file, filename) {
3049
+ formData.append(fieldName, file, uploadFilename(file, filename));
3050
+ }
3051
+ function memoryCreateUploadFormData(request, requestField, fileField) {
3052
+ const { file, filename, contentType: explicitContentType, ...metadata } = request;
3053
+ const contentType = inferFileContentType(file, explicitContentType);
3054
+ const formData = newUploadFormData();
3055
+ formData.append(requestField, JSON.stringify(stripNullishFields({ ...metadata, contentType }, "JsonMemoryCreationRequest")));
3056
+ appendUploadFile(formData, fileField, file, filename);
3057
+ return formData;
3058
+ }
3059
+ function memoryBatchCreateUploadFormData(requests, requestField, fileFieldPrefix) {
3060
+ if (requests.length === 0) {
3061
+ throw new TypeError("memories.batchCreateFromFiles requires at least one request.");
3062
+ }
3063
+ const formData = newUploadFormData();
3064
+ const requestParts = requests.map((request, index) => {
3065
+ const { file, filename, contentType: explicitContentType, ...metadata } = request;
3066
+ const contentType = inferFileContentType(file, explicitContentType);
3067
+ const fileField = `${fileFieldPrefix}${index}`;
3068
+ appendUploadFile(formData, fileField, file, filename);
3069
+ return stripNullishFields({ ...metadata, contentType, fileField }, "JsonMemoryCreationRequest");
3070
+ });
3071
+ formData.append(requestField, JSON.stringify(requestParts));
3072
+ return formData;
3073
+ }
3074
+ export class GoodMemError extends Error {
3075
+ constructor(message) {
3076
+ super(message);
3077
+ this.name = new.target.name;
3078
+ }
3079
+ }
3080
+ export class NetworkError extends GoodMemError {
3081
+ constructor(message, options) {
3082
+ super(message);
3083
+ if (options?.cause !== undefined) {
3084
+ this.cause = options.cause;
3085
+ }
3086
+ }
3087
+ }
3088
+ export class ParseError extends GoodMemError {
3089
+ constructor(message, options) {
3090
+ super(message);
3091
+ if (options?.cause !== undefined) {
3092
+ this.cause = options.cause;
3093
+ }
3094
+ }
3095
+ }
3096
+ export class StreamLineTooLargeError extends GoodMemError {
3097
+ }
3098
+ export class PaginationLoopError extends GoodMemError {
3099
+ }
3100
+ export class APIError extends GoodMemError {
3101
+ statusCode;
3102
+ body;
3103
+ response;
3104
+ constructor(message, statusCode, body, response) {
3105
+ super(message);
3106
+ this.statusCode = statusCode;
3107
+ this.body = body;
3108
+ this.response = response;
3109
+ }
3110
+ }
3111
+ export class BadRequestError extends APIError {
3112
+ }
3113
+ export class AuthenticationError extends APIError {
3114
+ }
3115
+ export class PermissionDeniedError extends APIError {
3116
+ }
3117
+ export class NotFoundError extends APIError {
3118
+ }
3119
+ export class ConflictError extends APIError {
3120
+ }
3121
+ export class UnprocessableEntityError extends APIError {
3122
+ }
3123
+ export class RateLimitError extends APIError {
3124
+ retryAfter;
3125
+ constructor(message, statusCode, body, response, retryAfter) {
3126
+ super(message, statusCode, body, response);
3127
+ this.retryAfter = retryAfter;
3128
+ }
3129
+ }
3130
+ export class InternalServerError extends APIError {
3131
+ }
3132
+ const STATUS_ERRORS = {
3133
+ 400: BadRequestError,
3134
+ 401: AuthenticationError,
3135
+ 403: PermissionDeniedError,
3136
+ 404: NotFoundError,
3137
+ 409: ConflictError,
3138
+ 422: UnprocessableEntityError,
3139
+ 429: RateLimitError,
3140
+ };
3141
+ export class Page {
3142
+ items;
3143
+ nextToken;
3144
+ fetchNext;
3145
+ constructor(items, nextToken, fetchNext) {
3146
+ this.items = items;
3147
+ this.nextToken = nextToken;
3148
+ this.fetchNext = fetchNext;
3149
+ }
3150
+ async *[Symbol.asyncIterator]() {
3151
+ let page = this;
3152
+ const seenNextTokens = new Set();
3153
+ while (page) {
3154
+ for (const item of page.items) {
3155
+ yield item;
3156
+ }
3157
+ if (!page.nextToken) {
3158
+ page = undefined;
3159
+ continue;
3160
+ }
3161
+ if (seenNextTokens.has(page.nextToken)) {
3162
+ throw new PaginationLoopError(`Pagination loop detected: server repeated nextToken ${page.nextToken}`);
3163
+ }
3164
+ seenNextTokens.add(page.nextToken);
3165
+ page = await page.fetchNext(page.nextToken);
3166
+ }
3167
+ }
3168
+ }
3169
+ function encodePath(value) {
3170
+ if (typeof value === "number") {
3171
+ if (!Number.isFinite(value)) {
3172
+ throw new TypeError("path parameter must be a finite number");
3173
+ }
3174
+ return encodeURIComponent(String(value));
3175
+ }
3176
+ return encodeURIComponent(value);
3177
+ }
3178
+ function assertPathParam(name, value, expected) {
3179
+ if (expected === "number") {
3180
+ if (typeof value !== "number" || !Number.isFinite(value)) {
3181
+ throw new TypeError(`${name} must be a finite number`);
3182
+ }
3183
+ return;
3184
+ }
3185
+ if (typeof value !== "string" || value.length === 0) {
3186
+ throw new TypeError(`${name} must be a non-empty string`);
3187
+ }
3188
+ }
3189
+ function appendQuery(query, key, value) {
3190
+ if (value === undefined || value === null)
3191
+ return;
3192
+ query[key] = String(value);
3193
+ }
3194
+ function appendDeepObject(query, key, value) {
3195
+ if (value === undefined || value === null)
3196
+ return;
3197
+ if (typeof value !== "object" || Array.isArray(value)) {
3198
+ throw new TypeError(`${key} must be an object`);
3199
+ }
3200
+ for (const [childKey, childValue] of Object.entries(value)) {
3201
+ if (childValue !== undefined && childValue !== null) {
3202
+ query[`${key}[${childKey}]`] = String(childValue);
3203
+ }
3204
+ }
3205
+ }
3206
+ function headersToRecord(headers) {
3207
+ const out = {};
3208
+ if (!headers)
3209
+ return out;
3210
+ new Headers(headers).forEach((value, key) => {
3211
+ out[key] = value;
3212
+ });
3213
+ return out;
3214
+ }
3215
+ function mergeHeaders(...headers) {
3216
+ const merged = new Headers();
3217
+ for (const item of headers) {
3218
+ if (!item)
3219
+ continue;
3220
+ new Headers(item).forEach((value, key) => {
3221
+ if (value !== undefined && value !== "undefined") {
3222
+ merged.set(key, value);
3223
+ }
3224
+ });
3225
+ }
3226
+ return merged;
3227
+ }
3228
+ function validateMaxStreamLineBytes(value) {
3229
+ if (!Number.isInteger(value) || value <= 0) {
3230
+ throw new TypeError("maxStreamLineBytes must be a positive integer");
3231
+ }
3232
+ return value;
3233
+ }
3234
+ function appendNdjsonLineSegment(lineParts, lineByteCount, segment, maxLineBytes, method, path) {
3235
+ if (segment.byteLength === 0)
3236
+ return lineByteCount;
3237
+ const nextByteCount = lineByteCount + segment.byteLength;
3238
+ if (nextByteCount > maxLineBytes) {
3239
+ throw new StreamLineTooLargeError(`NDJSON stream line from ${method} ${path} exceeded maxStreamLineBytes (${maxLineBytes} bytes). `
3240
+ + "Large inlined memory content can exceed the streaming line limit; use memories.content for large memory payloads.");
3241
+ }
3242
+ lineParts.push(segment);
3243
+ return nextByteCount;
3244
+ }
3245
+ function decodeNdjsonLine(decoder, lineParts, lineByteCount) {
3246
+ if (lineByteCount === 0)
3247
+ return "";
3248
+ if (lineParts.length === 1)
3249
+ return decoder.decode(lineParts[0]).trim();
3250
+ const lineBytes = new Uint8Array(lineByteCount);
3251
+ let offset = 0;
3252
+ for (const part of lineParts) {
3253
+ lineBytes.set(part, offset);
3254
+ offset += part.byteLength;
3255
+ }
3256
+ return decoder.decode(lineBytes).trim();
3257
+ }
3258
+ function isRequestOptions(value) {
3259
+ if (!value || typeof value !== "object" || Array.isArray(value))
3260
+ return false;
3261
+ return "signal" in value || "timeoutMs" in value || "headers" in value;
3262
+ }
3263
+ function isSet(value) {
3264
+ return value !== undefined && value !== null;
3265
+ }
3266
+ function checkTimeoutBudget(methodId, body, requestOptions) {
3267
+ const rule = TIMEOUT_BUDGET_RULES[methodId];
3268
+ const currentTimeoutMs = requestOptions?.timeoutMs;
3269
+ if (!rule || currentTimeoutMs === undefined || currentTimeoutMs === null)
3270
+ return;
3271
+ const bodyObject = body && typeof body === "object" && !Array.isArray(body)
3272
+ ? body
3273
+ : {};
3274
+ if (rule.appliesWhenField && !bodyObject[rule.appliesWhenField])
3275
+ return;
3276
+ const rawBudget = bodyObject[rule.field] ?? rule.fieldDefault;
3277
+ if (rawBudget === undefined || rawBudget === null)
3278
+ return;
3279
+ const budgetValue = Number(rawBudget);
3280
+ if (!Number.isFinite(budgetValue))
3281
+ return;
3282
+ const serverBudgetMs = rule.unit === "s" ? budgetValue * 1000 : budgetValue;
3283
+ const requiredTimeoutMs = serverBudgetMs + rule.headroomMs;
3284
+ if (requiredTimeoutMs > currentTimeoutMs) {
3285
+ throw new TypeError(`${methodId} requires requestOptions.timeoutMs >= ${requiredTimeoutMs}ms `
3286
+ + `(server timeout budget ${serverBudgetMs}ms + ${rule.headroomMs}ms headroom); `
3287
+ + `current requestOptions.timeoutMs is ${currentTimeoutMs}ms. `
3288
+ + "Pass a larger requestOptions.timeoutMs.");
3289
+ }
3290
+ }
3291
+ function stripNullishFields(value, modelName, seen = new WeakMap()) {
3292
+ if (!value || typeof value !== "object")
3293
+ return value;
3294
+ if (seen.has(value))
3295
+ return seen.get(value);
3296
+ if (Array.isArray(value)) {
3297
+ const clone = [];
3298
+ seen.set(value, clone);
3299
+ for (const item of value)
3300
+ clone.push(stripNullishFields(item, modelName, seen));
3301
+ return clone;
3302
+ }
3303
+ const clone = {};
3304
+ seen.set(value, clone);
3305
+ const freeformFields = new Set(MODEL_FREEFORM_FIELDS[modelName ?? ""] ?? []);
3306
+ const nestedFields = MODEL_FIELDS[modelName ?? ""] ?? {};
3307
+ for (const [key, childValue] of Object.entries(value)) {
3308
+ if (childValue === undefined || childValue === null)
3309
+ continue;
3310
+ if (freeformFields.has(key)) {
3311
+ clone[key] = childValue;
3312
+ continue;
3313
+ }
3314
+ clone[key] = stripNullishFields(childValue, nestedFields[key]?.model, seen);
3315
+ }
3316
+ return clone;
3317
+ }
3318
+ function isEmptyOneOfFrame(value) {
3319
+ if (!value || typeof value !== "object" || Array.isArray(value))
3320
+ return false;
3321
+ const entries = Object.values(value);
3322
+ if (entries.length === 0)
3323
+ return true;
3324
+ return entries.every((entry) => {
3325
+ if (entry === undefined || entry === null)
3326
+ return true;
3327
+ return typeof entry === "object" && !Array.isArray(entry) && Object.keys(entry).length === 0;
3328
+ });
3329
+ }
3330
+ function validateRange(modelName, field, value, rule) {
3331
+ if (value === undefined || value === null)
3332
+ return;
3333
+ if (typeof value !== "number" || !Number.isFinite(value))
3334
+ return;
3335
+ if (typeof rule.minimum === "number") {
3336
+ if (rule.exclusiveMinimum === true ? value <= rule.minimum : value < rule.minimum) {
3337
+ throw new TypeError(`${modelName}.${field} must be greater than ${rule.exclusiveMinimum === true ? "" : "or equal to "}${rule.minimum}`);
3338
+ }
3339
+ }
3340
+ if (typeof rule.maximum === "number") {
3341
+ if (rule.exclusiveMaximum === true ? value >= rule.maximum : value > rule.maximum) {
3342
+ throw new TypeError(`${modelName}.${field} must be less than ${rule.exclusiveMaximum === true ? "" : "or equal to "}${rule.maximum}`);
3343
+ }
3344
+ }
3345
+ }
3346
+ function validateModel(modelName, value, mode = "request", seen = new Set()) {
3347
+ if (!value || typeof value !== "object")
3348
+ return;
3349
+ if (seen.has(value))
3350
+ return;
3351
+ seen.add(value);
3352
+ const obj = value;
3353
+ const rules = MODEL_RULES[modelName];
3354
+ if (rules?.oneOf) {
3355
+ for (const group of rules.oneOf) {
3356
+ const count = group.fields.filter((field) => isSet(obj[field])).length;
3357
+ if (count !== 1) {
3358
+ throw new TypeError(group.message);
3359
+ }
3360
+ }
3361
+ }
3362
+ if (rules?.mutex) {
3363
+ for (const group of rules.mutex) {
3364
+ const count = group.fields.filter((field) => isSet(obj[field])).length;
3365
+ if (group.required ? count !== 1 : count > 1) {
3366
+ throw new TypeError(group.message);
3367
+ }
3368
+ }
3369
+ }
3370
+ if (rules?.requiredCompanions) {
3371
+ for (const companion of rules.requiredCompanions) {
3372
+ if (isSet(obj[companion.trigger]) && !isSet(obj[companion.required])) {
3373
+ throw new TypeError(companion.message);
3374
+ }
3375
+ }
3376
+ }
3377
+ if (mode === "request" && rules?.ranges) {
3378
+ for (const rule of rules.ranges) {
3379
+ validateRange(modelName, rule.field, obj[rule.field], rule);
3380
+ }
3381
+ }
3382
+ const fieldRules = MODEL_FIELDS[modelName];
3383
+ if (!fieldRules)
3384
+ return;
3385
+ for (const [field, nested] of Object.entries(fieldRules)) {
3386
+ const nestedValue = obj[field];
3387
+ if (!isSet(nestedValue))
3388
+ continue;
3389
+ if (nested.array) {
3390
+ if (Array.isArray(nestedValue)) {
3391
+ for (const item of nestedValue)
3392
+ validateModel(nested.model, item, mode, seen);
3393
+ }
3394
+ }
3395
+ else {
3396
+ validateModel(nested.model, nestedValue, mode, seen);
3397
+ }
3398
+ }
3399
+ }
3400
+ const NODE_INSPECT_CUSTOM = Symbol.for("nodejs.util.inspect.custom");
3401
+ const REDACTED_SECRET = "[REDACTED]";
3402
+ function redactedClone(modelName, value, seen = new WeakMap()) {
3403
+ if (!value || typeof value !== "object")
3404
+ return value;
3405
+ if (Array.isArray(value)) {
3406
+ return value.map((item) => redactedClone(modelName, item, seen));
3407
+ }
3408
+ if (seen.has(value))
3409
+ return seen.get(value);
3410
+ const obj = value;
3411
+ const clone = {};
3412
+ seen.set(value, clone);
3413
+ const sensitive = new Set(SENSITIVE_FIELDS[modelName] ?? []);
3414
+ const nestedFields = MODEL_FIELDS[modelName] ?? {};
3415
+ for (const [key, childValue] of Object.entries(obj)) {
3416
+ if (sensitive.has(key)) {
3417
+ clone[key] = REDACTED_SECRET;
3418
+ continue;
3419
+ }
3420
+ const nested = nestedFields[key];
3421
+ if (nested && isSet(childValue)) {
3422
+ clone[key] = nested.array && Array.isArray(childValue)
3423
+ ? childValue.map((item) => redactedClone(nested.model, item, seen))
3424
+ : redactedClone(nested.model, childValue, seen);
3425
+ }
3426
+ else {
3427
+ clone[key] = childValue;
3428
+ }
3429
+ }
3430
+ return clone;
3431
+ }
3432
+ function coerceUnknownResponseEnums(modelName, value, seen = new WeakSet()) {
3433
+ if (!modelName || !value || typeof value !== "object")
3434
+ return;
3435
+ if (Array.isArray(value)) {
3436
+ for (const item of value)
3437
+ coerceUnknownResponseEnums(modelName, item, seen);
3438
+ return;
3439
+ }
3440
+ if (seen.has(value))
3441
+ return;
3442
+ seen.add(value);
3443
+ const obj = value;
3444
+ const enumRules = MODEL_ENUM_FIELDS[modelName] ?? {};
3445
+ for (const [field, rule] of Object.entries(enumRules)) {
3446
+ const fieldValue = obj[field];
3447
+ if (!isSet(fieldValue))
3448
+ continue;
3449
+ if (rule.array) {
3450
+ if (Array.isArray(fieldValue)) {
3451
+ obj[field] = fieldValue.map((item) => (typeof item === "string" && !rule.values.includes(item)) ? null : item);
3452
+ }
3453
+ }
3454
+ else if (typeof fieldValue === "string" && !rule.values.includes(fieldValue)) {
3455
+ obj[field] = null;
3456
+ }
3457
+ }
3458
+ const fieldRules = MODEL_FIELDS[modelName];
3459
+ if (!fieldRules)
3460
+ return;
3461
+ for (const [field, nested] of Object.entries(fieldRules)) {
3462
+ const nestedValue = obj[field];
3463
+ if (!isSet(nestedValue))
3464
+ continue;
3465
+ if (nested.array) {
3466
+ if (Array.isArray(nestedValue)) {
3467
+ for (const item of nestedValue)
3468
+ coerceUnknownResponseEnums(nested.model, item, seen);
3469
+ }
3470
+ }
3471
+ else {
3472
+ coerceUnknownResponseEnums(nested.model, nestedValue, seen);
3473
+ }
3474
+ }
3475
+ }
3476
+ function attachResponseHelpers(modelName, value, seen = new WeakSet()) {
3477
+ if (!modelName || !value || typeof value !== "object")
3478
+ return;
3479
+ if (Array.isArray(value)) {
3480
+ for (const item of value)
3481
+ attachResponseHelpers(modelName, item, seen);
3482
+ return;
3483
+ }
3484
+ if (seen.has(value))
3485
+ return;
3486
+ seen.add(value);
3487
+ const obj = value;
3488
+ try {
3489
+ Object.defineProperty(obj, "toJSON", {
3490
+ configurable: true,
3491
+ enumerable: false,
3492
+ value: () => redactedClone(modelName, value),
3493
+ });
3494
+ Object.defineProperty(obj, NODE_INSPECT_CUSTOM, {
3495
+ configurable: true,
3496
+ enumerable: false,
3497
+ value: () => redactedClone(modelName, value),
3498
+ });
3499
+ }
3500
+ catch {
3501
+ // Parsed JSON responses are extensible; ignore exotic/frozen objects defensively.
3502
+ }
3503
+ const fieldRules = MODEL_FIELDS[modelName];
3504
+ if (!fieldRules)
3505
+ return;
3506
+ for (const [field, nested] of Object.entries(fieldRules)) {
3507
+ const nestedValue = obj[field];
3508
+ if (!isSet(nestedValue))
3509
+ continue;
3510
+ if (nested.array) {
3511
+ if (Array.isArray(nestedValue)) {
3512
+ for (const item of nestedValue)
3513
+ attachResponseHelpers(nested.model, item, seen);
3514
+ }
3515
+ }
3516
+ else {
3517
+ attachResponseHelpers(nested.model, nestedValue, seen);
3518
+ }
3519
+ }
3520
+ }
3521
+ function prepareResponse(modelName, value) {
3522
+ if (modelName) {
3523
+ coerceUnknownResponseEnums(modelName, value);
3524
+ validateModel(modelName, value, "response");
3525
+ attachResponseHelpers(modelName, value);
3526
+ }
3527
+ return value;
3528
+ }
3529
+ class HttpTransport {
3530
+ baseUrl;
3531
+ fetchImpl;
3532
+ defaultHeaders;
3533
+ maxStreamLineBytes;
3534
+ constructor(config) {
3535
+ if (!config.baseUrl || config.baseUrl.trim() === "") {
3536
+ throw new TypeError("baseUrl must be a non-empty string");
3537
+ }
3538
+ this.baseUrl = new URL(config.baseUrl);
3539
+ this.fetchImpl = config.fetch ?? fetch;
3540
+ this.defaultHeaders = mergeHeaders(config.headers, config.apiKey ? { "x-api-key": config.apiKey } : undefined);
3541
+ this.maxStreamLineBytes = validateMaxStreamLineBytes(config.maxStreamLineBytes ?? DEFAULT_MAX_STREAM_LINE_BYTES);
3542
+ }
3543
+ async requestJson(method, path, options = {}, responseModel) {
3544
+ const { response, cleanup } = await this.fetch(method, path, options);
3545
+ try {
3546
+ if (response.status === 204) {
3547
+ if (responseModel) {
3548
+ throw new ParseError(`Expected JSON response body from ${method} ${path} but received status 204`);
3549
+ }
3550
+ return undefined;
3551
+ }
3552
+ let text;
3553
+ try {
3554
+ text = await response.text();
3555
+ }
3556
+ catch (error) {
3557
+ throw new NetworkError(`Failed to read JSON response body from ${method} ${path}`, { cause: error });
3558
+ }
3559
+ if (!text) {
3560
+ if (responseModel) {
3561
+ throw new ParseError(`Expected JSON response body from ${method} ${path} but received an empty body`);
3562
+ }
3563
+ return undefined;
3564
+ }
3565
+ let parsed;
3566
+ try {
3567
+ parsed = JSON.parse(text);
3568
+ }
3569
+ catch (error) {
3570
+ throw new ParseError(`Failed to parse JSON response from ${method} ${path}`, { cause: error });
3571
+ }
3572
+ return prepareResponse(responseModel, parsed);
3573
+ }
3574
+ finally {
3575
+ cleanup();
3576
+ }
3577
+ }
3578
+ async requestBytes(method, path, options = {}) {
3579
+ const { response, cleanup } = await this.fetch(method, path, options);
3580
+ try {
3581
+ let bytes;
3582
+ try {
3583
+ bytes = await response.arrayBuffer();
3584
+ }
3585
+ catch (error) {
3586
+ throw new NetworkError(`Failed to read bytes response body from ${method} ${path}`, { cause: error });
3587
+ }
3588
+ return new Uint8Array(bytes);
3589
+ }
3590
+ finally {
3591
+ cleanup();
3592
+ }
3593
+ }
3594
+ async paginate(path, query, itemField, options, responseModel) {
3595
+ const load = async (nextToken) => {
3596
+ const pageQuery = { ...(query ?? {}) };
3597
+ if (nextToken)
3598
+ pageQuery.nextToken = nextToken;
3599
+ const response = await this.requestJson("GET", path, { query: pageQuery, ...options }, responseModel);
3600
+ const responseObject = response;
3601
+ const items = (responseObject[itemField] ?? []);
3602
+ const token = responseObject.nextToken;
3603
+ return new Page(items, token, load);
3604
+ };
3605
+ return load(query?.nextToken);
3606
+ }
3607
+ async *streamNdjson(method, path, body, options = {}, responseModel) {
3608
+ const { response, cleanup } = await this.fetch(method, path, {
3609
+ ...options,
3610
+ body,
3611
+ headers: mergeHeaders(options.headers, { Accept: "application/x-ndjson" }),
3612
+ });
3613
+ if (!response.body) {
3614
+ cleanup();
3615
+ throw new ParseError(`Expected NDJSON response body from ${method} ${path} but response body is unavailable`);
3616
+ }
3617
+ const reader = response.body.getReader();
3618
+ const decoder = new TextDecoder();
3619
+ let lineParts = [];
3620
+ let lineByteCount = 0;
3621
+ let naturalEof = false;
3622
+ let sawFrame = false;
3623
+ let streamError;
3624
+ try {
3625
+ for (;;) {
3626
+ let chunk;
3627
+ try {
3628
+ chunk = await reader.read();
3629
+ }
3630
+ catch (error) {
3631
+ throw new NetworkError(`Failed to read NDJSON stream from ${method} ${path}`, { cause: error });
3632
+ }
3633
+ const { value, done } = chunk;
3634
+ if (done) {
3635
+ naturalEof = true;
3636
+ break;
3637
+ }
3638
+ if (!value)
3639
+ continue;
3640
+ let start = 0;
3641
+ let newline = value.indexOf(0x0a, start);
3642
+ while (newline >= 0) {
3643
+ lineByteCount = appendNdjsonLineSegment(lineParts, lineByteCount, value.subarray(start, newline), this.maxStreamLineBytes, method, path);
3644
+ const line = decodeNdjsonLine(decoder, lineParts, lineByteCount);
3645
+ lineParts = [];
3646
+ lineByteCount = 0;
3647
+ if (line) {
3648
+ sawFrame = true;
3649
+ const parsed = parseNdjsonLine(line, method, path);
3650
+ if (!isEmptyOneOfFrame(parsed))
3651
+ yield prepareResponse(responseModel, parsed);
3652
+ }
3653
+ start = newline + 1;
3654
+ newline = value.indexOf(0x0a, start);
3655
+ }
3656
+ if (start < value.byteLength) {
3657
+ lineByteCount = appendNdjsonLineSegment(lineParts, lineByteCount, value.subarray(start), this.maxStreamLineBytes, method, path);
3658
+ }
3659
+ }
3660
+ const tail = decodeNdjsonLine(decoder, lineParts, lineByteCount);
3661
+ if (tail) {
3662
+ sawFrame = true;
3663
+ const parsed = parseNdjsonLine(tail, method, path);
3664
+ if (!isEmptyOneOfFrame(parsed))
3665
+ yield prepareResponse(responseModel, parsed);
3666
+ }
3667
+ if (!sawFrame) {
3668
+ throw new ParseError(`Expected NDJSON response body from ${method} ${path} but received an empty stream`);
3669
+ }
3670
+ }
3671
+ catch (error) {
3672
+ streamError = error;
3673
+ throw error;
3674
+ }
3675
+ finally {
3676
+ if (!naturalEof) {
3677
+ try {
3678
+ await reader.cancel(streamError);
3679
+ }
3680
+ catch {
3681
+ // Ignore cancellation cleanup failures so they do not mask stream errors.
3682
+ }
3683
+ }
3684
+ try {
3685
+ reader.releaseLock();
3686
+ }
3687
+ catch (error) {
3688
+ if (naturalEof)
3689
+ throw error;
3690
+ }
3691
+ finally {
3692
+ cleanup();
3693
+ }
3694
+ }
3695
+ }
3696
+ async fetch(method, path, options) {
3697
+ const url = this.url(path, options.query);
3698
+ const controller = options.timeoutMs ? new AbortController() : undefined;
3699
+ let timeout;
3700
+ let abortListener;
3701
+ let cleanedUp = false;
3702
+ const cleanup = () => {
3703
+ if (cleanedUp)
3704
+ return;
3705
+ cleanedUp = true;
3706
+ if (timeout)
3707
+ clearTimeout(timeout);
3708
+ if (abortListener && options.signal) {
3709
+ options.signal.removeEventListener("abort", abortListener);
3710
+ }
3711
+ };
3712
+ if (controller && options.timeoutMs) {
3713
+ timeout = setTimeout(() => controller.abort(new Error("request timed out")), options.timeoutMs);
3714
+ }
3715
+ if (controller && options.signal) {
3716
+ if (options.signal.aborted) {
3717
+ controller.abort(options.signal.reason);
3718
+ }
3719
+ else {
3720
+ abortListener = () => controller.abort(options.signal?.reason);
3721
+ options.signal.addEventListener("abort", abortListener, { once: true });
3722
+ }
3723
+ }
3724
+ const headers = mergeHeaders(this.defaultHeaders, options.headers);
3725
+ const init = {
3726
+ method,
3727
+ headers,
3728
+ signal: controller?.signal ?? options.signal,
3729
+ redirect: "error",
3730
+ };
3731
+ if (isFormDataBody(options.body)) {
3732
+ headers.delete("content-type");
3733
+ init.body = options.body;
3734
+ }
3735
+ else if (options.body !== undefined && options.body !== null) {
3736
+ headers.set("content-type", "application/json");
3737
+ init.body = JSON.stringify(stripNullishFields(options.body, options.requestModel));
3738
+ }
3739
+ try {
3740
+ const response = await this.fetchImpl(url, init);
3741
+ if (response.status >= 400) {
3742
+ await throwApiError(response);
3743
+ }
3744
+ return { response, cleanup };
3745
+ }
3746
+ catch (error) {
3747
+ cleanup();
3748
+ if (error instanceof APIError)
3749
+ throw error;
3750
+ throw new NetworkError(error instanceof Error ? error.message : String(error), { cause: error });
3751
+ }
3752
+ }
3753
+ url(path, query) {
3754
+ const basePath = this.baseUrl.pathname.replace(/\/$/, "");
3755
+ const relativePath = path.startsWith("/") ? path : `/${path}`;
3756
+ const url = new URL(`${basePath}${relativePath}`, this.baseUrl);
3757
+ for (const [key, value] of Object.entries(query ?? {})) {
3758
+ if (value !== undefined && value !== null) {
3759
+ url.searchParams.append(key, value);
3760
+ }
3761
+ }
3762
+ return url.toString();
3763
+ }
3764
+ }
3765
+ function parseNdjsonLine(line, method, path) {
3766
+ try {
3767
+ return JSON.parse(line);
3768
+ }
3769
+ catch (error) {
3770
+ throw new ParseError(`Failed to parse NDJSON response from ${method} ${path}`, { cause: error });
3771
+ }
3772
+ }
3773
+ function parseRetryAfter(headers) {
3774
+ const raw = headers.get("retry-after");
3775
+ if (!raw)
3776
+ return undefined;
3777
+ const trimmed = raw.trim();
3778
+ if (/^\d+$/.test(trimmed)) {
3779
+ return Number(trimmed);
3780
+ }
3781
+ const timestamp = Date.parse(trimmed);
3782
+ return Number.isNaN(timestamp) ? undefined : new Date(timestamp);
3783
+ }
3784
+ async function throwApiError(response) {
3785
+ let body;
3786
+ try {
3787
+ body = await response.text();
3788
+ }
3789
+ catch {
3790
+ body = undefined;
3791
+ }
3792
+ const message = body ? `HTTP ${response.status}: ${body.slice(0, 500)}` : `HTTP ${response.status}`;
3793
+ if (response.status === 429) {
3794
+ throw new RateLimitError(message, response.status, body, response, parseRetryAfter(response.headers));
3795
+ }
3796
+ const ErrorClass = STATUS_ERRORS[response.status] ?? (response.status >= 500 ? InternalServerError : APIError);
3797
+ throw new ErrorClass(message, response.status, body, response);
3798
+ }
3799
+ export class AdminAPI {
3800
+ _http;
3801
+ constructor(_http) {
3802
+ this._http = _http;
3803
+ }
3804
+ /**
3805
+ * Deletes terminal background jobs older than a retention cutoff.
3806
+ */
3807
+ async backgroundJobsPurge(request, requestOptions) {
3808
+ validateModel("AdminPurgeJobsRequest", request);
3809
+ return this._http.requestJson("POST", `/v1/admin/background-jobs:purge`, { query: undefined, body: request, ...requestOptions, requestModel: "AdminPurgeJobsRequest" }, "AdminPurgeJobsResponse");
3810
+ }
3811
+ /**
3812
+ * Initiates drain mode and optionally waits for the server to quiesce.
3813
+ */
3814
+ async drain(request, requestOptions) {
3815
+ const body = request ?? {};
3816
+ validateModel("AdminDrainRequest", body);
3817
+ checkTimeoutBudget("admin.drain", body, requestOptions);
3818
+ return this._http.requestJson("POST", `/v1/admin:drain`, { query: undefined, body: body, ...requestOptions, requestModel: "AdminDrainRequest" }, "AdminDrainResponse");
3819
+ }
3820
+ /**
3821
+ * Triggers the server to reload its license file from the configured directory and returns metadata about the currently active license.
3822
+ */
3823
+ async licenseReload(requestOptions) {
3824
+ return this._http.requestJson("POST", `/v1/admin/license:reload`, { query: undefined, body: undefined, ...requestOptions }, "AdminReloadLicenseResponse");
3825
+ }
3826
+ /**
3827
+ * Creates an immutable administrative policy that can automatically enable durable RetrieveMemory request logging.
3828
+ */
3829
+ async retrieveMemoryLogPoliciesCreate(request, requestOptions) {
3830
+ validateModel("CreateRetrieveMemoryLogPolicyRequest", request);
3831
+ return this._http.requestJson("POST", `/v1/admin/retrieve-memory-log-policies`, { query: undefined, body: request, ...requestOptions, requestModel: "CreateRetrieveMemoryLogPolicyRequest" }, "RetrieveMemoryLogPolicy");
3832
+ }
3833
+ /**
3834
+ * Idempotently tombstones an immutable RetrieveMemory log policy.
3835
+ */
3836
+ async retrieveMemoryLogPoliciesDelete(id, requestOrRequestOptions, requestOptions) {
3837
+ assertPathParam("id", id, "string");
3838
+ const request = isRequestOptions(requestOrRequestOptions) ? undefined : requestOrRequestOptions;
3839
+ const effectiveRequestOptions = isRequestOptions(requestOrRequestOptions) ? requestOrRequestOptions : requestOptions;
3840
+ const body = request ?? {};
3841
+ validateModel("DeleteRetrieveMemoryLogPolicyRequest", body);
3842
+ return this._http.requestJson("DELETE", `/v1/admin/retrieve-memory-log-policies/${encodePath(id)}`, { query: undefined, body: body, ...effectiveRequestOptions, requestModel: "DeleteRetrieveMemoryLogPolicyRequest" }, "RetrieveMemoryLogPolicy");
3843
+ }
3844
+ /**
3845
+ * Retrieves a live RetrieveMemory log policy by UUID, or a tombstoned policy when includeDeleted is true.
3846
+ */
3847
+ async retrieveMemoryLogPoliciesGet(id, options, requestOptions) {
3848
+ assertPathParam("id", id, "string");
3849
+ const query = {};
3850
+ appendQuery(query, "includeDeleted", options?.includeDeleted);
3851
+ return this._http.requestJson("GET", `/v1/admin/retrieve-memory-log-policies/${encodePath(id)}`, { query: query, body: undefined, ...requestOptions }, "RetrieveMemoryLogPolicy");
3852
+ }
3853
+ /**
3854
+ * Lists RetrieveMemory log policies with optional tombstone, active-time, name, label, sort, and pagination filters. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
3855
+ */
3856
+ async retrieveMemoryLogPoliciesList(options, requestOptions) {
3857
+ const query = {};
3858
+ appendQuery(query, "includeDeleted", options?.includeDeleted);
3859
+ appendQuery(query, "nameFilter", options?.nameFilter);
3860
+ appendQuery(query, "activeAt", options?.activeAt);
3861
+ appendQuery(query, "maxResults", options?.maxResults);
3862
+ appendQuery(query, "nextToken", options?.nextToken);
3863
+ appendQuery(query, "sortBy", options?.sortBy);
3864
+ appendQuery(query, "sortOrder", options?.sortOrder);
3865
+ appendDeepObject(query, "label", options?.label);
3866
+ return this._http.paginate(`/v1/admin/retrieve-memory-log-policies`, query, "policies", requestOptions, "ListRetrieveMemoryLogPoliciesResponse");
3867
+ }
3868
+ }
3869
+ export class ApikeysAPI {
3870
+ _http;
3871
+ constructor(_http) {
3872
+ this._http = _http;
3873
+ }
3874
+ /**
3875
+ * Creates a new API key for authenticating with the API. New keys start in ACTIVE status and can be used immediately for authentication. The response includes the one-time raw API key value which will not be retrievable later - clients must save this value as it cannot be recovered. Requires CREATE_APIKEY_OWN permission (or CREATE_APIKEY_ANY for admin users). Side effects include generating cryptographically secure key material, recording creation timestamp, and tracking creator ID. Returns INVALID_ARGUMENT if expires_at is set to a time in the past.
3876
+ */
3877
+ async create(request, requestOptions) {
3878
+ validateModel("CreateApiKeyRequest", request);
3879
+ return this._http.requestJson("POST", `/v1/apikeys`, { query: undefined, body: request, ...requestOptions, requestModel: "CreateApiKeyRequest" }, "CreateApiKeyResponse");
3880
+ }
3881
+ /**
3882
+ * Permanently deletes an API key. This operation cannot be undone and immediately invalidates the key for all future authentication attempts. TIP: For reversible deactivation, use PUT /v1/apikeys/{id} with status=INACTIVE instead. Requires DELETE_APIKEY_OWN permission for keys you own (or DELETE_APIKEY_ANY for admin users to delete any user's keys). Side effects include permanently removing the key record from the database and immediate authentication invalidation.
3883
+ */
3884
+ async delete(id, requestOptions) {
3885
+ assertPathParam("id", id, "string");
3886
+ await this._http.requestJson("DELETE", `/v1/apikeys/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
3887
+ }
3888
+ /**
3889
+ * Retrieves a list of API keys belonging to the authenticated user. The list includes metadata about each key but not the actual key values or key hashes for security reasons. Requires LIST_APIKEY_OWN permission (or LIST_APIKEY_ANY for admin users to view keys from any user). This is a read-only operation with no side effects.
3890
+ */
3891
+ async list(requestOptions) {
3892
+ const response = await this._http.requestJson("GET", `/v1/apikeys`, { query: undefined, ...requestOptions }, "ListApiKeysResponse");
3893
+ return response.keys ?? [];
3894
+ }
3895
+ /**
3896
+ * Updates an existing API key with new values for status or labels. IMPORTANT: Key ID, user ownership, key material, and audit fields cannot be modified - only status (ACTIVE/INACTIVE) and labels are mutable. Requires UPDATE_APIKEY_OWN permission for keys you own (or UPDATE_APIKEY_ANY for admin users to modify any user's keys). Side effects include updating the updated_at timestamp and recording the updater's user ID. This operation is idempotent - repeated identical requests have no additional effect.
3897
+ */
3898
+ async update(id, request, requestOptions) {
3899
+ assertPathParam("id", id, "string");
3900
+ validateModel("UpdateApiKeyRequest", request);
3901
+ return this._http.requestJson("PUT", `/v1/apikeys/${encodePath(id)}`, { query: undefined, body: request, ...requestOptions, requestModel: "UpdateApiKeyRequest" }, "ApiKeyResponse");
3902
+ }
3903
+ }
3904
+ export class EmbeddersAPI {
3905
+ _http;
3906
+ constructor(_http) {
3907
+ this._http = _http;
3908
+ }
3909
+ async create(request, requestOptions) {
3910
+ const body = inferCreateRequest("embedders", request, requestOptions?.apiKey);
3911
+ const transportOptions = withoutProviderApiKey(requestOptions);
3912
+ validateModel("EmbedderCreationRequest", body);
3913
+ return this._http.requestJson("POST", `/v1/embedders`, { query: undefined, body, ...transportOptions, requestModel: "EmbedderCreationRequest" }, "EmbedderResponse");
3914
+ }
3915
+ /**
3916
+ * Permanently deletes an embedder configuration. This operation cannot be undone and removes the embedder record and securely deletes stored credentials. IMPORTANT: This does NOT invalidate or delete embeddings previously created with this embedder - existing embeddings remain accessible. CONFLICT: Returns HTTP 409 Conflict if the embedder is still referenced by a space. Requires DELETE_EMBEDDER_OWN permission for embedders you own (or DELETE_EMBEDDER_ANY for admin users).
3917
+ */
3918
+ async delete(id, requestOptions) {
3919
+ assertPathParam("id", id, "string");
3920
+ await this._http.requestJson("DELETE", `/v1/embedders/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
3921
+ }
3922
+ /**
3923
+ * Retrieves the details of a specific embedder configuration by its unique identifier. Requires READ_EMBEDDER_OWN permission for embedders you own (or READ_EMBEDDER_ANY for admin users to view any user's embedders). This is a read-only operation with no side effects.
3924
+ */
3925
+ async get(id, requestOptions) {
3926
+ assertPathParam("id", id, "string");
3927
+ return this._http.requestJson("GET", `/v1/embedders/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, "EmbedderResponse");
3928
+ }
3929
+ /**
3930
+ * Retrieves a list of embedder configurations accessible to the caller, with optional filtering. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_EMBEDDER_OWN permission, you can only see your own embedders (ownerId filter is ignored if set to another user). With LIST_EMBEDDER_ANY permission, you can see all embedders or filter by any ownerId. This is a read-only operation with no side effects.
3931
+ */
3932
+ async list(options, requestOptions) {
3933
+ const query = {};
3934
+ appendQuery(query, "ownerId", options?.ownerId);
3935
+ appendQuery(query, "providerType", options?.providerType);
3936
+ appendDeepObject(query, "label", options?.label);
3937
+ const response = await this._http.requestJson("GET", `/v1/embedders`, { query: query, ...requestOptions }, "ListEmbeddersResponse");
3938
+ return response.embedders ?? [];
3939
+ }
3940
+ /**
3941
+ * Updates an existing embedder configuration including display information, endpoint configuration, model parameters, credentials, and labels. All fields are optional - only specified fields will be updated. IMPORTANT: providerType is IMMUTABLE after creation and cannot be changed. CRITICAL: Returns HTTP 412 Precondition Failed (FAILED_PRECONDITION) if attempting to update core fields (dimensionality, distributionType, modelIdentifier) while the embedder is actively referenced by spaces or ingestion jobs. DUPLICATE DETECTION: Returns HTTP 409 Conflict (ALREADY_EXISTS) if the update would create a duplicate embedder with the same provider, endpoint, model, dimensionality, distribution, and credentials for this owner. Requires UPDATE_EMBEDDER_OWN permission for embedders you own (or UPDATE_EMBEDDER_ANY for admin users).
3942
+ */
3943
+ async update(id, request, requestOptions) {
3944
+ assertPathParam("id", id, "string");
3945
+ validateModel("UpdateEmbedderRequest", request);
3946
+ return this._http.requestJson("PUT", `/v1/embedders/${encodePath(id)}`, { query: undefined, body: request, ...requestOptions, requestModel: "UpdateEmbedderRequest" }, "EmbedderResponse");
3947
+ }
3948
+ }
3949
+ export class LlmsAPI {
3950
+ _http;
3951
+ constructor(_http) {
3952
+ this._http = _http;
3953
+ }
3954
+ async create(request, requestOptions) {
3955
+ const body = inferCreateRequest("llms", request, requestOptions?.apiKey);
3956
+ const transportOptions = withoutProviderApiKey(requestOptions);
3957
+ validateModel("LLMCreationRequest", body);
3958
+ return this._http.requestJson("POST", `/v1/llms`, { query: undefined, body, ...transportOptions, requestModel: "LLMCreationRequest" }, "CreateLLMResponse");
3959
+ }
3960
+ /**
3961
+ * Permanently deletes an LLM configuration. This operation cannot be undone and removes the LLM record and securely deletes stored credentials. IMPORTANT: This does NOT invalidate or delete any previously generated content using this LLM - existing generations remain accessible. Requires DELETE_LLM_OWN permission for LLMs you own (or DELETE_LLM_ANY for admin users).
3962
+ */
3963
+ async delete(id, requestOptions) {
3964
+ assertPathParam("id", id, "string");
3965
+ await this._http.requestJson("DELETE", `/v1/llms/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
3966
+ }
3967
+ /**
3968
+ * Retrieves the details of a specific LLM configuration by its unique identifier. Requires READ_LLM_OWN permission for LLMs you own (or READ_LLM_ANY for admin users to view any user's LLMs). This is a read-only operation with no side effects.
3969
+ */
3970
+ async get(id, requestOptions) {
3971
+ assertPathParam("id", id, "string");
3972
+ return this._http.requestJson("GET", `/v1/llms/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, "LLMResponse");
3973
+ }
3974
+ /**
3975
+ * Retrieves a list of LLM configurations accessible to the caller, with optional filtering. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_LLM_OWN permission, you can only see your own LLMs (ownerId filter is ignored if set to another user). With LIST_LLM_ANY permission, you can see all LLMs or filter by any ownerId. This is a read-only operation with no side effects.
3976
+ */
3977
+ async list(options, requestOptions) {
3978
+ const query = {};
3979
+ appendQuery(query, "ownerId", options?.ownerId);
3980
+ appendQuery(query, "providerType", options?.providerType);
3981
+ appendDeepObject(query, "label", options?.label);
3982
+ const response = await this._http.requestJson("GET", `/v1/llms`, { query: query, ...requestOptions }, "ListLLMsResponse");
3983
+ return response.llms ?? [];
3984
+ }
3985
+ /**
3986
+ * Updates an existing LLM configuration including display information, endpoint configuration, model parameters, credentials, and labels. All fields are optional - only specified fields will be updated. SUPPORTED_MODALITIES UPDATE: If the array contains >=1 elements, it replaces the stored set; if empty or omitted, no change occurs and it does not count as an update by itself. IMPORTANT: providerType is IMMUTABLE after creation and cannot be changed. Requires UPDATE_LLM_OWN permission for LLMs you own (or UPDATE_LLM_ANY for admin users).
3987
+ */
3988
+ async update(id, request, requestOptions) {
3989
+ assertPathParam("id", id, "string");
3990
+ validateModel("LLMUpdateRequest", request);
3991
+ return this._http.requestJson("PUT", `/v1/llms/${encodePath(id)}`, { query: undefined, body: request, ...requestOptions, requestModel: "LLMUpdateRequest" }, "LLMResponse");
3992
+ }
3993
+ }
3994
+ export class MemoriesAPI {
3995
+ _http;
3996
+ constructor(_http) {
3997
+ this._http = _http;
3998
+ }
3999
+ /**
4000
+ * Creates multiple memories in a single operation, with individual success/failure results.
4001
+ */
4002
+ async batchCreate(request, requestOptions) {
4003
+ const body = normalizeMemoryBatchCreateRequest(request);
4004
+ validateModel("JsonBatchMemoryCreationRequest", body);
4005
+ return this._http.requestJson("POST", `/v1/memories:batchCreate`, { query: undefined, body, ...requestOptions, requestModel: "JsonBatchMemoryCreationRequest" }, "BatchMemoryResponse");
4006
+ }
4007
+ /**
4008
+ * Deletes memories using selector entries. Each selector can target either a specific memory ID or a filtered subset scoped to a specific space.
4009
+ */
4010
+ async batchDelete(request, requestOptions) {
4011
+ validateModel("BatchMemoryDeletionRequest", request);
4012
+ return this._http.requestJson("POST", `/v1/memories:batchDelete`, { query: undefined, body: request, ...requestOptions, requestModel: "BatchMemoryDeletionRequest" }, "BatchMemoryResponse");
4013
+ }
4014
+ /**
4015
+ * Retrieves multiple memories in a single operation, with individual success/failure results.
4016
+ */
4017
+ async batchGet(request, requestOptions) {
4018
+ validateModel("BatchMemoryRetrievalRequest", request);
4019
+ return this._http.requestJson("POST", `/v1/memories:batchGet`, { query: undefined, body: request, ...requestOptions, requestModel: "BatchMemoryRetrievalRequest" }, "BatchMemoryResponse");
4020
+ }
4021
+ /**
4022
+ * Returns the original binary payload for a memory. The response uses the memory's stored content type when available. Returns 404 when the memory does not have inline content; clients can check originalContentRef from the metadata endpoint to locate external content.
4023
+ */
4024
+ async content(id, requestOptions) {
4025
+ assertPathParam("id", id, "string");
4026
+ return this._http.requestBytes("GET", `/v1/memories/${encodePath(id)}/content`, { query: undefined, ...requestOptions });
4027
+ }
4028
+ /**
4029
+ * Creates a new memory in a specified space and starts asynchronous processing. The memory begins in PENDING status while a background job performs chunking and embedding generation. IDEMPOTENCY: If memoryId is omitted, the server generates a new UUID and retries are not idempotent. If the client supplies a stable memoryId, the operation behaves as create-if-absent: the first request creates the memory and subsequent retries return HTTP 409 Conflict (ALREADY_EXISTS) rather than creating duplicates. Returns INVALID_ARGUMENT if space_id, original_content, or content_type is missing or invalid. Returns NOT_FOUND if the specified space does not exist. Requires CREATE_MEMORY_OWN permission for spaces you own (or CREATE_MEMORY_ANY for admin users to create in any space). Side effects include creating the memory record and enqueuing a background processing job.
4030
+ */
4031
+ async create(request, requestOptions) {
4032
+ const body = normalizeMemoryCreateRequest(request, "memories.create");
4033
+ validateModel("JsonMemoryCreationRequest", body);
4034
+ return this._http.requestJson("POST", `/v1/memories`, { query: undefined, body, ...requestOptions, requestModel: "JsonMemoryCreationRequest" }, "Memory");
4035
+ }
4036
+ /**
4037
+ * Permanently deletes a memory and its associated chunks. This operation cannot be undone and immediately removes the memory record from the database. IDEMPOTENCY: This operation is safe to retry - may return NOT_FOUND if the memory was already deleted or never existed. Requires DELETE_MEMORY_OWN permission for memories in spaces you own (or DELETE_MEMORY_ANY for admin users to delete any memory). Side effects include permanent removal of the memory record and all associated chunk data.
4038
+ */
4039
+ async delete(id, requestOptions) {
4040
+ assertPathParam("id", id, "string");
4041
+ await this._http.requestJson("DELETE", `/v1/memories/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
4042
+ }
4043
+ /**
4044
+ * Retrieves a single memory by its ID. PERMISSION CLARIFICATION: With READ_MEMORY_OWN permission, access is granted if you own the parent space OR if the parent space is public (public_read=true). With READ_MEMORY_ANY permission, you can access any memory regardless of ownership. This is a read-only operation with no side effects and is safe to retry. Returns NOT_FOUND if the memory or its parent space does not exist.
4045
+ */
4046
+ async get(id, options, requestOptions) {
4047
+ assertPathParam("id", id, "string");
4048
+ const query = {};
4049
+ appendQuery(query, "includeContent", options?.includeContent);
4050
+ appendQuery(query, "includeProcessingHistory", options?.includeProcessingHistory);
4051
+ return this._http.requestJson("GET", `/v1/memories/${encodePath(id)}`, { query: query, body: undefined, ...requestOptions }, "Memory");
4052
+ }
4053
+ /**
4054
+ * Lists all memories within a given space. Pagination is supported via maxResults and nextToken (opaque). nextToken is a URL-safe Base64 string without padding; do not parse or construct it. This is a read-only operation with no side effects and is safe to retry. Requires LIST_MEMORY_OWN or LIST_MEMORY_ANY permission. Returns NOT_FOUND if the specified space does not exist.
4055
+ */
4056
+ async list(spaceId, options, requestOptions) {
4057
+ assertPathParam("spaceId", spaceId, "string");
4058
+ const query = {};
4059
+ appendQuery(query, "includeContent", options?.includeContent);
4060
+ appendQuery(query, "includeProcessingHistory", options?.includeProcessingHistory);
4061
+ appendQuery(query, "statusFilter", options?.statusFilter);
4062
+ appendQuery(query, "filter", options?.filter);
4063
+ appendQuery(query, "maxResults", options?.maxResults);
4064
+ appendQuery(query, "nextToken", options?.nextToken);
4065
+ appendQuery(query, "sortBy", options?.sortBy);
4066
+ appendQuery(query, "sortOrder", options?.sortOrder);
4067
+ return this._http.paginate(`/v1/spaces/${encodePath(spaceId)}/memories`, query, "memories", requestOptions, "MemoryListResponse");
4068
+ }
4069
+ /**
4070
+ * Lists extracted page-image metadata for a memory with optional filters and pagination.
4071
+ */
4072
+ async pages(id, options, requestOptions) {
4073
+ assertPathParam("id", id, "string");
4074
+ const query = {};
4075
+ appendQuery(query, "startPageIndex", options?.startPageIndex);
4076
+ appendQuery(query, "endPageIndex", options?.endPageIndex);
4077
+ appendQuery(query, "dpi", options?.dpi);
4078
+ appendQuery(query, "contentType", options?.contentType);
4079
+ appendQuery(query, "maxResults", options?.maxResults);
4080
+ appendQuery(query, "nextToken", options?.nextToken);
4081
+ return this._http.paginate(`/v1/memories/${encodePath(id)}/pages`, query, "pageImages", requestOptions, "ListMemoryPageImagesResponse");
4082
+ }
4083
+ /**
4084
+ * Downloads inline bytes for one page image. The page index is required. The optional dpi and content type query parameters act as rendition filters; if omitted, the server returns the unique rendition for that page or rejects ambiguous matches.
4085
+ */
4086
+ async pagesImage(id, pageIndex, options, requestOptions) {
4087
+ assertPathParam("id", id, "string");
4088
+ assertPathParam("pageIndex", pageIndex, "number");
4089
+ const query = {};
4090
+ appendQuery(query, "dpi", options?.dpi);
4091
+ appendQuery(query, "contentType", options?.contentType);
4092
+ return this._http.requestBytes("GET", `/v1/memories/${encodePath(id)}/pages/${encodePath(pageIndex)}/image`, { query: query, ...requestOptions });
4093
+ }
4094
+ retrieve(requestOrMessage, optionsOrRequestOptions, requestOptions) {
4095
+ const request = typeof requestOrMessage === "string"
4096
+ ? buildRetrieveRequest(requestOrMessage, optionsOrRequestOptions)
4097
+ : requestOrMessage;
4098
+ const effectiveRequestOptions = typeof requestOrMessage === "string"
4099
+ ? requestOptions
4100
+ : optionsOrRequestOptions;
4101
+ const { accept: _accept, ...body } = request;
4102
+ validateModel("RetrieveMemoryRequest", body);
4103
+ return this._http.streamNdjson("POST", `/v1/memories:retrieve`, body, { ...effectiveRequestOptions, requestModel: "RetrieveMemoryRequest" }, "RetrieveMemoryEvent");
4104
+ }
4105
+ async createFromBytes(request, requestOptions) {
4106
+ const { bytes, filename, ...metadata } = request;
4107
+ const contentType = requireBytesContentType(metadata.contentType);
4108
+ const file = bytesToBlob(bytes, contentType);
4109
+ return this.createFromFile({ ...metadata, contentType, file, filename: filename ?? "memory.bin" }, requestOptions);
4110
+ }
4111
+ async createFromPath(request, requestOptions) {
4112
+ const { path, contentType, filename, ...metadata } = request;
4113
+ const uploadPath = requireUploadPath(path, "memories.createFromPath");
4114
+ const normalizedContentType = inferPathContentType(uploadPath, contentType);
4115
+ const file = await pathToBlob(uploadPath, normalizedContentType, "memories.createFromPath");
4116
+ return this.createFromFile({ ...metadata, file, contentType: normalizedContentType, filename: filename ?? uploadFilenameFromPath(uploadPath) }, requestOptions);
4117
+ }
4118
+ async createFromFile(request, requestOptions) {
4119
+ const formData = memoryCreateUploadFormData(request, "request", "file");
4120
+ return this._http.requestJson("POST", `/v1/memories`, { query: undefined, body: formData, ...requestOptions }, "Memory");
4121
+ }
4122
+ async batchCreateFromPaths(request, requestOptions) {
4123
+ if (request.requests.length === 0) {
4124
+ throw new TypeError("memories.batchCreateFromPaths requires at least one request.");
4125
+ }
4126
+ const fileRequests = await Promise.all(request.requests.map(async (item) => {
4127
+ const { path, contentType, filename, ...metadata } = item;
4128
+ const uploadPath = requireUploadPath(path, "memories.batchCreateFromPaths");
4129
+ const normalizedContentType = inferPathContentType(uploadPath, contentType);
4130
+ const file = await pathToBlob(uploadPath, normalizedContentType, "memories.batchCreateFromPaths");
4131
+ return { ...metadata, file, contentType: normalizedContentType, filename: filename ?? uploadFilenameFromPath(uploadPath) };
4132
+ }));
4133
+ return this.batchCreateFromFiles({ requests: fileRequests }, requestOptions);
4134
+ }
4135
+ async batchCreateFromFiles(request, requestOptions) {
4136
+ const formData = memoryBatchCreateUploadFormData(request.requests, "requests", "file");
4137
+ return this._http.requestJson("POST", `/v1/memories:batchCreate`, { query: undefined, body: formData, ...requestOptions }, "BatchMemoryResponse");
4138
+ }
4139
+ }
4140
+ export class OcrAPI {
4141
+ _http;
4142
+ constructor(_http) {
4143
+ this._http = _http;
4144
+ }
4145
+ /**
4146
+ * Runs layout-aware OCR on the provided document bytes and returns per-page results. When a page range is provided, only the inclusive subset is processed. Requires OCR_DOCUMENT permission.
4147
+ */
4148
+ async document(request, requestOptions) {
4149
+ validateModel("OcrDocumentRequest", request);
4150
+ return this._http.requestJson("POST", `/v1/ocr:document`, { query: undefined, body: request, ...requestOptions, requestModel: "OcrDocumentRequest" }, "OcrDocumentResponse");
4151
+ }
4152
+ async documentFromBytes(request, requestOptions) {
4153
+ const { bytes, ...metadata } = request;
4154
+ return this.document({ ...metadata, content: bytesToBase64(bytes) }, requestOptions);
4155
+ }
4156
+ async documentFromFile(request, requestOptions) {
4157
+ const { file, ...metadata } = request;
4158
+ const content = await blobToBase64(file, "ocr.documentFromFile");
4159
+ return this.document({ ...metadata, content }, requestOptions);
4160
+ }
4161
+ async documentFromPath(request, requestOptions) {
4162
+ const { path, ...metadata } = request;
4163
+ const content = await ocrPathToBase64(path);
4164
+ return this.document({ ...metadata, content }, requestOptions);
4165
+ }
4166
+ }
4167
+ export class PingAPI {
4168
+ _http;
4169
+ constructor(_http) {
4170
+ this._http = _http;
4171
+ }
4172
+ /**
4173
+ * Runs a single ping probe and returns the probe result.
4174
+ */
4175
+ async once(request, requestOptions) {
4176
+ validateModel("PingOnceRequest", request);
4177
+ checkTimeoutBudget("ping.once", request, requestOptions);
4178
+ return this._http.requestJson("POST", `/v1/ping:once`, { query: undefined, body: request, ...requestOptions, requestModel: "PingOnceRequest" }, "PingResult");
4179
+ }
4180
+ /**
4181
+ * Opens a streaming ping session and returns per-probe results plus a terminal summary.
4182
+ */
4183
+ stream(request, requestOptions) {
4184
+ const { accept: _accept, ...body } = request;
4185
+ validateModel("PingStreamRequest", body);
4186
+ checkTimeoutBudget("ping.stream", body, requestOptions);
4187
+ return this._http.streamNdjson("POST", `/v1/ping:stream`, body, { ...requestOptions, requestModel: "PingStreamRequest" }, "PingEvent");
4188
+ }
4189
+ }
4190
+ export class RerankersAPI {
4191
+ _http;
4192
+ constructor(_http) {
4193
+ this._http = _http;
4194
+ }
4195
+ async create(request, requestOptions) {
4196
+ const body = inferCreateRequest("rerankers", request, requestOptions?.apiKey);
4197
+ const transportOptions = withoutProviderApiKey(requestOptions);
4198
+ validateModel("RerankerCreationRequest", body);
4199
+ return this._http.requestJson("POST", `/v1/rerankers`, { query: undefined, body, ...transportOptions, requestModel: "RerankerCreationRequest" }, "RerankerResponse");
4200
+ }
4201
+ /**
4202
+ * Permanently deletes a reranker configuration. This operation cannot be undone and immediately removes the reranker record from the database. SIDE EFFECTS: Invalidates any cached references to this reranker; does not affect historical usage data or audit logs. Requires DELETE_RERANKER_OWN permission for rerankers you own (or DELETE_RERANKER_ANY for admin users). This operation is safe to retry - may return NOT_FOUND if already deleted.
4203
+ */
4204
+ async delete(id, requestOptions) {
4205
+ assertPathParam("id", id, "string");
4206
+ await this._http.requestJson("DELETE", `/v1/rerankers/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
4207
+ }
4208
+ /**
4209
+ * Retrieves the details of a specific reranker configuration by its unique identifier. Response payloads include stored credentials, matching gRPC response semantics. Requires READ_RERANKER_OWN permission for rerankers you own (or READ_RERANKER_ANY for admin users). This is a read-only operation with no side effects and is safe to retry.
4210
+ */
4211
+ async get(id, requestOptions) {
4212
+ assertPathParam("id", id, "string");
4213
+ return this._http.requestJson("GET", `/v1/rerankers/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, "RerankerResponse");
4214
+ }
4215
+ /**
4216
+ * Retrieves a list of reranker configurations accessible to the caller, with optional filtering. IMPORTANT: Pagination is NOT supported - all matching results are returned. Results are ordered by created_at descending. Responses include stored credentials, matching gRPC response semantics. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_RERANKER_OWN permission, only your own rerankers are shown. With LIST_RERANKER_ANY permission, you can see all rerankers or filter by any ownerId. Specifying ownerId without LIST_RERANKER_ANY permission returns PERMISSION_DENIED.
4217
+ */
4218
+ async list(options, requestOptions) {
4219
+ const query = {};
4220
+ appendQuery(query, "ownerId", options?.ownerId);
4221
+ appendQuery(query, "providerType", options?.providerType);
4222
+ appendDeepObject(query, "label", options?.label);
4223
+ const response = await this._http.requestJson("GET", `/v1/rerankers`, { query: query, ...requestOptions }, "ListRerankersResponse");
4224
+ return response.rerankers ?? [];
4225
+ }
4226
+ /**
4227
+ * Updates an existing reranker configuration including display information, endpoint configuration, model parameters, credentials, and labels. All fields are optional - only specified fields will be updated. IMMUTABLE FIELDS: providerType and ownerId cannot be changed after creation. SUPPORTED_MODALITIES UPDATE: If the array contains >=1 elements, it replaces the stored set; if empty or omitted, no change occurs and it does not count as an update by itself. Returns ALREADY_EXISTS if update would create duplicate with same {ownerId, providerType, endpointUrl, apiPath, modelIdentifier, credentialsFingerprint} after URL canonicalization (HTTP 409 Conflict / ALREADY_EXISTS). Requires UPDATE_RERANKER_OWN permission for rerankers you own (or UPDATE_RERANKER_ANY for admin users). This operation is idempotent.
4228
+ */
4229
+ async update(id, request, requestOptions) {
4230
+ assertPathParam("id", id, "string");
4231
+ validateModel("UpdateRerankerRequest", request);
4232
+ return this._http.requestJson("PUT", `/v1/rerankers/${encodePath(id)}`, { query: undefined, body: request, ...requestOptions, requestModel: "UpdateRerankerRequest" }, "RerankerResponse");
4233
+ }
4234
+ }
4235
+ export class SpacesAPI {
4236
+ _http;
4237
+ constructor(_http) {
4238
+ this._http = _http;
4239
+ }
4240
+ /**
4241
+ * Creates a new space with the provided name, labels, and embedder configuration. A space is a container for organizing related memories. OWNER DEFAULTS: Owner defaults to authenticated user unless ownerId is provided (requires CREATE_SPACE_ANY if differs). EMBEDDER REQUIREMENTS: At least one embedder configuration must be specified. DUPLICATE DETECTION: Returns ALREADY_EXISTS if another space exists with identical {ownerId, name} (case-sensitive). Requires CREATE_SPACE_OWN permission (or CREATE_SPACE_ANY for admin users). This operation is NOT idempotent.
4242
+ */
4243
+ async create(request, requestOptions) {
4244
+ const body = withDefaultSpaceChunkingConfig(request);
4245
+ validateModel("SpaceCreationRequest", body);
4246
+ return this._http.requestJson("POST", `/v1/spaces`, { query: undefined, body, ...requestOptions, requestModel: "SpaceCreationRequest" }, "Space");
4247
+ }
4248
+ /**
4249
+ * Permanently deletes a space and all associated content. This operation cannot be undone. CASCADE DELETION: Removes the space record and cascades deletion to associated memories, chunks, and embedder associations. Requires DELETE_SPACE_OWN permission for spaces you own (or DELETE_SPACE_ANY for admin users). This operation is safe to retry - may return NOT_FOUND if already deleted.
4250
+ */
4251
+ async delete(id, requestOptions) {
4252
+ assertPathParam("id", id, "string");
4253
+ await this._http.requestJson("DELETE", `/v1/spaces/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, undefined);
4254
+ }
4255
+ /**
4256
+ * Retrieves a specific space by its unique identifier. Returns the complete space information, including name, labels, embedder configuration, and metadata. PUBLIC SPACE ACCESS: When public_read=true, any authenticated user can retrieve the space metadata, bypassing ownership checks. Otherwise, requires ownership or DISPLAY_SPACE_ANY permission. Requires DISPLAY_SPACE_OWN permission for owned spaces (or DISPLAY_SPACE_ANY for admin users to view any space). This is a read-only operation safe to retry.
4257
+ */
4258
+ async get(id, requestOptions) {
4259
+ assertPathParam("id", id, "string");
4260
+ return this._http.requestJson("GET", `/v1/spaces/${encodePath(id)}`, { query: undefined, body: undefined, ...requestOptions }, "Space");
4261
+ }
4262
+ /**
4263
+ * Retrieves a list of spaces accessible to the caller, with optional filtering by owner, labels, and name. Results are paginated with a maximum number of spaces per response. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_SPACE_ANY and ownerId omitted, returns all visible spaces; otherwise returns caller-owned spaces only. DEFAULT SORT: Results ordered by created_at DESCENDING unless specified otherwise. MAX_RESULTS CLAMPING: maxResults defaults to 50 and is clamped to [1, 1000] range. Requires LIST_SPACE_OWN or LIST_SPACE_ANY permission.
4264
+ */
4265
+ async list(options, requestOptions) {
4266
+ const query = {};
4267
+ appendQuery(query, "ownerId", options?.ownerId);
4268
+ appendQuery(query, "nameFilter", options?.nameFilter);
4269
+ appendQuery(query, "maxResults", options?.maxResults);
4270
+ appendQuery(query, "nextToken", options?.nextToken);
4271
+ appendQuery(query, "sortBy", options?.sortBy);
4272
+ appendQuery(query, "sortOrder", options?.sortOrder);
4273
+ appendDeepObject(query, "label", options?.label);
4274
+ return this._http.paginate(`/v1/spaces`, query, "spaces", requestOptions, "ListSpacesResponse");
4275
+ }
4276
+ /**
4277
+ * Updates an existing space with new values for the specified fields. Only name, publicRead, and labels can be updated. Fields not included in the request remain unchanged. IMMUTABLE FIELDS: space_embedders, default_chunking_config, and ownerId cannot be modified after creation. NAME UNIQUENESS: Name must be unique per owner - returns ALREADY_EXISTS if name conflicts with existing space. Requires UPDATE_SPACE_OWN permission for spaces you own (or UPDATE_SPACE_ANY for admin users). This operation is idempotent.
4278
+ */
4279
+ async update(id, request, requestOptions) {
4280
+ assertPathParam("id", id, "string");
4281
+ validateModel("UpdateSpaceRequest", request);
4282
+ return this._http.requestJson("PUT", `/v1/spaces/${encodePath(id)}`, { query: undefined, body: request, ...requestOptions, requestModel: "UpdateSpaceRequest" }, "Space");
4283
+ }
4284
+ }
4285
+ export class SystemAPI {
4286
+ _http;
4287
+ constructor(_http) {
4288
+ this._http = _http;
4289
+ }
4290
+ /**
4291
+ * Returns the server's advertised semantic version, git metadata, build timestamp, and optional capability flags. The endpoint is intentionally unauthenticated so bootstrap tooling can call it before API keys exist.
4292
+ */
4293
+ async info(requestOptions) {
4294
+ return this._http.requestJson("GET", `/v1/system/info`, { query: undefined, body: undefined, ...requestOptions }, "SystemInfoResponse");
4295
+ }
4296
+ /**
4297
+ * Initializes the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, the endpoint will return a success response without creating new credentials.
4298
+ */
4299
+ async init(requestOptions) {
4300
+ return this._http.requestJson("POST", `/v1/system/init`, { query: undefined, body: undefined, ...requestOptions }, "SystemInitResponse");
4301
+ }
4302
+ }
4303
+ export class UsersAPI {
4304
+ _http;
4305
+ constructor(_http) {
4306
+ this._http = _http;
4307
+ }
4308
+ /**
4309
+ * Retrieves a specific user by their UUID. This endpoint only accepts user IDs - for email-based lookup, use GET /v1/users/email/{email}. For getting your own profile, use GET /v1/users/me.
4310
+ */
4311
+ get(options, requestOptions) {
4312
+ const hasId = typeof options.id === "string" && options.id.length > 0;
4313
+ const hasEmail = typeof options.email === "string" && options.email.length > 0;
4314
+ if (hasId === hasEmail) {
4315
+ throw new TypeError("users.get requires exactly one non-empty id or email");
4316
+ }
4317
+ const path = hasEmail
4318
+ ? `/v1/users/email/${encodePath(options.email)}`
4319
+ : `/v1/users/${encodePath(options.id)}`;
4320
+ return this._http.requestJson("GET", path, { ...requestOptions }, "UserResponse");
4321
+ }
4322
+ /**
4323
+ * Retrieves the authenticated user's profile information including email, display name, and creation time. This endpoint does not require any parameters as it automatically returns the caller's information.
4324
+ */
4325
+ async me(requestOptions) {
4326
+ return this._http.requestJson("GET", `/v1/users/me`, { query: undefined, body: undefined, ...requestOptions }, "UserResponse");
4327
+ }
4328
+ }
4329
+ export class Goodmem {
4330
+ admin;
4331
+ apikeys;
4332
+ embedders;
4333
+ llms;
4334
+ memories;
4335
+ ocr;
4336
+ ping;
4337
+ rerankers;
4338
+ spaces;
4339
+ system;
4340
+ users;
4341
+ constructor(config) {
4342
+ const http = new HttpTransport(config);
4343
+ this.admin = new AdminAPI(http);
4344
+ this.apikeys = new ApikeysAPI(http);
4345
+ this.embedders = new EmbeddersAPI(http);
4346
+ this.llms = new LlmsAPI(http);
4347
+ this.memories = new MemoriesAPI(http);
4348
+ this.ocr = new OcrAPI(http);
4349
+ this.ping = new PingAPI(http);
4350
+ this.rerankers = new RerankersAPI(http);
4351
+ this.spaces = new SpacesAPI(http);
4352
+ this.system = new SystemAPI(http);
4353
+ this.users = new UsersAPI(http);
4354
+ }
4355
+ }
4356
+ export { Goodmem as Client };
4357
+ export default Goodmem;
4358
+ //# sourceMappingURL=index.js.map