@vectorize-io/hindsight-client 0.4.22 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +390 -7
- package/dist/index.d.ts +390 -7
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -1
- package/generated/sdk.gen.ts +50 -0
- package/generated/types.gen.ts +378 -5
- package/package.json +1 -1
- package/src/index.ts +53 -0
package/generated/sdk.gen.ts
CHANGED
|
@@ -53,6 +53,9 @@ import type {
|
|
|
53
53
|
DeleteWebhookData,
|
|
54
54
|
DeleteWebhookErrors,
|
|
55
55
|
DeleteWebhookResponses,
|
|
56
|
+
ExportBankTemplateData,
|
|
57
|
+
ExportBankTemplateErrors,
|
|
58
|
+
ExportBankTemplateResponses,
|
|
56
59
|
FileRetainData,
|
|
57
60
|
FileRetainErrors,
|
|
58
61
|
FileRetainResponses,
|
|
@@ -65,6 +68,8 @@ import type {
|
|
|
65
68
|
GetBankProfileData,
|
|
66
69
|
GetBankProfileErrors,
|
|
67
70
|
GetBankProfileResponses,
|
|
71
|
+
GetBankTemplateSchemaData,
|
|
72
|
+
GetBankTemplateSchemaResponses,
|
|
68
73
|
GetChunkData,
|
|
69
74
|
GetChunkErrors,
|
|
70
75
|
GetChunkResponses,
|
|
@@ -99,6 +104,9 @@ import type {
|
|
|
99
104
|
GetVersionResponses,
|
|
100
105
|
HealthEndpointHealthGetData,
|
|
101
106
|
HealthEndpointHealthGetResponses,
|
|
107
|
+
ImportBankTemplateData,
|
|
108
|
+
ImportBankTemplateErrors,
|
|
109
|
+
ImportBankTemplateResponses,
|
|
102
110
|
ListAuditLogsData,
|
|
103
111
|
ListAuditLogsErrors,
|
|
104
112
|
ListAuditLogsResponses,
|
|
@@ -930,6 +938,48 @@ export const createOrUpdateBank = <ThrowOnError extends boolean = false>(
|
|
|
930
938
|
},
|
|
931
939
|
});
|
|
932
940
|
|
|
941
|
+
/**
|
|
942
|
+
* Import bank template
|
|
943
|
+
*
|
|
944
|
+
* Import a bank template manifest to create or update a bank's configuration, mental models, and directives. If the bank does not exist it is created. Config fields are applied as per-bank overrides. Mental models are matched by id, directives by name — existing ones are updated, new ones are created. Use dry_run=true to validate the manifest without applying changes.
|
|
945
|
+
*/
|
|
946
|
+
export const importBankTemplate = <ThrowOnError extends boolean = false>(
|
|
947
|
+
options: Options<ImportBankTemplateData, ThrowOnError>,
|
|
948
|
+
) =>
|
|
949
|
+
(options.client ?? client).post<
|
|
950
|
+
ImportBankTemplateResponses,
|
|
951
|
+
ImportBankTemplateErrors,
|
|
952
|
+
ThrowOnError
|
|
953
|
+
>({ url: "/v1/default/banks/{bank_id}/import", ...options });
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Export bank template
|
|
957
|
+
*
|
|
958
|
+
* Export a bank's current configuration, mental models, and directives as a template manifest. The exported manifest can be imported into another bank to replicate the setup.
|
|
959
|
+
*/
|
|
960
|
+
export const exportBankTemplate = <ThrowOnError extends boolean = false>(
|
|
961
|
+
options: Options<ExportBankTemplateData, ThrowOnError>,
|
|
962
|
+
) =>
|
|
963
|
+
(options.client ?? client).get<
|
|
964
|
+
ExportBankTemplateResponses,
|
|
965
|
+
ExportBankTemplateErrors,
|
|
966
|
+
ThrowOnError
|
|
967
|
+
>({ url: "/v1/default/banks/{bank_id}/export", ...options });
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Get bank template JSON Schema
|
|
971
|
+
*
|
|
972
|
+
* Returns the JSON Schema for the bank template manifest format. Use this to validate template manifests before importing.
|
|
973
|
+
*/
|
|
974
|
+
export const getBankTemplateSchema = <ThrowOnError extends boolean = false>(
|
|
975
|
+
options?: Options<GetBankTemplateSchemaData, ThrowOnError>,
|
|
976
|
+
) =>
|
|
977
|
+
(options?.client ?? client).get<
|
|
978
|
+
GetBankTemplateSchemaResponses,
|
|
979
|
+
unknown,
|
|
980
|
+
ThrowOnError
|
|
981
|
+
>({ url: "/v1/bank-template-schema", ...options });
|
|
982
|
+
|
|
933
983
|
/**
|
|
934
984
|
* Clear all observations
|
|
935
985
|
*
|
package/generated/types.gen.ts
CHANGED
|
@@ -385,6 +385,263 @@ export type BankStatsResponse = {
|
|
|
385
385
|
total_observations?: number;
|
|
386
386
|
};
|
|
387
387
|
|
|
388
|
+
/**
|
|
389
|
+
* BankTemplateConfig
|
|
390
|
+
*
|
|
391
|
+
* Bank configuration fields within a template manifest.
|
|
392
|
+
*
|
|
393
|
+
* Only includes configurable (per-bank) fields. Credential fields
|
|
394
|
+
* (API keys, base URLs) are intentionally excluded for security.
|
|
395
|
+
*/
|
|
396
|
+
export type BankTemplateConfig = {
|
|
397
|
+
/**
|
|
398
|
+
* Reflect Mission
|
|
399
|
+
*
|
|
400
|
+
* Mission/context for Reflect operations
|
|
401
|
+
*/
|
|
402
|
+
reflect_mission?: string | null;
|
|
403
|
+
/**
|
|
404
|
+
* Retain Mission
|
|
405
|
+
*
|
|
406
|
+
* Steers what gets extracted during retain
|
|
407
|
+
*/
|
|
408
|
+
retain_mission?: string | null;
|
|
409
|
+
/**
|
|
410
|
+
* Retain Extraction Mode
|
|
411
|
+
*
|
|
412
|
+
* Fact extraction mode: 'concise' (default), 'verbose', or 'custom'
|
|
413
|
+
*/
|
|
414
|
+
retain_extraction_mode?: string | null;
|
|
415
|
+
/**
|
|
416
|
+
* Retain Custom Instructions
|
|
417
|
+
*
|
|
418
|
+
* Custom extraction prompt (when mode='custom')
|
|
419
|
+
*/
|
|
420
|
+
retain_custom_instructions?: string | null;
|
|
421
|
+
/**
|
|
422
|
+
* Retain Chunk Size
|
|
423
|
+
*
|
|
424
|
+
* Max token size for each content chunk
|
|
425
|
+
*/
|
|
426
|
+
retain_chunk_size?: number | null;
|
|
427
|
+
/**
|
|
428
|
+
* Enable Observations
|
|
429
|
+
*
|
|
430
|
+
* Toggle observation consolidation
|
|
431
|
+
*/
|
|
432
|
+
enable_observations?: boolean | null;
|
|
433
|
+
/**
|
|
434
|
+
* Observations Mission
|
|
435
|
+
*
|
|
436
|
+
* Controls what gets synthesised
|
|
437
|
+
*/
|
|
438
|
+
observations_mission?: string | null;
|
|
439
|
+
/**
|
|
440
|
+
* Disposition Skepticism
|
|
441
|
+
*
|
|
442
|
+
* Skepticism trait (1-5)
|
|
443
|
+
*/
|
|
444
|
+
disposition_skepticism?: number | null;
|
|
445
|
+
/**
|
|
446
|
+
* Disposition Literalism
|
|
447
|
+
*
|
|
448
|
+
* Literalism trait (1-5)
|
|
449
|
+
*/
|
|
450
|
+
disposition_literalism?: number | null;
|
|
451
|
+
/**
|
|
452
|
+
* Disposition Empathy
|
|
453
|
+
*
|
|
454
|
+
* Empathy trait (1-5)
|
|
455
|
+
*/
|
|
456
|
+
disposition_empathy?: number | null;
|
|
457
|
+
/**
|
|
458
|
+
* Entity Labels
|
|
459
|
+
*
|
|
460
|
+
* Controlled vocabulary for entity labels
|
|
461
|
+
*/
|
|
462
|
+
entity_labels?: Array<{
|
|
463
|
+
[key: string]: unknown;
|
|
464
|
+
}> | null;
|
|
465
|
+
/**
|
|
466
|
+
* Entities Allow Free Form
|
|
467
|
+
*
|
|
468
|
+
* Allow entities outside the label vocabulary
|
|
469
|
+
*/
|
|
470
|
+
entities_allow_free_form?: boolean | null;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* BankTemplateDirective
|
|
475
|
+
*
|
|
476
|
+
* A directive definition within a bank template manifest.
|
|
477
|
+
*
|
|
478
|
+
* Directives are matched by name on re-import: existing directives
|
|
479
|
+
* with the same name are updated, new ones are created.
|
|
480
|
+
*/
|
|
481
|
+
export type BankTemplateDirective = {
|
|
482
|
+
/**
|
|
483
|
+
* Name
|
|
484
|
+
*
|
|
485
|
+
* Human-readable name for the directive (used as match key on re-import)
|
|
486
|
+
*/
|
|
487
|
+
name: string;
|
|
488
|
+
/**
|
|
489
|
+
* Content
|
|
490
|
+
*
|
|
491
|
+
* The directive text to inject into prompts
|
|
492
|
+
*/
|
|
493
|
+
content: string;
|
|
494
|
+
/**
|
|
495
|
+
* Priority
|
|
496
|
+
*
|
|
497
|
+
* Higher priority directives are injected first
|
|
498
|
+
*/
|
|
499
|
+
priority?: number;
|
|
500
|
+
/**
|
|
501
|
+
* Is Active
|
|
502
|
+
*
|
|
503
|
+
* Whether this directive is active
|
|
504
|
+
*/
|
|
505
|
+
is_active?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Tags
|
|
508
|
+
*
|
|
509
|
+
* Tags for filtering
|
|
510
|
+
*/
|
|
511
|
+
tags?: Array<string>;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* BankTemplateImportResponse
|
|
516
|
+
*
|
|
517
|
+
* Response model for the bank template import endpoint.
|
|
518
|
+
*/
|
|
519
|
+
export type BankTemplateImportResponse = {
|
|
520
|
+
/**
|
|
521
|
+
* Bank Id
|
|
522
|
+
*
|
|
523
|
+
* Bank that was imported into
|
|
524
|
+
*/
|
|
525
|
+
bank_id: string;
|
|
526
|
+
/**
|
|
527
|
+
* Config Applied
|
|
528
|
+
*
|
|
529
|
+
* Whether bank config was updated
|
|
530
|
+
*/
|
|
531
|
+
config_applied: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Mental Models Created
|
|
534
|
+
*
|
|
535
|
+
* IDs of newly created mental models
|
|
536
|
+
*/
|
|
537
|
+
mental_models_created?: Array<string>;
|
|
538
|
+
/**
|
|
539
|
+
* Mental Models Updated
|
|
540
|
+
*
|
|
541
|
+
* IDs of updated mental models
|
|
542
|
+
*/
|
|
543
|
+
mental_models_updated?: Array<string>;
|
|
544
|
+
/**
|
|
545
|
+
* Directives Created
|
|
546
|
+
*
|
|
547
|
+
* Names of newly created directives
|
|
548
|
+
*/
|
|
549
|
+
directives_created?: Array<string>;
|
|
550
|
+
/**
|
|
551
|
+
* Directives Updated
|
|
552
|
+
*
|
|
553
|
+
* Names of updated directives
|
|
554
|
+
*/
|
|
555
|
+
directives_updated?: Array<string>;
|
|
556
|
+
/**
|
|
557
|
+
* Operation Ids
|
|
558
|
+
*
|
|
559
|
+
* Operation IDs for mental model content generation (async)
|
|
560
|
+
*/
|
|
561
|
+
operation_ids?: Array<string>;
|
|
562
|
+
/**
|
|
563
|
+
* Dry Run
|
|
564
|
+
*
|
|
565
|
+
* True if this was a validation-only run
|
|
566
|
+
*/
|
|
567
|
+
dry_run?: boolean;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* BankTemplateManifest
|
|
572
|
+
*
|
|
573
|
+
* A bank template manifest for import/export.
|
|
574
|
+
*
|
|
575
|
+
* Version field enables forward-compatible schema evolution: the API
|
|
576
|
+
* auto-upgrades older manifest versions to the current schema on import.
|
|
577
|
+
*/
|
|
578
|
+
export type BankTemplateManifest = {
|
|
579
|
+
/**
|
|
580
|
+
* Version
|
|
581
|
+
*
|
|
582
|
+
* Manifest schema version (currently '1')
|
|
583
|
+
*/
|
|
584
|
+
version: string;
|
|
585
|
+
/**
|
|
586
|
+
* Bank configuration to apply. Omit to leave config unchanged.
|
|
587
|
+
*/
|
|
588
|
+
bank?: BankTemplateConfig | null;
|
|
589
|
+
/**
|
|
590
|
+
* Mental Models
|
|
591
|
+
*
|
|
592
|
+
* Mental models to create or update (matched by id). Omit to leave unchanged.
|
|
593
|
+
*/
|
|
594
|
+
mental_models?: Array<BankTemplateMentalModel> | null;
|
|
595
|
+
/**
|
|
596
|
+
* Directives
|
|
597
|
+
*
|
|
598
|
+
* Directives to create or update (matched by name). Omit to leave unchanged.
|
|
599
|
+
*/
|
|
600
|
+
directives?: Array<BankTemplateDirective> | null;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* BankTemplateMentalModel
|
|
605
|
+
*
|
|
606
|
+
* A mental model definition within a bank template manifest.
|
|
607
|
+
*/
|
|
608
|
+
export type BankTemplateMentalModel = {
|
|
609
|
+
/**
|
|
610
|
+
* Id
|
|
611
|
+
*
|
|
612
|
+
* Unique ID for the mental model (alphanumeric lowercase with hyphens)
|
|
613
|
+
*/
|
|
614
|
+
id: string;
|
|
615
|
+
/**
|
|
616
|
+
* Name
|
|
617
|
+
*
|
|
618
|
+
* Human-readable name for the mental model
|
|
619
|
+
*/
|
|
620
|
+
name: string;
|
|
621
|
+
/**
|
|
622
|
+
* Source Query
|
|
623
|
+
*
|
|
624
|
+
* The query to run to generate content
|
|
625
|
+
*/
|
|
626
|
+
source_query: string;
|
|
627
|
+
/**
|
|
628
|
+
* Tags
|
|
629
|
+
*
|
|
630
|
+
* Tags for scoped visibility
|
|
631
|
+
*/
|
|
632
|
+
tags?: Array<string>;
|
|
633
|
+
/**
|
|
634
|
+
* Max Tokens
|
|
635
|
+
*
|
|
636
|
+
* Maximum tokens for generated content
|
|
637
|
+
*/
|
|
638
|
+
max_tokens?: number;
|
|
639
|
+
/**
|
|
640
|
+
* Trigger settings
|
|
641
|
+
*/
|
|
642
|
+
trigger?: MentalModelTriggerOutput;
|
|
643
|
+
};
|
|
644
|
+
|
|
388
645
|
/**
|
|
389
646
|
* Body_file_retain
|
|
390
647
|
*/
|
|
@@ -1400,6 +1657,12 @@ export type MemoryItem = {
|
|
|
1400
1657
|
* Named retain strategy for this item. Overrides the bank's default strategy for this item only. Strategies are defined in the bank config under 'retain_strategies'.
|
|
1401
1658
|
*/
|
|
1402
1659
|
strategy?: string | null;
|
|
1660
|
+
/**
|
|
1661
|
+
* Update Mode
|
|
1662
|
+
*
|
|
1663
|
+
* How to handle an existing document with the same document_id. 'replace' (default) deletes old data and reprocesses from scratch. 'append' concatenates new content to the existing document text and reprocesses.
|
|
1664
|
+
*/
|
|
1665
|
+
update_mode?: "replace" | "append" | null;
|
|
1403
1666
|
};
|
|
1404
1667
|
|
|
1405
1668
|
/**
|
|
@@ -1435,13 +1698,13 @@ export type MentalModelResponse = {
|
|
|
1435
1698
|
/**
|
|
1436
1699
|
* Source Query
|
|
1437
1700
|
*/
|
|
1438
|
-
source_query
|
|
1701
|
+
source_query?: string | null;
|
|
1439
1702
|
/**
|
|
1440
1703
|
* Content
|
|
1441
1704
|
*
|
|
1442
1705
|
* The mental model content as well-formatted markdown (auto-generated from reflect endpoint)
|
|
1443
1706
|
*/
|
|
1444
|
-
content
|
|
1707
|
+
content?: string | null;
|
|
1445
1708
|
/**
|
|
1446
1709
|
* Tags
|
|
1447
1710
|
*/
|
|
@@ -1449,8 +1712,8 @@ export type MentalModelResponse = {
|
|
|
1449
1712
|
/**
|
|
1450
1713
|
* Max Tokens
|
|
1451
1714
|
*/
|
|
1452
|
-
max_tokens?: number;
|
|
1453
|
-
trigger?: MentalModelTriggerOutput;
|
|
1715
|
+
max_tokens?: number | null;
|
|
1716
|
+
trigger?: MentalModelTriggerOutput | null;
|
|
1454
1717
|
/**
|
|
1455
1718
|
* Last Refreshed At
|
|
1456
1719
|
*/
|
|
@@ -3331,6 +3594,12 @@ export type ListMentalModelsData = {
|
|
|
3331
3594
|
* How to match tags
|
|
3332
3595
|
*/
|
|
3333
3596
|
tags_match?: "any" | "all" | "exact";
|
|
3597
|
+
/**
|
|
3598
|
+
* Detail
|
|
3599
|
+
*
|
|
3600
|
+
* Detail level: 'metadata' (names/tags only), 'content' (adds content/config), 'full' (includes reflect_response)
|
|
3601
|
+
*/
|
|
3602
|
+
detail?: "metadata" | "content" | "full";
|
|
3334
3603
|
/**
|
|
3335
3604
|
* Limit
|
|
3336
3605
|
*/
|
|
@@ -3458,7 +3727,14 @@ export type GetMentalModelData = {
|
|
|
3458
3727
|
*/
|
|
3459
3728
|
mental_model_id: string;
|
|
3460
3729
|
};
|
|
3461
|
-
query?:
|
|
3730
|
+
query?: {
|
|
3731
|
+
/**
|
|
3732
|
+
* Detail
|
|
3733
|
+
*
|
|
3734
|
+
* Detail level: 'metadata' (names/tags only), 'content' (adds content/config), 'full' (includes reflect_response)
|
|
3735
|
+
*/
|
|
3736
|
+
detail?: "metadata" | "content" | "full";
|
|
3737
|
+
};
|
|
3462
3738
|
url: "/v1/default/banks/{bank_id}/mental-models/{mental_model_id}";
|
|
3463
3739
|
};
|
|
3464
3740
|
|
|
@@ -4523,6 +4799,103 @@ export type CreateOrUpdateBankResponses = {
|
|
|
4523
4799
|
export type CreateOrUpdateBankResponse =
|
|
4524
4800
|
CreateOrUpdateBankResponses[keyof CreateOrUpdateBankResponses];
|
|
4525
4801
|
|
|
4802
|
+
export type ImportBankTemplateData = {
|
|
4803
|
+
body?: never;
|
|
4804
|
+
headers?: {
|
|
4805
|
+
/**
|
|
4806
|
+
* Authorization
|
|
4807
|
+
*/
|
|
4808
|
+
authorization?: string | null;
|
|
4809
|
+
};
|
|
4810
|
+
path: {
|
|
4811
|
+
/**
|
|
4812
|
+
* Bank Id
|
|
4813
|
+
*/
|
|
4814
|
+
bank_id: string;
|
|
4815
|
+
};
|
|
4816
|
+
query?: {
|
|
4817
|
+
/**
|
|
4818
|
+
* Dry Run
|
|
4819
|
+
*
|
|
4820
|
+
* Validate only, do not apply changes
|
|
4821
|
+
*/
|
|
4822
|
+
dry_run?: boolean;
|
|
4823
|
+
};
|
|
4824
|
+
url: "/v1/default/banks/{bank_id}/import";
|
|
4825
|
+
};
|
|
4826
|
+
|
|
4827
|
+
export type ImportBankTemplateErrors = {
|
|
4828
|
+
/**
|
|
4829
|
+
* Validation Error
|
|
4830
|
+
*/
|
|
4831
|
+
422: HttpValidationError;
|
|
4832
|
+
};
|
|
4833
|
+
|
|
4834
|
+
export type ImportBankTemplateError =
|
|
4835
|
+
ImportBankTemplateErrors[keyof ImportBankTemplateErrors];
|
|
4836
|
+
|
|
4837
|
+
export type ImportBankTemplateResponses = {
|
|
4838
|
+
/**
|
|
4839
|
+
* Successful Response
|
|
4840
|
+
*/
|
|
4841
|
+
200: BankTemplateImportResponse;
|
|
4842
|
+
};
|
|
4843
|
+
|
|
4844
|
+
export type ImportBankTemplateResponse =
|
|
4845
|
+
ImportBankTemplateResponses[keyof ImportBankTemplateResponses];
|
|
4846
|
+
|
|
4847
|
+
export type ExportBankTemplateData = {
|
|
4848
|
+
body?: never;
|
|
4849
|
+
headers?: {
|
|
4850
|
+
/**
|
|
4851
|
+
* Authorization
|
|
4852
|
+
*/
|
|
4853
|
+
authorization?: string | null;
|
|
4854
|
+
};
|
|
4855
|
+
path: {
|
|
4856
|
+
/**
|
|
4857
|
+
* Bank Id
|
|
4858
|
+
*/
|
|
4859
|
+
bank_id: string;
|
|
4860
|
+
};
|
|
4861
|
+
query?: never;
|
|
4862
|
+
url: "/v1/default/banks/{bank_id}/export";
|
|
4863
|
+
};
|
|
4864
|
+
|
|
4865
|
+
export type ExportBankTemplateErrors = {
|
|
4866
|
+
/**
|
|
4867
|
+
* Validation Error
|
|
4868
|
+
*/
|
|
4869
|
+
422: HttpValidationError;
|
|
4870
|
+
};
|
|
4871
|
+
|
|
4872
|
+
export type ExportBankTemplateError =
|
|
4873
|
+
ExportBankTemplateErrors[keyof ExportBankTemplateErrors];
|
|
4874
|
+
|
|
4875
|
+
export type ExportBankTemplateResponses = {
|
|
4876
|
+
/**
|
|
4877
|
+
* Successful Response
|
|
4878
|
+
*/
|
|
4879
|
+
200: BankTemplateManifest;
|
|
4880
|
+
};
|
|
4881
|
+
|
|
4882
|
+
export type ExportBankTemplateResponse =
|
|
4883
|
+
ExportBankTemplateResponses[keyof ExportBankTemplateResponses];
|
|
4884
|
+
|
|
4885
|
+
export type GetBankTemplateSchemaData = {
|
|
4886
|
+
body?: never;
|
|
4887
|
+
path?: never;
|
|
4888
|
+
query?: never;
|
|
4889
|
+
url: "/v1/bank-template-schema";
|
|
4890
|
+
};
|
|
4891
|
+
|
|
4892
|
+
export type GetBankTemplateSchemaResponses = {
|
|
4893
|
+
/**
|
|
4894
|
+
* Successful Response
|
|
4895
|
+
*/
|
|
4896
|
+
200: unknown;
|
|
4897
|
+
};
|
|
4898
|
+
|
|
4526
4899
|
export type ClearObservationsData = {
|
|
4527
4900
|
body?: never;
|
|
4528
4901
|
headers?: {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -83,6 +83,7 @@ export interface MemoryItemInput {
|
|
|
83
83
|
tags?: string[];
|
|
84
84
|
observation_scopes?: "per_tag" | "combined" | "all_combinations" | string[][];
|
|
85
85
|
strategy?: string;
|
|
86
|
+
update_mode?: "replace" | "append";
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
export class HindsightClient {
|
|
@@ -137,6 +138,8 @@ export class HindsightClient {
|
|
|
137
138
|
entities?: EntityInput[];
|
|
138
139
|
/** Optional list of tags for this memory */
|
|
139
140
|
tags?: string[];
|
|
141
|
+
/** How to handle existing documents: 'replace' (default) or 'append' */
|
|
142
|
+
updateMode?: "replace" | "append";
|
|
140
143
|
}
|
|
141
144
|
): Promise<RetainResponse> {
|
|
142
145
|
const item: {
|
|
@@ -147,6 +150,7 @@ export class HindsightClient {
|
|
|
147
150
|
document_id?: string;
|
|
148
151
|
entities?: EntityInput[];
|
|
149
152
|
tags?: string[];
|
|
153
|
+
update_mode?: "replace" | "append";
|
|
150
154
|
} = { content };
|
|
151
155
|
if (options?.timestamp) {
|
|
152
156
|
item.timestamp =
|
|
@@ -169,6 +173,9 @@ export class HindsightClient {
|
|
|
169
173
|
if (options?.tags) {
|
|
170
174
|
item.tags = options.tags;
|
|
171
175
|
}
|
|
176
|
+
if (options?.updateMode) {
|
|
177
|
+
item.update_mode = options.updateMode;
|
|
178
|
+
}
|
|
172
179
|
|
|
173
180
|
const response = await sdk.retainMemories({
|
|
174
181
|
client: this.client,
|
|
@@ -192,6 +199,7 @@ export class HindsightClient {
|
|
|
192
199
|
tags: item.tags,
|
|
193
200
|
observation_scopes: item.observation_scopes,
|
|
194
201
|
strategy: item.strategy,
|
|
202
|
+
update_mode: item.update_mode,
|
|
195
203
|
timestamp:
|
|
196
204
|
item.timestamp instanceof Date
|
|
197
205
|
? item.timestamp.toISOString()
|
|
@@ -742,6 +750,51 @@ export class HindsightClient {
|
|
|
742
750
|
}
|
|
743
751
|
}
|
|
744
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Serialize a RecallResponse to a string suitable for LLM prompts.
|
|
755
|
+
*
|
|
756
|
+
* Builds a prompt containing:
|
|
757
|
+
* - Facts: each result as a JSON object with text, context, temporal fields,
|
|
758
|
+
* and source_chunk (if the result's chunk_id matches a chunk in the response).
|
|
759
|
+
* - Entities: entity summaries from observations, formatted as sections.
|
|
760
|
+
*
|
|
761
|
+
* Mirrors the format used internally by Hindsight's reflect operation.
|
|
762
|
+
*/
|
|
763
|
+
export function recallResponseToPromptString(response: RecallResponse): string {
|
|
764
|
+
const chunksMap = response.chunks ?? {};
|
|
765
|
+
const sections: string[] = [];
|
|
766
|
+
|
|
767
|
+
// Facts
|
|
768
|
+
const formattedFacts = (response.results ?? []).map((result) => {
|
|
769
|
+
const obj: Record<string, string> = { text: result.text };
|
|
770
|
+
if (result.context) obj.context = result.context;
|
|
771
|
+
if (result.occurred_start) obj.occurred_start = result.occurred_start;
|
|
772
|
+
if (result.occurred_end) obj.occurred_end = result.occurred_end;
|
|
773
|
+
if (result.mentioned_at) obj.mentioned_at = result.mentioned_at;
|
|
774
|
+
if (result.chunk_id && chunksMap[result.chunk_id]) {
|
|
775
|
+
obj.source_chunk = chunksMap[result.chunk_id].text;
|
|
776
|
+
}
|
|
777
|
+
return obj;
|
|
778
|
+
});
|
|
779
|
+
sections.push('FACTS:\n' + JSON.stringify(formattedFacts, null, 2));
|
|
780
|
+
|
|
781
|
+
// Entities
|
|
782
|
+
const entities = response.entities;
|
|
783
|
+
if (entities) {
|
|
784
|
+
const entityParts: string[] = [];
|
|
785
|
+
for (const [name, state] of Object.entries(entities)) {
|
|
786
|
+
if (state.observations?.length) {
|
|
787
|
+
entityParts.push(`## ${name}\n${state.observations[0].text}`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (entityParts.length) {
|
|
791
|
+
sections.push('ENTITIES:\n' + entityParts.join('\n\n'));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
return sections.join('\n\n');
|
|
796
|
+
}
|
|
797
|
+
|
|
745
798
|
// Re-export types for convenience
|
|
746
799
|
export type {
|
|
747
800
|
RetainRequest,
|