memorysync-sdk 1.1.1 → 1.2.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 +302 -1
- package/dist/index.d.ts +302 -1
- package/dist/index.js +408 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +408 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +49 -48
package/dist/index.d.mts
CHANGED
|
@@ -546,6 +546,139 @@ interface ExportResponse {
|
|
|
546
546
|
generatedAt: string;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
/** One edit inside a {@link MemorySyncClient.batchUpdate} call. */
|
|
550
|
+
interface BatchUpdateItem {
|
|
551
|
+
memoryId: number;
|
|
552
|
+
tags?: string[];
|
|
553
|
+
importance?: number;
|
|
554
|
+
metadata?: Record<string, unknown>;
|
|
555
|
+
source?: string;
|
|
556
|
+
eventType?: string;
|
|
557
|
+
}
|
|
558
|
+
interface BatchUpdateItemResult {
|
|
559
|
+
index: number;
|
|
560
|
+
memoryId: number;
|
|
561
|
+
status: "updated" | "not_found";
|
|
562
|
+
changedFields: string[];
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Result of a batch update.
|
|
566
|
+
*
|
|
567
|
+
* The server answers `207 Multi-Status`: a batch may legitimately name a memory
|
|
568
|
+
* the caller cannot see, and the caller needs to know which one rather than
|
|
569
|
+
* losing the whole request. `notFound` is an ordinary outcome, not an error.
|
|
570
|
+
*/
|
|
571
|
+
interface BatchUpdateResponse {
|
|
572
|
+
total: number;
|
|
573
|
+
updated: number;
|
|
574
|
+
notFound: number;
|
|
575
|
+
results: BatchUpdateItemResult[];
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Criteria for a filter-based delete.
|
|
579
|
+
*
|
|
580
|
+
* At least one field must be set — an all-empty filter would mean "delete
|
|
581
|
+
* everything I own", which has to be an explicit `purgeUser()` call instead.
|
|
582
|
+
* `tags` matches memories carrying **all** the listed tags, not any of them.
|
|
583
|
+
*/
|
|
584
|
+
interface ForgetFilters {
|
|
585
|
+
source?: string;
|
|
586
|
+
eventType?: string;
|
|
587
|
+
tags?: string[];
|
|
588
|
+
tier?: string;
|
|
589
|
+
before?: string;
|
|
590
|
+
after?: string;
|
|
591
|
+
}
|
|
592
|
+
interface ForgetRequest {
|
|
593
|
+
memoryIds?: number[];
|
|
594
|
+
filters?: ForgetFilters;
|
|
595
|
+
/** Return the ids that *would* be deleted without deleting anything. */
|
|
596
|
+
dryRun?: boolean;
|
|
597
|
+
reason?: string;
|
|
598
|
+
}
|
|
599
|
+
type RevisionEvent = "created" | "updated" | "superseded" | "soft_deleted" | "restored" | "archived" | "purged";
|
|
600
|
+
/**
|
|
601
|
+
* One recorded change to a memory.
|
|
602
|
+
*
|
|
603
|
+
* Revision 0 is the creation entry, synthesised by the server. `actor` is `null`
|
|
604
|
+
* for changes made by background workers, which have no request behind them —
|
|
605
|
+
* that is expected rather than missing data.
|
|
606
|
+
*/
|
|
607
|
+
interface RevisionEntry {
|
|
608
|
+
revision: number;
|
|
609
|
+
event: RevisionEvent;
|
|
610
|
+
changedFields: string[];
|
|
611
|
+
diff: Record<string, {
|
|
612
|
+
old?: unknown;
|
|
613
|
+
new?: unknown;
|
|
614
|
+
}>;
|
|
615
|
+
actor: string | null;
|
|
616
|
+
createdAt: string;
|
|
617
|
+
}
|
|
618
|
+
interface HistoryResponse {
|
|
619
|
+
memoryId: number;
|
|
620
|
+
total: number;
|
|
621
|
+
revisions: RevisionEntry[];
|
|
622
|
+
/**
|
|
623
|
+
* The fields changes are recorded for. Worth reading: only user-meaningful
|
|
624
|
+
* fields are tracked, so without this you cannot tell "nothing changed" from
|
|
625
|
+
* "that change is not recorded".
|
|
626
|
+
*/
|
|
627
|
+
trackedFields: string[];
|
|
628
|
+
}
|
|
629
|
+
type FeedbackSignal = "positive" | "negative" | "retrieved" | "ignored";
|
|
630
|
+
interface FeedbackTrend {
|
|
631
|
+
momentum: string;
|
|
632
|
+
consistency: number;
|
|
633
|
+
trendMultiplier: number;
|
|
634
|
+
recentCount: number;
|
|
635
|
+
}
|
|
636
|
+
interface FeedbackSummary {
|
|
637
|
+
totalSignals: number;
|
|
638
|
+
signalCounts: Record<string, number>;
|
|
639
|
+
trend: FeedbackTrend;
|
|
640
|
+
}
|
|
641
|
+
interface FeedbackResponse {
|
|
642
|
+
memoryId: number;
|
|
643
|
+
signal: FeedbackSignal;
|
|
644
|
+
importanceBefore: number;
|
|
645
|
+
importanceAfter: number;
|
|
646
|
+
/** Delta actually applied. `0` when ranking influence is off, or when the change was clamped at the bounds. */
|
|
647
|
+
adjustment: number;
|
|
648
|
+
/** Whether this signal was allowed to change ranking. Reported, not assumed. */
|
|
649
|
+
influencedRanking: boolean;
|
|
650
|
+
summary: FeedbackSummary;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The memory vocabulary in effect for an organization.
|
|
654
|
+
*
|
|
655
|
+
* The built-in types are a floor: they always apply and cannot be removed,
|
|
656
|
+
* because dropping a type would leave memories already filed under it invisible
|
|
657
|
+
* to any typed retrieval. Only `custom*` entries are removable.
|
|
658
|
+
*/
|
|
659
|
+
interface Ontology {
|
|
660
|
+
contentTypes: string[];
|
|
661
|
+
relationTypes: string[];
|
|
662
|
+
builtinContentTypes: string[];
|
|
663
|
+
builtinRelationTypes: string[];
|
|
664
|
+
customContentTypes: string[];
|
|
665
|
+
customRelationTypes: string[];
|
|
666
|
+
maxCustomTypes: number;
|
|
667
|
+
}
|
|
668
|
+
interface OntologyUpdateRequest {
|
|
669
|
+
contentTypes?: string[];
|
|
670
|
+
relationTypes?: string[];
|
|
671
|
+
}
|
|
672
|
+
interface UploadRequest {
|
|
673
|
+
/** File contents. A `Blob`/`File` in browsers and Node 18+, or a `Uint8Array`. */
|
|
674
|
+
file: Blob | Uint8Array;
|
|
675
|
+
/** Required: the server picks its parser from the extension. */
|
|
676
|
+
filename: string;
|
|
677
|
+
contentType?: string;
|
|
678
|
+
source?: string;
|
|
679
|
+
metadata?: Record<string, unknown>;
|
|
680
|
+
endUserId?: string;
|
|
681
|
+
}
|
|
549
682
|
declare class MemorySyncClient {
|
|
550
683
|
private readonly apiKey;
|
|
551
684
|
private readonly baseUrl;
|
|
@@ -564,11 +697,179 @@ declare class MemorySyncClient {
|
|
|
564
697
|
query(req: QueryRequest): Promise<QueryResponse>;
|
|
565
698
|
get(memoryId: number): Promise<MemoryRecord>;
|
|
566
699
|
update(memoryId: number, req: UpdateRequest): Promise<MemoryRecord>;
|
|
700
|
+
/**
|
|
701
|
+
* Delete memories, either by id or by filter. Returns the deleted ids.
|
|
702
|
+
*
|
|
703
|
+
* Accepts the legacy positional form `forget([1,2], "reason")` as well as
|
|
704
|
+
* `forget({ filters, dryRun })`. The positional form is kept because it ships
|
|
705
|
+
* in 1.1.x and removing it would break installed callers for no benefit.
|
|
706
|
+
*
|
|
707
|
+
* Exactly one selector. Passing both is rejected rather than resolved by a
|
|
708
|
+
* precedence rule, because getting that wrong on a delete cannot be undone.
|
|
709
|
+
* Deletion is scoped to the calling end user, so a filter never reaches
|
|
710
|
+
* another end user's memories — including the organisation's connector history.
|
|
711
|
+
*/
|
|
712
|
+
forget(request: ForgetRequest): Promise<number[]>;
|
|
567
713
|
forget(memoryIds: number[], reason?: string): Promise<number[]>;
|
|
714
|
+
/**
|
|
715
|
+
* Delete every memory belonging to the calling end user.
|
|
716
|
+
*
|
|
717
|
+
* Separate from {@link forget} on purpose: this reads like what it does, so a
|
|
718
|
+
* whole-namespace delete can never be the accidental result of an empty filter.
|
|
719
|
+
*/
|
|
720
|
+
purgeUser(): Promise<Record<string, unknown>>;
|
|
568
721
|
summarize(req: SummarizeRequest): Promise<MemoryRecord>;
|
|
569
722
|
compose(req: ComposeRequest): Promise<ComposeResponse>;
|
|
570
723
|
exportAll(): Promise<ExportResponse>;
|
|
571
724
|
createRelation(fromMemoryId: number, req: RelationCreateRequest): Promise<RelationRecord>;
|
|
725
|
+
/**
|
|
726
|
+
* Ingest a document and store the memories extracted from its text.
|
|
727
|
+
*
|
|
728
|
+
* Accepts the formats the connectors accept — PDF, DOCX, PPTX, XLSX, CSV,
|
|
729
|
+
* text, Markdown, HTML, source code, and images/audio/video where
|
|
730
|
+
* transcription is configured.
|
|
731
|
+
*
|
|
732
|
+
* Billed as an add, one unit per memory created. Resolves to the first stored
|
|
733
|
+
* memory, or an {@link AddSkippedResponse} when the file yielded nothing worth
|
|
734
|
+
* keeping — a blank scan, a sheet of empty cells, or content the extractor
|
|
735
|
+
* judges trivial are all normal outcomes rather than errors.
|
|
736
|
+
*/
|
|
737
|
+
upload(req: UploadRequest): Promise<AddResponse>;
|
|
738
|
+
/**
|
|
739
|
+
* Apply many metadata edits in one request.
|
|
740
|
+
*
|
|
741
|
+
* Editable: `tags`, `importance`, `metadata`, `source`, `eventType`. A memory's
|
|
742
|
+
* text, embeddings, owner, environment and project are not editable.
|
|
743
|
+
*
|
|
744
|
+
* Applied in one transaction, so the batch either lands or it does not — but an
|
|
745
|
+
* id the caller cannot see is reported per item rather than failing the request.
|
|
746
|
+
*/
|
|
747
|
+
batchUpdate(items: BatchUpdateItem[]): Promise<BatchUpdateResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Recorded changes to one memory, oldest first.
|
|
750
|
+
*
|
|
751
|
+
* Entry 0 is the creation. Later entries carry the old and new value per field.
|
|
752
|
+
* Entries written by background workers have `actor: null`. Only
|
|
753
|
+
* user-meaningful fields are tracked; the watched list comes back in
|
|
754
|
+
* `trackedFields`.
|
|
755
|
+
*/
|
|
756
|
+
history(memoryId: number, opts?: {
|
|
757
|
+
limit?: number;
|
|
758
|
+
offset?: number;
|
|
759
|
+
}): Promise<HistoryResponse>;
|
|
760
|
+
/**
|
|
761
|
+
* Tell MemorySync whether a memory was useful.
|
|
762
|
+
*
|
|
763
|
+
* By default this moves the memory's `importance`, a weighted retrieval-ranking
|
|
764
|
+
* factor, so a memory marked useful surfaces more readily and one marked wrong
|
|
765
|
+
* surfaces less. The size of the move is adaptive: consistent signals amplify
|
|
766
|
+
* it, mixed signals damp it. Importance is clamped to [0.05, 1.0], so no run of
|
|
767
|
+
* negative feedback can make a memory permanently unreachable. Not billed.
|
|
768
|
+
*/
|
|
769
|
+
feedback(memoryId: number, signal: FeedbackSignal, opts?: {
|
|
770
|
+
comment?: string;
|
|
771
|
+
}): Promise<FeedbackResponse>;
|
|
772
|
+
/** The memory vocabulary in effect for this organization. */
|
|
773
|
+
getOntology(): Promise<Ontology>;
|
|
774
|
+
/**
|
|
775
|
+
* Replace this organization's *additions* to the vocabulary.
|
|
776
|
+
*
|
|
777
|
+
* The two vocabularies are independent: omit one and it is left untouched, so
|
|
778
|
+
* adding a content type cannot wipe your relation types. Pass an empty array to
|
|
779
|
+
* clear a vocabulary's custom entries. The built-in types always remain.
|
|
780
|
+
*/
|
|
781
|
+
updateOntology(req: OntologyUpdateRequest): Promise<Ontology>;
|
|
782
|
+
/**
|
|
783
|
+
* Alias of {@link query} against `/memory/retrieve`.
|
|
784
|
+
*
|
|
785
|
+
* Both paths are live, and integrators arriving from other platforms reach for
|
|
786
|
+
* `retrieve`. Identical semantics.
|
|
787
|
+
*/
|
|
788
|
+
retrieve(req: QueryRequest): Promise<QueryResponse>;
|
|
789
|
+
/**
|
|
790
|
+
* Route a question to the best knowledge source and answer from it.
|
|
791
|
+
*
|
|
792
|
+
* Returns the raw payload: the response carries routing diagnostics whose shape
|
|
793
|
+
* is richer and more volatile than an SDK should freeze into an interface.
|
|
794
|
+
*/
|
|
795
|
+
searchRouted(query: string, opts?: {
|
|
796
|
+
k?: number;
|
|
797
|
+
route?: string;
|
|
798
|
+
includeReasoning?: boolean;
|
|
799
|
+
}): Promise<Record<string, unknown>>;
|
|
800
|
+
/** Compose an answer across several memories, with citations. */
|
|
801
|
+
synthesize(opts?: {
|
|
802
|
+
query?: string;
|
|
803
|
+
memoryIds?: number[];
|
|
804
|
+
maxMemories?: number;
|
|
805
|
+
}): Promise<Record<string, unknown>>;
|
|
806
|
+
/** Re-embed this end user's memories. Returns immediately (`202`). */
|
|
807
|
+
refresh(): Promise<Record<string, unknown>>;
|
|
808
|
+
/** Nodes and typed edges for this end user's memory graph. */
|
|
809
|
+
graph(opts?: {
|
|
810
|
+
limit?: number;
|
|
811
|
+
memoryId?: number;
|
|
812
|
+
depth?: number;
|
|
813
|
+
}): Promise<Record<string, unknown>>;
|
|
814
|
+
/** Semantic clusters over this end user's memories. */
|
|
815
|
+
clusters(opts?: {
|
|
816
|
+
limit?: number;
|
|
817
|
+
}): Promise<Record<string, unknown>>;
|
|
818
|
+
/** Contradictions and open decisions detected across memories. */
|
|
819
|
+
decisions(opts?: {
|
|
820
|
+
limit?: number;
|
|
821
|
+
}): Promise<Record<string, unknown>>;
|
|
822
|
+
/** Record which side of a contradiction wins. */
|
|
823
|
+
resolveDecision(opts?: {
|
|
824
|
+
decisionId?: string;
|
|
825
|
+
winningMemoryId?: number;
|
|
826
|
+
resolution?: string;
|
|
827
|
+
note?: string;
|
|
828
|
+
}): Promise<Record<string, unknown>>;
|
|
829
|
+
/**
|
|
830
|
+
* The intelligence report: themes, entities, patterns, dual-horizon view.
|
|
831
|
+
*
|
|
832
|
+
* `scope` is explicit by design server-side — nothing is inferred, so if you do
|
|
833
|
+
* not ask for a scope you do not get it.
|
|
834
|
+
*/
|
|
835
|
+
intelligence(opts?: {
|
|
836
|
+
limit?: number;
|
|
837
|
+
scope?: string;
|
|
838
|
+
projectId?: string;
|
|
839
|
+
}): Promise<Record<string, unknown>>;
|
|
840
|
+
/** Counts and coverage for the knowledge base. */
|
|
841
|
+
knowledgeStats(): Promise<Record<string, unknown>>;
|
|
842
|
+
/** Add a conversation turn and extract memories from it. */
|
|
843
|
+
addTurn(req: {
|
|
844
|
+
tenantId: string;
|
|
845
|
+
userId: string;
|
|
846
|
+
messages: Array<Record<string, unknown>>;
|
|
847
|
+
sessionId?: string;
|
|
848
|
+
metadata?: Record<string, unknown>;
|
|
849
|
+
}): Promise<Record<string, unknown>>;
|
|
850
|
+
/**
|
|
851
|
+
* Build a prompt-ready context block for an LLM call.
|
|
852
|
+
*
|
|
853
|
+
* `types` narrows the result to those content types. Names outside the
|
|
854
|
+
* organization's vocabulary are dropped rather than rejected, so a stale client
|
|
855
|
+
* gets a narrower answer instead of an error.
|
|
856
|
+
*/
|
|
857
|
+
recall(req: {
|
|
858
|
+
tenantId: string;
|
|
859
|
+
userId: string;
|
|
860
|
+
prompt: string;
|
|
861
|
+
k?: number;
|
|
862
|
+
types?: string[];
|
|
863
|
+
}): Promise<Record<string, unknown>>;
|
|
864
|
+
/** Async ingestion status for one memory. */
|
|
865
|
+
status(memoryId: number): Promise<Record<string, unknown>>;
|
|
866
|
+
/** Page through a specific end user's memories. */
|
|
867
|
+
listMemories(req: {
|
|
868
|
+
tenantId: string;
|
|
869
|
+
userId: string;
|
|
870
|
+
limit?: number;
|
|
871
|
+
offset?: number;
|
|
872
|
+
}): Promise<Record<string, unknown>>;
|
|
572
873
|
}
|
|
573
874
|
|
|
574
|
-
export { type AddRequest, type AddResponse, type AddSkippedResponse, type ApiKeyTestResponse, type ApiKeyTestStatus, type AuditActor, type AuditEvent, type AuditEventListResponse, type AuditEventQuery, type AuditResource, type AuditSortDirection, AuthError, type BulkAddItem, type BulkAddItemResult, type BulkAddResponse, type BulkRevokeApiKeyResult, type BulkRevokeApiKeysRequest, type BulkRevokeApiKeysResponse, type ComposeRequest, type ComposeResponse, ControlPlaneClient, type ControlPlaneConfig, type ControlPlaneRequestOptions, type CreateOrganizationRequest, type CreateWebhookRequest, type CreatedWebhook, type CurrentPlanResponse, type ExportResponse, type Integration, type IntegrationQuery, type LoginRequest, type LoginResponse, type MemoryRecord, MemorySyncClient, type MemorySyncConfig, MemorySyncError, NotFoundError, type OrganizationMembership, type OrganizationSettings, type OrganizationSettingsQuery, type Plan, type PlanLimits, type Project, type QueryFilters, type QueryRequest, type QueryResponse, RateLimitError, type RelationCreateRequest, type RelationRecord, type RelationshipType, type ReplayWebhookDeliveriesRequest, type ReplayWebhookDeliveriesResponse, ServerError, type Session, type SessionListResponse, type SummarizeRequest, type TeamMember, type TestWebhookRequest, type TestWebhookResponse, type UpdateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQuery, type WebhookListResponse, type WebhookRetryConfig, type WebhookSignatureConfig };
|
|
875
|
+
export { type AddRequest, type AddResponse, type AddSkippedResponse, type ApiKeyTestResponse, type ApiKeyTestStatus, type AuditActor, type AuditEvent, type AuditEventListResponse, type AuditEventQuery, type AuditResource, type AuditSortDirection, AuthError, type BatchUpdateItem, type BatchUpdateItemResult, type BatchUpdateResponse, type BulkAddItem, type BulkAddItemResult, type BulkAddResponse, type BulkRevokeApiKeyResult, type BulkRevokeApiKeysRequest, type BulkRevokeApiKeysResponse, type ComposeRequest, type ComposeResponse, ControlPlaneClient, type ControlPlaneConfig, type ControlPlaneRequestOptions, type CreateOrganizationRequest, type CreateWebhookRequest, type CreatedWebhook, type CurrentPlanResponse, type ExportResponse, type FeedbackResponse, type FeedbackSignal, type FeedbackSummary, type FeedbackTrend, type ForgetFilters, type ForgetRequest, type HistoryResponse, type Integration, type IntegrationQuery, type LoginRequest, type LoginResponse, type MemoryRecord, MemorySyncClient, type MemorySyncConfig, MemorySyncError, NotFoundError, type Ontology, type OntologyUpdateRequest, type OrganizationMembership, type OrganizationSettings, type OrganizationSettingsQuery, type Plan, type PlanLimits, type Project, type QueryFilters, type QueryRequest, type QueryResponse, RateLimitError, type RelationCreateRequest, type RelationRecord, type RelationshipType, type ReplayWebhookDeliveriesRequest, type ReplayWebhookDeliveriesResponse, type RevisionEntry, type RevisionEvent, ServerError, type Session, type SessionListResponse, type SummarizeRequest, type TeamMember, type TestWebhookRequest, type TestWebhookResponse, type UpdateRequest, type UpdateWebhookRequest, type UploadRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQuery, type WebhookListResponse, type WebhookRetryConfig, type WebhookSignatureConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -546,6 +546,139 @@ interface ExportResponse {
|
|
|
546
546
|
generatedAt: string;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
/** One edit inside a {@link MemorySyncClient.batchUpdate} call. */
|
|
550
|
+
interface BatchUpdateItem {
|
|
551
|
+
memoryId: number;
|
|
552
|
+
tags?: string[];
|
|
553
|
+
importance?: number;
|
|
554
|
+
metadata?: Record<string, unknown>;
|
|
555
|
+
source?: string;
|
|
556
|
+
eventType?: string;
|
|
557
|
+
}
|
|
558
|
+
interface BatchUpdateItemResult {
|
|
559
|
+
index: number;
|
|
560
|
+
memoryId: number;
|
|
561
|
+
status: "updated" | "not_found";
|
|
562
|
+
changedFields: string[];
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Result of a batch update.
|
|
566
|
+
*
|
|
567
|
+
* The server answers `207 Multi-Status`: a batch may legitimately name a memory
|
|
568
|
+
* the caller cannot see, and the caller needs to know which one rather than
|
|
569
|
+
* losing the whole request. `notFound` is an ordinary outcome, not an error.
|
|
570
|
+
*/
|
|
571
|
+
interface BatchUpdateResponse {
|
|
572
|
+
total: number;
|
|
573
|
+
updated: number;
|
|
574
|
+
notFound: number;
|
|
575
|
+
results: BatchUpdateItemResult[];
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Criteria for a filter-based delete.
|
|
579
|
+
*
|
|
580
|
+
* At least one field must be set — an all-empty filter would mean "delete
|
|
581
|
+
* everything I own", which has to be an explicit `purgeUser()` call instead.
|
|
582
|
+
* `tags` matches memories carrying **all** the listed tags, not any of them.
|
|
583
|
+
*/
|
|
584
|
+
interface ForgetFilters {
|
|
585
|
+
source?: string;
|
|
586
|
+
eventType?: string;
|
|
587
|
+
tags?: string[];
|
|
588
|
+
tier?: string;
|
|
589
|
+
before?: string;
|
|
590
|
+
after?: string;
|
|
591
|
+
}
|
|
592
|
+
interface ForgetRequest {
|
|
593
|
+
memoryIds?: number[];
|
|
594
|
+
filters?: ForgetFilters;
|
|
595
|
+
/** Return the ids that *would* be deleted without deleting anything. */
|
|
596
|
+
dryRun?: boolean;
|
|
597
|
+
reason?: string;
|
|
598
|
+
}
|
|
599
|
+
type RevisionEvent = "created" | "updated" | "superseded" | "soft_deleted" | "restored" | "archived" | "purged";
|
|
600
|
+
/**
|
|
601
|
+
* One recorded change to a memory.
|
|
602
|
+
*
|
|
603
|
+
* Revision 0 is the creation entry, synthesised by the server. `actor` is `null`
|
|
604
|
+
* for changes made by background workers, which have no request behind them —
|
|
605
|
+
* that is expected rather than missing data.
|
|
606
|
+
*/
|
|
607
|
+
interface RevisionEntry {
|
|
608
|
+
revision: number;
|
|
609
|
+
event: RevisionEvent;
|
|
610
|
+
changedFields: string[];
|
|
611
|
+
diff: Record<string, {
|
|
612
|
+
old?: unknown;
|
|
613
|
+
new?: unknown;
|
|
614
|
+
}>;
|
|
615
|
+
actor: string | null;
|
|
616
|
+
createdAt: string;
|
|
617
|
+
}
|
|
618
|
+
interface HistoryResponse {
|
|
619
|
+
memoryId: number;
|
|
620
|
+
total: number;
|
|
621
|
+
revisions: RevisionEntry[];
|
|
622
|
+
/**
|
|
623
|
+
* The fields changes are recorded for. Worth reading: only user-meaningful
|
|
624
|
+
* fields are tracked, so without this you cannot tell "nothing changed" from
|
|
625
|
+
* "that change is not recorded".
|
|
626
|
+
*/
|
|
627
|
+
trackedFields: string[];
|
|
628
|
+
}
|
|
629
|
+
type FeedbackSignal = "positive" | "negative" | "retrieved" | "ignored";
|
|
630
|
+
interface FeedbackTrend {
|
|
631
|
+
momentum: string;
|
|
632
|
+
consistency: number;
|
|
633
|
+
trendMultiplier: number;
|
|
634
|
+
recentCount: number;
|
|
635
|
+
}
|
|
636
|
+
interface FeedbackSummary {
|
|
637
|
+
totalSignals: number;
|
|
638
|
+
signalCounts: Record<string, number>;
|
|
639
|
+
trend: FeedbackTrend;
|
|
640
|
+
}
|
|
641
|
+
interface FeedbackResponse {
|
|
642
|
+
memoryId: number;
|
|
643
|
+
signal: FeedbackSignal;
|
|
644
|
+
importanceBefore: number;
|
|
645
|
+
importanceAfter: number;
|
|
646
|
+
/** Delta actually applied. `0` when ranking influence is off, or when the change was clamped at the bounds. */
|
|
647
|
+
adjustment: number;
|
|
648
|
+
/** Whether this signal was allowed to change ranking. Reported, not assumed. */
|
|
649
|
+
influencedRanking: boolean;
|
|
650
|
+
summary: FeedbackSummary;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The memory vocabulary in effect for an organization.
|
|
654
|
+
*
|
|
655
|
+
* The built-in types are a floor: they always apply and cannot be removed,
|
|
656
|
+
* because dropping a type would leave memories already filed under it invisible
|
|
657
|
+
* to any typed retrieval. Only `custom*` entries are removable.
|
|
658
|
+
*/
|
|
659
|
+
interface Ontology {
|
|
660
|
+
contentTypes: string[];
|
|
661
|
+
relationTypes: string[];
|
|
662
|
+
builtinContentTypes: string[];
|
|
663
|
+
builtinRelationTypes: string[];
|
|
664
|
+
customContentTypes: string[];
|
|
665
|
+
customRelationTypes: string[];
|
|
666
|
+
maxCustomTypes: number;
|
|
667
|
+
}
|
|
668
|
+
interface OntologyUpdateRequest {
|
|
669
|
+
contentTypes?: string[];
|
|
670
|
+
relationTypes?: string[];
|
|
671
|
+
}
|
|
672
|
+
interface UploadRequest {
|
|
673
|
+
/** File contents. A `Blob`/`File` in browsers and Node 18+, or a `Uint8Array`. */
|
|
674
|
+
file: Blob | Uint8Array;
|
|
675
|
+
/** Required: the server picks its parser from the extension. */
|
|
676
|
+
filename: string;
|
|
677
|
+
contentType?: string;
|
|
678
|
+
source?: string;
|
|
679
|
+
metadata?: Record<string, unknown>;
|
|
680
|
+
endUserId?: string;
|
|
681
|
+
}
|
|
549
682
|
declare class MemorySyncClient {
|
|
550
683
|
private readonly apiKey;
|
|
551
684
|
private readonly baseUrl;
|
|
@@ -564,11 +697,179 @@ declare class MemorySyncClient {
|
|
|
564
697
|
query(req: QueryRequest): Promise<QueryResponse>;
|
|
565
698
|
get(memoryId: number): Promise<MemoryRecord>;
|
|
566
699
|
update(memoryId: number, req: UpdateRequest): Promise<MemoryRecord>;
|
|
700
|
+
/**
|
|
701
|
+
* Delete memories, either by id or by filter. Returns the deleted ids.
|
|
702
|
+
*
|
|
703
|
+
* Accepts the legacy positional form `forget([1,2], "reason")` as well as
|
|
704
|
+
* `forget({ filters, dryRun })`. The positional form is kept because it ships
|
|
705
|
+
* in 1.1.x and removing it would break installed callers for no benefit.
|
|
706
|
+
*
|
|
707
|
+
* Exactly one selector. Passing both is rejected rather than resolved by a
|
|
708
|
+
* precedence rule, because getting that wrong on a delete cannot be undone.
|
|
709
|
+
* Deletion is scoped to the calling end user, so a filter never reaches
|
|
710
|
+
* another end user's memories — including the organisation's connector history.
|
|
711
|
+
*/
|
|
712
|
+
forget(request: ForgetRequest): Promise<number[]>;
|
|
567
713
|
forget(memoryIds: number[], reason?: string): Promise<number[]>;
|
|
714
|
+
/**
|
|
715
|
+
* Delete every memory belonging to the calling end user.
|
|
716
|
+
*
|
|
717
|
+
* Separate from {@link forget} on purpose: this reads like what it does, so a
|
|
718
|
+
* whole-namespace delete can never be the accidental result of an empty filter.
|
|
719
|
+
*/
|
|
720
|
+
purgeUser(): Promise<Record<string, unknown>>;
|
|
568
721
|
summarize(req: SummarizeRequest): Promise<MemoryRecord>;
|
|
569
722
|
compose(req: ComposeRequest): Promise<ComposeResponse>;
|
|
570
723
|
exportAll(): Promise<ExportResponse>;
|
|
571
724
|
createRelation(fromMemoryId: number, req: RelationCreateRequest): Promise<RelationRecord>;
|
|
725
|
+
/**
|
|
726
|
+
* Ingest a document and store the memories extracted from its text.
|
|
727
|
+
*
|
|
728
|
+
* Accepts the formats the connectors accept — PDF, DOCX, PPTX, XLSX, CSV,
|
|
729
|
+
* text, Markdown, HTML, source code, and images/audio/video where
|
|
730
|
+
* transcription is configured.
|
|
731
|
+
*
|
|
732
|
+
* Billed as an add, one unit per memory created. Resolves to the first stored
|
|
733
|
+
* memory, or an {@link AddSkippedResponse} when the file yielded nothing worth
|
|
734
|
+
* keeping — a blank scan, a sheet of empty cells, or content the extractor
|
|
735
|
+
* judges trivial are all normal outcomes rather than errors.
|
|
736
|
+
*/
|
|
737
|
+
upload(req: UploadRequest): Promise<AddResponse>;
|
|
738
|
+
/**
|
|
739
|
+
* Apply many metadata edits in one request.
|
|
740
|
+
*
|
|
741
|
+
* Editable: `tags`, `importance`, `metadata`, `source`, `eventType`. A memory's
|
|
742
|
+
* text, embeddings, owner, environment and project are not editable.
|
|
743
|
+
*
|
|
744
|
+
* Applied in one transaction, so the batch either lands or it does not — but an
|
|
745
|
+
* id the caller cannot see is reported per item rather than failing the request.
|
|
746
|
+
*/
|
|
747
|
+
batchUpdate(items: BatchUpdateItem[]): Promise<BatchUpdateResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Recorded changes to one memory, oldest first.
|
|
750
|
+
*
|
|
751
|
+
* Entry 0 is the creation. Later entries carry the old and new value per field.
|
|
752
|
+
* Entries written by background workers have `actor: null`. Only
|
|
753
|
+
* user-meaningful fields are tracked; the watched list comes back in
|
|
754
|
+
* `trackedFields`.
|
|
755
|
+
*/
|
|
756
|
+
history(memoryId: number, opts?: {
|
|
757
|
+
limit?: number;
|
|
758
|
+
offset?: number;
|
|
759
|
+
}): Promise<HistoryResponse>;
|
|
760
|
+
/**
|
|
761
|
+
* Tell MemorySync whether a memory was useful.
|
|
762
|
+
*
|
|
763
|
+
* By default this moves the memory's `importance`, a weighted retrieval-ranking
|
|
764
|
+
* factor, so a memory marked useful surfaces more readily and one marked wrong
|
|
765
|
+
* surfaces less. The size of the move is adaptive: consistent signals amplify
|
|
766
|
+
* it, mixed signals damp it. Importance is clamped to [0.05, 1.0], so no run of
|
|
767
|
+
* negative feedback can make a memory permanently unreachable. Not billed.
|
|
768
|
+
*/
|
|
769
|
+
feedback(memoryId: number, signal: FeedbackSignal, opts?: {
|
|
770
|
+
comment?: string;
|
|
771
|
+
}): Promise<FeedbackResponse>;
|
|
772
|
+
/** The memory vocabulary in effect for this organization. */
|
|
773
|
+
getOntology(): Promise<Ontology>;
|
|
774
|
+
/**
|
|
775
|
+
* Replace this organization's *additions* to the vocabulary.
|
|
776
|
+
*
|
|
777
|
+
* The two vocabularies are independent: omit one and it is left untouched, so
|
|
778
|
+
* adding a content type cannot wipe your relation types. Pass an empty array to
|
|
779
|
+
* clear a vocabulary's custom entries. The built-in types always remain.
|
|
780
|
+
*/
|
|
781
|
+
updateOntology(req: OntologyUpdateRequest): Promise<Ontology>;
|
|
782
|
+
/**
|
|
783
|
+
* Alias of {@link query} against `/memory/retrieve`.
|
|
784
|
+
*
|
|
785
|
+
* Both paths are live, and integrators arriving from other platforms reach for
|
|
786
|
+
* `retrieve`. Identical semantics.
|
|
787
|
+
*/
|
|
788
|
+
retrieve(req: QueryRequest): Promise<QueryResponse>;
|
|
789
|
+
/**
|
|
790
|
+
* Route a question to the best knowledge source and answer from it.
|
|
791
|
+
*
|
|
792
|
+
* Returns the raw payload: the response carries routing diagnostics whose shape
|
|
793
|
+
* is richer and more volatile than an SDK should freeze into an interface.
|
|
794
|
+
*/
|
|
795
|
+
searchRouted(query: string, opts?: {
|
|
796
|
+
k?: number;
|
|
797
|
+
route?: string;
|
|
798
|
+
includeReasoning?: boolean;
|
|
799
|
+
}): Promise<Record<string, unknown>>;
|
|
800
|
+
/** Compose an answer across several memories, with citations. */
|
|
801
|
+
synthesize(opts?: {
|
|
802
|
+
query?: string;
|
|
803
|
+
memoryIds?: number[];
|
|
804
|
+
maxMemories?: number;
|
|
805
|
+
}): Promise<Record<string, unknown>>;
|
|
806
|
+
/** Re-embed this end user's memories. Returns immediately (`202`). */
|
|
807
|
+
refresh(): Promise<Record<string, unknown>>;
|
|
808
|
+
/** Nodes and typed edges for this end user's memory graph. */
|
|
809
|
+
graph(opts?: {
|
|
810
|
+
limit?: number;
|
|
811
|
+
memoryId?: number;
|
|
812
|
+
depth?: number;
|
|
813
|
+
}): Promise<Record<string, unknown>>;
|
|
814
|
+
/** Semantic clusters over this end user's memories. */
|
|
815
|
+
clusters(opts?: {
|
|
816
|
+
limit?: number;
|
|
817
|
+
}): Promise<Record<string, unknown>>;
|
|
818
|
+
/** Contradictions and open decisions detected across memories. */
|
|
819
|
+
decisions(opts?: {
|
|
820
|
+
limit?: number;
|
|
821
|
+
}): Promise<Record<string, unknown>>;
|
|
822
|
+
/** Record which side of a contradiction wins. */
|
|
823
|
+
resolveDecision(opts?: {
|
|
824
|
+
decisionId?: string;
|
|
825
|
+
winningMemoryId?: number;
|
|
826
|
+
resolution?: string;
|
|
827
|
+
note?: string;
|
|
828
|
+
}): Promise<Record<string, unknown>>;
|
|
829
|
+
/**
|
|
830
|
+
* The intelligence report: themes, entities, patterns, dual-horizon view.
|
|
831
|
+
*
|
|
832
|
+
* `scope` is explicit by design server-side — nothing is inferred, so if you do
|
|
833
|
+
* not ask for a scope you do not get it.
|
|
834
|
+
*/
|
|
835
|
+
intelligence(opts?: {
|
|
836
|
+
limit?: number;
|
|
837
|
+
scope?: string;
|
|
838
|
+
projectId?: string;
|
|
839
|
+
}): Promise<Record<string, unknown>>;
|
|
840
|
+
/** Counts and coverage for the knowledge base. */
|
|
841
|
+
knowledgeStats(): Promise<Record<string, unknown>>;
|
|
842
|
+
/** Add a conversation turn and extract memories from it. */
|
|
843
|
+
addTurn(req: {
|
|
844
|
+
tenantId: string;
|
|
845
|
+
userId: string;
|
|
846
|
+
messages: Array<Record<string, unknown>>;
|
|
847
|
+
sessionId?: string;
|
|
848
|
+
metadata?: Record<string, unknown>;
|
|
849
|
+
}): Promise<Record<string, unknown>>;
|
|
850
|
+
/**
|
|
851
|
+
* Build a prompt-ready context block for an LLM call.
|
|
852
|
+
*
|
|
853
|
+
* `types` narrows the result to those content types. Names outside the
|
|
854
|
+
* organization's vocabulary are dropped rather than rejected, so a stale client
|
|
855
|
+
* gets a narrower answer instead of an error.
|
|
856
|
+
*/
|
|
857
|
+
recall(req: {
|
|
858
|
+
tenantId: string;
|
|
859
|
+
userId: string;
|
|
860
|
+
prompt: string;
|
|
861
|
+
k?: number;
|
|
862
|
+
types?: string[];
|
|
863
|
+
}): Promise<Record<string, unknown>>;
|
|
864
|
+
/** Async ingestion status for one memory. */
|
|
865
|
+
status(memoryId: number): Promise<Record<string, unknown>>;
|
|
866
|
+
/** Page through a specific end user's memories. */
|
|
867
|
+
listMemories(req: {
|
|
868
|
+
tenantId: string;
|
|
869
|
+
userId: string;
|
|
870
|
+
limit?: number;
|
|
871
|
+
offset?: number;
|
|
872
|
+
}): Promise<Record<string, unknown>>;
|
|
572
873
|
}
|
|
573
874
|
|
|
574
|
-
export { type AddRequest, type AddResponse, type AddSkippedResponse, type ApiKeyTestResponse, type ApiKeyTestStatus, type AuditActor, type AuditEvent, type AuditEventListResponse, type AuditEventQuery, type AuditResource, type AuditSortDirection, AuthError, type BulkAddItem, type BulkAddItemResult, type BulkAddResponse, type BulkRevokeApiKeyResult, type BulkRevokeApiKeysRequest, type BulkRevokeApiKeysResponse, type ComposeRequest, type ComposeResponse, ControlPlaneClient, type ControlPlaneConfig, type ControlPlaneRequestOptions, type CreateOrganizationRequest, type CreateWebhookRequest, type CreatedWebhook, type CurrentPlanResponse, type ExportResponse, type Integration, type IntegrationQuery, type LoginRequest, type LoginResponse, type MemoryRecord, MemorySyncClient, type MemorySyncConfig, MemorySyncError, NotFoundError, type OrganizationMembership, type OrganizationSettings, type OrganizationSettingsQuery, type Plan, type PlanLimits, type Project, type QueryFilters, type QueryRequest, type QueryResponse, RateLimitError, type RelationCreateRequest, type RelationRecord, type RelationshipType, type ReplayWebhookDeliveriesRequest, type ReplayWebhookDeliveriesResponse, ServerError, type Session, type SessionListResponse, type SummarizeRequest, type TeamMember, type TestWebhookRequest, type TestWebhookResponse, type UpdateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQuery, type WebhookListResponse, type WebhookRetryConfig, type WebhookSignatureConfig };
|
|
875
|
+
export { type AddRequest, type AddResponse, type AddSkippedResponse, type ApiKeyTestResponse, type ApiKeyTestStatus, type AuditActor, type AuditEvent, type AuditEventListResponse, type AuditEventQuery, type AuditResource, type AuditSortDirection, AuthError, type BatchUpdateItem, type BatchUpdateItemResult, type BatchUpdateResponse, type BulkAddItem, type BulkAddItemResult, type BulkAddResponse, type BulkRevokeApiKeyResult, type BulkRevokeApiKeysRequest, type BulkRevokeApiKeysResponse, type ComposeRequest, type ComposeResponse, ControlPlaneClient, type ControlPlaneConfig, type ControlPlaneRequestOptions, type CreateOrganizationRequest, type CreateWebhookRequest, type CreatedWebhook, type CurrentPlanResponse, type ExportResponse, type FeedbackResponse, type FeedbackSignal, type FeedbackSummary, type FeedbackTrend, type ForgetFilters, type ForgetRequest, type HistoryResponse, type Integration, type IntegrationQuery, type LoginRequest, type LoginResponse, type MemoryRecord, MemorySyncClient, type MemorySyncConfig, MemorySyncError, NotFoundError, type Ontology, type OntologyUpdateRequest, type OrganizationMembership, type OrganizationSettings, type OrganizationSettingsQuery, type Plan, type PlanLimits, type Project, type QueryFilters, type QueryRequest, type QueryResponse, RateLimitError, type RelationCreateRequest, type RelationRecord, type RelationshipType, type ReplayWebhookDeliveriesRequest, type ReplayWebhookDeliveriesResponse, type RevisionEntry, type RevisionEvent, ServerError, type Session, type SessionListResponse, type SummarizeRequest, type TeamMember, type TestWebhookRequest, type TestWebhookResponse, type UpdateRequest, type UpdateWebhookRequest, type UploadRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQuery, type WebhookListResponse, type WebhookRetryConfig, type WebhookSignatureConfig };
|