memorysync-sdk 1.1.1 → 1.3.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 CHANGED
@@ -26,6 +26,296 @@ declare class ServerError extends MemorySyncError {
26
26
  constructor(message: string, options?: ErrorOptions);
27
27
  }
28
28
 
29
+ /**
30
+ * Connector namespaces — `client.connections`, `client.objects` and friends.
31
+ *
32
+ * Covers the connector API: creating and managing connections to Slack, Google
33
+ * Drive, S3 and Granola, driving syncs, and inspecting the objects a sync
34
+ * produced. Shaped after `client.connections.*` in comparable SDKs so the layout
35
+ * is familiar.
36
+ *
37
+ * ## Why these return raw payloads
38
+ *
39
+ * Connector responses are large, provider-shaped and still moving — a Slack
40
+ * channel listing looks nothing like an S3 prefix listing, and both carry
41
+ * provider fields that change when the provider changes. Freezing them into
42
+ * interfaces would mean an SDK release every time a provider adds a field, and
43
+ * callers unable to see the new field until then. Typed models are reserved for
44
+ * the small, stable, first-party shapes (memories, history, feedback, ontology).
45
+ */
46
+ /** The client's request function, injected so namespaces carry no transport. */
47
+ type RequestFn = <T>(method: string, path: string, options?: {
48
+ body?: unknown;
49
+ query?: Record<string, unknown>;
50
+ }) => Promise<T>;
51
+ type Json = Record<string, unknown>;
52
+ declare class Namespace {
53
+ protected readonly req: RequestFn;
54
+ constructor(request: RequestFn);
55
+ }
56
+ /** Slack connection settings. */
57
+ declare class SlackNamespace extends Namespace {
58
+ /**
59
+ * Channels the app can see and could be added.
60
+ *
61
+ * Private channels appear only where the deployment allows them *and* a human
62
+ * has invited the app, so this never widens what someone already granted.
63
+ */
64
+ availableChannels(connectionId: string, query?: Json): Promise<Json>;
65
+ /** Channels currently selected for syncing. */
66
+ channels(connectionId: string): Promise<Json>;
67
+ /** Select channels for syncing. */
68
+ addChannels(connectionId: string, channelIds: string[]): Promise<Json>;
69
+ /** Stop syncing one channel. */
70
+ removeChannel(connectionId: string, channelId: string): Promise<Json>;
71
+ /**
72
+ * Channels this connection will never sync.
73
+ *
74
+ * The deployment-wide floor cannot be removed here; a tenant may only add to it.
75
+ */
76
+ exclusionPolicy(connectionId: string): Promise<Json>;
77
+ /** Replace this connection's additions to the exclusion policy. */
78
+ setExclusionPolicy(connectionId: string, policy: Json): Promise<Json>;
79
+ /** Slack users seen on this connection and who they map to. */
80
+ identities(connectionId: string): Promise<Json>;
81
+ /** Map a Slack user to a MemorySync end user. */
82
+ linkIdentity(connectionId: string, body: Json): Promise<Json>;
83
+ /** Re-read the Slack member list and refresh the identity table. */
84
+ syncIdentities(connectionId: string): Promise<Json>;
85
+ }
86
+ /** Google Drive connection settings. */
87
+ declare class GoogleDriveNamespace extends Namespace {
88
+ /** Config for rendering Google's own file picker in your UI. */
89
+ pickerConfig(connectionId: string): Promise<Json>;
90
+ /** Files and folders selected for syncing. */
91
+ resources(connectionId: string, query?: Json): Promise<Json>;
92
+ /** Select files or folders for syncing. */
93
+ addResources(connectionId: string, body: Json): Promise<Json>;
94
+ /** Stop syncing one file or folder. */
95
+ removeResource(connectionId: string, resourceId: string): Promise<Json>;
96
+ }
97
+ /** S3 connection settings. */
98
+ declare class S3Namespace extends Namespace {
99
+ /** Prefixes visible in the bucket that could be added. */
100
+ availablePrefixes(connectionId: string, query?: Json): Promise<Json>;
101
+ /** Prefixes currently selected for syncing. */
102
+ prefixes(connectionId: string): Promise<Json>;
103
+ /** Select prefixes for syncing. */
104
+ addPrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
105
+ /**
106
+ * Stop syncing the given prefixes.
107
+ *
108
+ * The prefixes travel in the body rather than the path because they contain
109
+ * slashes, which is why this DELETE carries one.
110
+ */
111
+ removePrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
112
+ /** Keys and patterns this connection will never sync. */
113
+ exclusionPolicy(connectionId: string): Promise<Json>;
114
+ /** Replace this connection's additions to the exclusion policy. */
115
+ setExclusionPolicy(connectionId: string, policy: Json): Promise<Json>;
116
+ /** Effective S3 settings, including the per-object size ceiling. */
117
+ settings(connectionId: string): Promise<Json>;
118
+ }
119
+ /** Granola connection settings. */
120
+ declare class GranolaNamespace extends Namespace {
121
+ /** Folders that could be added. */
122
+ availableFolders(connectionId: string, query?: Json): Promise<Json>;
123
+ /** Folders currently selected for syncing. */
124
+ folders(connectionId: string): Promise<Json>;
125
+ /** Select folders for syncing. */
126
+ addFolders(connectionId: string, body: Json): Promise<Json>;
127
+ /** Stop syncing one folder. */
128
+ removeFolder(connectionId: string, folderId: string): Promise<Json>;
129
+ /** Folders and meetings this connection will never sync. */
130
+ exclusionPolicy(connectionId: string): Promise<Json>;
131
+ /** Replace this connection's additions to the exclusion policy. */
132
+ setExclusionPolicy(connectionId: string, policy: Json): Promise<Json>;
133
+ /** Meeting participants seen on this connection and who they map to. */
134
+ identities(connectionId: string): Promise<Json>;
135
+ /** Map a participant to a MemorySync end user. */
136
+ linkIdentity(connectionId: string, body: Json): Promise<Json>;
137
+ /** Move an existing mapping to a different end user. */
138
+ relinkIdentity(connectionId: string, body: Json): Promise<Json>;
139
+ /** Effective Granola settings for this connection. */
140
+ settings(connectionId: string): Promise<Json>;
141
+ /** Update Granola settings for this connection. */
142
+ setSettings(connectionId: string, settings: Json): Promise<Json>;
143
+ }
144
+ /** Starting an OAuth connection. */
145
+ declare class ConnectionOAuthNamespace extends Namespace {
146
+ /**
147
+ * Begin an OAuth connection and get the URL to send the user to.
148
+ *
149
+ * The user completes consent in a browser and the provider calls the platform
150
+ * back — not your backend. Poll {@link status} to find out how it went.
151
+ */
152
+ initiate(provider: string, body?: Json): Promise<Json>;
153
+ /** Where an in-flight OAuth connection got to. */
154
+ status(query?: Json): Promise<Json>;
155
+ }
156
+ /**
157
+ * Connections to external sources.
158
+ *
159
+ * Provider-specific settings live in sub-namespaces: `connections.slack`,
160
+ * `connections.gdrive`, `connections.s3`, `connections.granola`.
161
+ */
162
+ declare class ConnectionsNamespace extends Namespace {
163
+ readonly slack: SlackNamespace;
164
+ readonly gdrive: GoogleDriveNamespace;
165
+ readonly s3: S3Namespace;
166
+ readonly granola: GranolaNamespace;
167
+ readonly oauth: ConnectionOAuthNamespace;
168
+ constructor(request: RequestFn);
169
+ /** Every connection in this organization. */
170
+ list(query?: Json): Promise<Json>;
171
+ /** One connection, including its status and last sync. */
172
+ get(connectionId: string): Promise<Json>;
173
+ /** Connect a provider that authenticates with an API key or bot token. */
174
+ createWithApiKey(provider: string, apiKey: string, body?: Json): Promise<Json>;
175
+ /** Connect a provider that needs a credential bundle, such as S3 keys. */
176
+ createWithCredentials(provider: string, credentials: Json, body?: Json): Promise<Json>;
177
+ /** Change a connection's name, schedule or settings. */
178
+ update(connectionId: string, body: Json): Promise<Json>;
179
+ /**
180
+ * Remove a connection.
181
+ *
182
+ * Stops future syncing. Memories already extracted are left in place — use
183
+ * {@link purge} for those, so disconnecting never silently deletes knowledge
184
+ * someone still depends on.
185
+ */
186
+ delete(connectionId: string): Promise<Json>;
187
+ /** Re-authorise a connection whose credentials expired or were revoked. */
188
+ reconnect(connectionId: string, body?: Json): Promise<Json>;
189
+ /**
190
+ * Delete the memories this connection produced.
191
+ *
192
+ * Separate from {@link delete} on purpose: removing a connection and removing
193
+ * what it taught you are different decisions.
194
+ */
195
+ purge(connectionId: string, body?: Json): Promise<Json>;
196
+ /** Current and recent sync state for a connection. */
197
+ syncStatus(connectionId: string): Promise<Json>;
198
+ /** Start a sync now instead of waiting for the schedule. */
199
+ triggerSync(connectionId: string, body?: Json): Promise<Json>;
200
+ /** Objects a connection has ingested — files, messages, meetings. */
201
+ objects(connectionId: string, query?: Json): Promise<Json>;
202
+ /** Object listing with richer filtering and paging than {@link objects}. */
203
+ objectsV2(connectionId: string, query?: Json): Promise<Json>;
204
+ /** Apply one action to many objects — pause, resume, re-extract. */
205
+ bulkObjectAction(connectionId: string, body: Json): Promise<Json>;
206
+ /** Connector totals: connections, objects synced, memories produced. */
207
+ stats(query?: Json): Promise<Json>;
208
+ /** Audit trail of connector activity. */
209
+ auditLogs(query?: Json): Promise<Json>;
210
+ }
211
+ /**
212
+ * A single synced object: a Drive file, a Slack message batch, an S3 key, a
213
+ * meeting transcript.
214
+ */
215
+ declare class ObjectsNamespace extends Namespace {
216
+ /** Metadata and sync state for one object. */
217
+ get(objectId: string): Promise<Json>;
218
+ /** What extraction made of this object. */
219
+ analysis(objectId: string): Promise<Json>;
220
+ /** Every action taken on this object. */
221
+ audit(objectId: string, query?: Json): Promise<Json>;
222
+ /** Versions of this object seen across syncs. */
223
+ history(objectId: string, query?: Json): Promise<Json>;
224
+ /** Which memories this object produced, and whether extraction finished. */
225
+ memoryStatus(objectId: string): Promise<Json>;
226
+ /** Row and column statistics for spreadsheet-shaped objects. */
227
+ structuredStats(objectId: string): Promise<Json>;
228
+ /** Score this object for extraction worthiness without extracting. */
229
+ evaluate(objectId: string, body?: Json): Promise<Json>;
230
+ /** Stop re-syncing this object, leaving its memories in place. */
231
+ pause(objectId: string): Promise<Json>;
232
+ /** Resume syncing a paused object. */
233
+ resume(objectId: string): Promise<Json>;
234
+ /**
235
+ * Run extraction again over content already fetched.
236
+ *
237
+ * Counts against the plan's add allowance, exactly like the first extraction,
238
+ * because it creates memories the same way.
239
+ */
240
+ reextract(objectId: string, body?: Json): Promise<Json>;
241
+ /** Fetch this object from the provider again, then extract. */
242
+ resync(objectId: string, body?: Json): Promise<Json>;
243
+ /** Remove the memories this object produced, keeping the object record. */
244
+ deleteMemories(objectId: string, query?: Json): Promise<Json>;
245
+ }
246
+ /** Connectors this deployment supports. */
247
+ declare class ProvidersNamespace extends Namespace {
248
+ /** Every available provider and what it needs to connect. */
249
+ list(query?: Json): Promise<Json>;
250
+ /** One provider's capabilities, scopes and settings schema. */
251
+ get(providerId: string): Promise<Json>;
252
+ }
253
+ /** Individual sync runs. */
254
+ declare class SyncJobsNamespace extends Namespace {
255
+ /** Progress and outcome of one sync run. */
256
+ get(jobId: string): Promise<Json>;
257
+ /** Stop a running sync. Objects already ingested are kept. */
258
+ cancel(jobId: string, body?: Json): Promise<Json>;
259
+ }
260
+ /** Turn websites into memories. */
261
+ declare class WebCrawlerNamespace extends Namespace {
262
+ /** Check a URL is reachable and crawlable before committing to a job. */
263
+ validate(url: string, body?: Json): Promise<Json>;
264
+ /**
265
+ * Start a crawl. Returns a job to poll.
266
+ *
267
+ * Crawling only fetches and stores page content. Nothing becomes a memory until
268
+ * you call {@link importJob}, so a large crawl cannot quietly consume your add
269
+ * allowance.
270
+ */
271
+ crawl(url: string, body?: Json): Promise<Json>;
272
+ /** Crawl jobs for this organization. */
273
+ jobs(query?: Json): Promise<Json>;
274
+ /** One crawl job's status and progress. */
275
+ job(jobId: string): Promise<Json>;
276
+ /** Stop a running crawl. Pages already fetched are kept. */
277
+ cancelJob(jobId: string): Promise<Json>;
278
+ /** Delete a crawl job and its fetched pages. */
279
+ deleteJob(jobId: string): Promise<Json>;
280
+ /** Pages a crawl fetched, before any import. */
281
+ jobContent(jobId: string, query?: Json): Promise<Json>;
282
+ /** Page counts, byte totals and error breakdown for a crawl. */
283
+ jobStatistics(jobId: string): Promise<Json>;
284
+ /**
285
+ * Turn a completed crawl's pages into memories.
286
+ *
287
+ * This is the step that creates memories, so this is the step that is billed —
288
+ * one unit per memory created, like every other ingestion path.
289
+ */
290
+ importJob(jobId: string, body?: Json): Promise<Json>;
291
+ /** Crawls running right now. */
292
+ active(): Promise<Json>;
293
+ /** Crawler limits in force: depth, page ceiling, rate, timeouts. */
294
+ config(): Promise<Json>;
295
+ }
296
+ /**
297
+ * The `/api/v1/integrations` surface.
298
+ *
299
+ * Kept because the catalog and the web crawler live here and have no v2
300
+ * equivalent. For connection lifecycle use `client.connections`, which is the
301
+ * current API — `connected()` and `stats()` here are older, thinner views of the
302
+ * same data.
303
+ */
304
+ declare class IntegrationsNamespace extends Namespace {
305
+ readonly webCrawler: WebCrawlerNamespace;
306
+ constructor(request: RequestFn);
307
+ /** Every integration this deployment offers, for building a picker UI. */
308
+ catalog(query?: Json): Promise<Json>;
309
+ /** Integrations currently connected. Older view of `connections.list()`. */
310
+ connected(query?: Json): Promise<Json>;
311
+ /** Legacy integration counters. Prefer `connections.stats()`. */
312
+ stats(query?: Json): Promise<Json>;
313
+ /** Update a legacy integration record. */
314
+ update(integrationId: string, body: Json): Promise<Json>;
315
+ /** Delete a legacy integration record. */
316
+ delete(integrationId: string): Promise<Json>;
317
+ }
318
+
29
319
  interface ControlPlaneConfig {
30
320
  baseUrl: string;
31
321
  accessToken?: string;
@@ -546,6 +836,140 @@ interface ExportResponse {
546
836
  generatedAt: string;
547
837
  }
548
838
 
839
+ /** One edit inside a {@link MemorySyncClient.batchUpdate} call. */
840
+ interface BatchUpdateItem {
841
+ memoryId: number;
842
+ tags?: string[];
843
+ importance?: number;
844
+ metadata?: Record<string, unknown>;
845
+ source?: string;
846
+ eventType?: string;
847
+ }
848
+ interface BatchUpdateItemResult {
849
+ index: number;
850
+ memoryId: number;
851
+ status: "updated" | "not_found";
852
+ changedFields: string[];
853
+ }
854
+ /**
855
+ * Result of a batch update.
856
+ *
857
+ * The server answers `207 Multi-Status`: a batch may legitimately name a memory
858
+ * the caller cannot see, and the caller needs to know which one rather than
859
+ * losing the whole request. `notFound` is an ordinary outcome, not an error.
860
+ */
861
+ interface BatchUpdateResponse {
862
+ total: number;
863
+ updated: number;
864
+ notFound: number;
865
+ results: BatchUpdateItemResult[];
866
+ }
867
+ /**
868
+ * Criteria for a filter-based delete.
869
+ *
870
+ * At least one field must be set — an all-empty filter would mean "delete
871
+ * everything I own", which has to be an explicit `purgeUser()` call instead.
872
+ * `tags` matches memories carrying **all** the listed tags, not any of them.
873
+ */
874
+ interface ForgetFilters {
875
+ source?: string;
876
+ eventType?: string;
877
+ tags?: string[];
878
+ tier?: string;
879
+ before?: string;
880
+ after?: string;
881
+ }
882
+ interface ForgetRequest {
883
+ memoryIds?: number[];
884
+ filters?: ForgetFilters;
885
+ /** Return the ids that *would* be deleted without deleting anything. */
886
+ dryRun?: boolean;
887
+ reason?: string;
888
+ }
889
+ type RevisionEvent = "created" | "updated" | "superseded" | "soft_deleted" | "restored" | "archived" | "purged";
890
+ /**
891
+ * One recorded change to a memory.
892
+ *
893
+ * Revision 0 is the creation entry, synthesised by the server. `actor` is `null`
894
+ * for changes made by background workers, which have no request behind them —
895
+ * that is expected rather than missing data.
896
+ */
897
+ interface RevisionEntry {
898
+ revision: number;
899
+ event: RevisionEvent;
900
+ changedFields: string[];
901
+ diff: Record<string, {
902
+ old?: unknown;
903
+ new?: unknown;
904
+ }>;
905
+ actor: string | null;
906
+ createdAt: string;
907
+ }
908
+ interface HistoryResponse {
909
+ memoryId: number;
910
+ total: number;
911
+ revisions: RevisionEntry[];
912
+ /**
913
+ * The fields changes are recorded for. Worth reading: only user-meaningful
914
+ * fields are tracked, so without this you cannot tell "nothing changed" from
915
+ * "that change is not recorded".
916
+ */
917
+ trackedFields: string[];
918
+ }
919
+ type FeedbackSignal = "positive" | "negative" | "retrieved" | "ignored";
920
+ interface FeedbackTrend {
921
+ momentum: string;
922
+ consistency: number;
923
+ trendMultiplier: number;
924
+ recentCount: number;
925
+ }
926
+ interface FeedbackSummary {
927
+ totalSignals: number;
928
+ signalCounts: Record<string, number>;
929
+ trend: FeedbackTrend;
930
+ }
931
+ interface FeedbackResponse {
932
+ memoryId: number;
933
+ signal: FeedbackSignal;
934
+ importanceBefore: number;
935
+ importanceAfter: number;
936
+ /** Delta actually applied. `0` when ranking influence is off, or when the change was clamped at the bounds. */
937
+ adjustment: number;
938
+ /** Whether this signal was allowed to change ranking. Reported, not assumed. */
939
+ influencedRanking: boolean;
940
+ summary: FeedbackSummary;
941
+ }
942
+ /**
943
+ * The memory vocabulary in effect for an organization.
944
+ *
945
+ * The built-in types are a floor: they always apply and cannot be removed,
946
+ * because dropping a type would leave memories already filed under it invisible
947
+ * to any typed retrieval. Only `custom*` entries are removable.
948
+ */
949
+ interface Ontology {
950
+ contentTypes: string[];
951
+ relationTypes: string[];
952
+ builtinContentTypes: string[];
953
+ builtinRelationTypes: string[];
954
+ customContentTypes: string[];
955
+ customRelationTypes: string[];
956
+ maxCustomTypes: number;
957
+ }
958
+ interface OntologyUpdateRequest {
959
+ contentTypes?: string[];
960
+ relationTypes?: string[];
961
+ }
962
+ interface UploadRequest {
963
+ /** File contents. A `Blob`/`File` in browsers and Node 18+, or a `Uint8Array`. */
964
+ file: Blob | Uint8Array;
965
+ /** Required: the server picks its parser from the extension. */
966
+ filename: string;
967
+ contentType?: string;
968
+ source?: string;
969
+ metadata?: Record<string, unknown>;
970
+ endUserId?: string;
971
+ }
972
+
549
973
  declare class MemorySyncClient {
550
974
  private readonly apiKey;
551
975
  private readonly baseUrl;
@@ -553,6 +977,16 @@ declare class MemorySyncClient {
553
977
  private readonly endUserId?;
554
978
  private readonly timeoutMs;
555
979
  private readonly fetchImpl;
980
+ /** Connections to external sources, with provider sub-namespaces. */
981
+ readonly connections: ConnectionsNamespace;
982
+ /** Individual objects a connector ingested. */
983
+ readonly objects: ObjectsNamespace;
984
+ /** Connectors this deployment supports. */
985
+ readonly providers: ProvidersNamespace;
986
+ /** Individual sync runs. */
987
+ readonly syncJobs: SyncJobsNamespace;
988
+ /** The legacy `/api/v1/integrations` surface, including the web crawler. */
989
+ readonly integrations: IntegrationsNamespace;
556
990
  constructor(config: MemorySyncConfig);
557
991
  private headers;
558
992
  private request;
@@ -564,11 +998,179 @@ declare class MemorySyncClient {
564
998
  query(req: QueryRequest): Promise<QueryResponse>;
565
999
  get(memoryId: number): Promise<MemoryRecord>;
566
1000
  update(memoryId: number, req: UpdateRequest): Promise<MemoryRecord>;
1001
+ /**
1002
+ * Delete memories, either by id or by filter. Returns the deleted ids.
1003
+ *
1004
+ * Accepts the legacy positional form `forget([1,2], "reason")` as well as
1005
+ * `forget({ filters, dryRun })`. The positional form is kept because it ships
1006
+ * in 1.1.x and removing it would break installed callers for no benefit.
1007
+ *
1008
+ * Exactly one selector. Passing both is rejected rather than resolved by a
1009
+ * precedence rule, because getting that wrong on a delete cannot be undone.
1010
+ * Deletion is scoped to the calling end user, so a filter never reaches
1011
+ * another end user's memories — including the organisation's connector history.
1012
+ */
1013
+ forget(request: ForgetRequest): Promise<number[]>;
567
1014
  forget(memoryIds: number[], reason?: string): Promise<number[]>;
1015
+ /**
1016
+ * Delete every memory belonging to the calling end user.
1017
+ *
1018
+ * Separate from {@link forget} on purpose: this reads like what it does, so a
1019
+ * whole-namespace delete can never be the accidental result of an empty filter.
1020
+ */
1021
+ purgeUser(): Promise<Record<string, unknown>>;
568
1022
  summarize(req: SummarizeRequest): Promise<MemoryRecord>;
569
1023
  compose(req: ComposeRequest): Promise<ComposeResponse>;
570
1024
  exportAll(): Promise<ExportResponse>;
571
1025
  createRelation(fromMemoryId: number, req: RelationCreateRequest): Promise<RelationRecord>;
1026
+ /**
1027
+ * Ingest a document and store the memories extracted from its text.
1028
+ *
1029
+ * Accepts the formats the connectors accept — PDF, DOCX, PPTX, XLSX, CSV,
1030
+ * text, Markdown, HTML, source code, and images/audio/video where
1031
+ * transcription is configured.
1032
+ *
1033
+ * Billed as an add, one unit per memory created. Resolves to the first stored
1034
+ * memory, or an {@link AddSkippedResponse} when the file yielded nothing worth
1035
+ * keeping — a blank scan, a sheet of empty cells, or content the extractor
1036
+ * judges trivial are all normal outcomes rather than errors.
1037
+ */
1038
+ upload(req: UploadRequest): Promise<AddResponse>;
1039
+ /**
1040
+ * Apply many metadata edits in one request.
1041
+ *
1042
+ * Editable: `tags`, `importance`, `metadata`, `source`, `eventType`. A memory's
1043
+ * text, embeddings, owner, environment and project are not editable.
1044
+ *
1045
+ * Applied in one transaction, so the batch either lands or it does not — but an
1046
+ * id the caller cannot see is reported per item rather than failing the request.
1047
+ */
1048
+ batchUpdate(items: BatchUpdateItem[]): Promise<BatchUpdateResponse>;
1049
+ /**
1050
+ * Recorded changes to one memory, oldest first.
1051
+ *
1052
+ * Entry 0 is the creation. Later entries carry the old and new value per field.
1053
+ * Entries written by background workers have `actor: null`. Only
1054
+ * user-meaningful fields are tracked; the watched list comes back in
1055
+ * `trackedFields`.
1056
+ */
1057
+ history(memoryId: number, opts?: {
1058
+ limit?: number;
1059
+ offset?: number;
1060
+ }): Promise<HistoryResponse>;
1061
+ /**
1062
+ * Tell MemorySync whether a memory was useful.
1063
+ *
1064
+ * By default this moves the memory's `importance`, a weighted retrieval-ranking
1065
+ * factor, so a memory marked useful surfaces more readily and one marked wrong
1066
+ * surfaces less. The size of the move is adaptive: consistent signals amplify
1067
+ * it, mixed signals damp it. Importance is clamped to [0.05, 1.0], so no run of
1068
+ * negative feedback can make a memory permanently unreachable. Not billed.
1069
+ */
1070
+ feedback(memoryId: number, signal: FeedbackSignal, opts?: {
1071
+ comment?: string;
1072
+ }): Promise<FeedbackResponse>;
1073
+ /** The memory vocabulary in effect for this organization. */
1074
+ getOntology(): Promise<Ontology>;
1075
+ /**
1076
+ * Replace this organization's *additions* to the vocabulary.
1077
+ *
1078
+ * The two vocabularies are independent: omit one and it is left untouched, so
1079
+ * adding a content type cannot wipe your relation types. Pass an empty array to
1080
+ * clear a vocabulary's custom entries. The built-in types always remain.
1081
+ */
1082
+ updateOntology(req: OntologyUpdateRequest): Promise<Ontology>;
1083
+ /**
1084
+ * Alias of {@link query} against `/memory/retrieve`.
1085
+ *
1086
+ * Both paths are live, and integrators arriving from other platforms reach for
1087
+ * `retrieve`. Identical semantics.
1088
+ */
1089
+ retrieve(req: QueryRequest): Promise<QueryResponse>;
1090
+ /**
1091
+ * Route a question to the best knowledge source and answer from it.
1092
+ *
1093
+ * Returns the raw payload: the response carries routing diagnostics whose shape
1094
+ * is richer and more volatile than an SDK should freeze into an interface.
1095
+ */
1096
+ searchRouted(query: string, opts?: {
1097
+ k?: number;
1098
+ route?: string;
1099
+ includeReasoning?: boolean;
1100
+ }): Promise<Record<string, unknown>>;
1101
+ /** Compose an answer across several memories, with citations. */
1102
+ synthesize(opts?: {
1103
+ query?: string;
1104
+ memoryIds?: number[];
1105
+ maxMemories?: number;
1106
+ }): Promise<Record<string, unknown>>;
1107
+ /** Re-embed this end user's memories. Returns immediately (`202`). */
1108
+ refresh(): Promise<Record<string, unknown>>;
1109
+ /** Nodes and typed edges for this end user's memory graph. */
1110
+ graph(opts?: {
1111
+ limit?: number;
1112
+ memoryId?: number;
1113
+ depth?: number;
1114
+ }): Promise<Record<string, unknown>>;
1115
+ /** Semantic clusters over this end user's memories. */
1116
+ clusters(opts?: {
1117
+ limit?: number;
1118
+ }): Promise<Record<string, unknown>>;
1119
+ /** Contradictions and open decisions detected across memories. */
1120
+ decisions(opts?: {
1121
+ limit?: number;
1122
+ }): Promise<Record<string, unknown>>;
1123
+ /** Record which side of a contradiction wins. */
1124
+ resolveDecision(opts?: {
1125
+ decisionId?: string;
1126
+ winningMemoryId?: number;
1127
+ resolution?: string;
1128
+ note?: string;
1129
+ }): Promise<Record<string, unknown>>;
1130
+ /**
1131
+ * The intelligence report: themes, entities, patterns, dual-horizon view.
1132
+ *
1133
+ * `scope` is explicit by design server-side — nothing is inferred, so if you do
1134
+ * not ask for a scope you do not get it.
1135
+ */
1136
+ intelligence(opts?: {
1137
+ limit?: number;
1138
+ scope?: string;
1139
+ projectId?: string;
1140
+ }): Promise<Record<string, unknown>>;
1141
+ /** Counts and coverage for the knowledge base. */
1142
+ knowledgeStats(): Promise<Record<string, unknown>>;
1143
+ /** Add a conversation turn and extract memories from it. */
1144
+ addTurn(req: {
1145
+ tenantId: string;
1146
+ userId: string;
1147
+ messages: Array<Record<string, unknown>>;
1148
+ sessionId?: string;
1149
+ metadata?: Record<string, unknown>;
1150
+ }): Promise<Record<string, unknown>>;
1151
+ /**
1152
+ * Build a prompt-ready context block for an LLM call.
1153
+ *
1154
+ * `types` narrows the result to those content types. Names outside the
1155
+ * organization's vocabulary are dropped rather than rejected, so a stale client
1156
+ * gets a narrower answer instead of an error.
1157
+ */
1158
+ recall(req: {
1159
+ tenantId: string;
1160
+ userId: string;
1161
+ prompt: string;
1162
+ k?: number;
1163
+ types?: string[];
1164
+ }): Promise<Record<string, unknown>>;
1165
+ /** Async ingestion status for one memory. */
1166
+ status(memoryId: number): Promise<Record<string, unknown>>;
1167
+ /** Page through a specific end user's memories. */
1168
+ listMemories(req: {
1169
+ tenantId: string;
1170
+ userId: string;
1171
+ limit?: number;
1172
+ offset?: number;
1173
+ }): Promise<Record<string, unknown>>;
572
1174
  }
573
1175
 
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 };
1176
+ 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, ConnectionOAuthNamespace, ConnectionsNamespace, 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, GoogleDriveNamespace, GranolaNamespace, type HistoryResponse, type Integration, type IntegrationQuery, IntegrationsNamespace, type LoginRequest, type LoginResponse, type MemoryRecord, MemorySyncClient, type MemorySyncConfig, MemorySyncError, NotFoundError, ObjectsNamespace, type Ontology, type OntologyUpdateRequest, type OrganizationMembership, type OrganizationSettings, type OrganizationSettingsQuery, type Plan, type PlanLimits, type Project, ProvidersNamespace, type QueryFilters, type QueryRequest, type QueryResponse, RateLimitError, type RelationCreateRequest, type RelationRecord, type RelationshipType, type ReplayWebhookDeliveriesRequest, type ReplayWebhookDeliveriesResponse, type RevisionEntry, type RevisionEvent, S3Namespace, ServerError, type Session, type SessionListResponse, SlackNamespace, type SummarizeRequest, SyncJobsNamespace, type TeamMember, type TestWebhookRequest, type TestWebhookResponse, type UpdateRequest, type UpdateWebhookRequest, type UploadRequest, ValidationError, WebCrawlerNamespace, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQuery, type WebhookListResponse, type WebhookRetryConfig, type WebhookSignatureConfig };