@memnexus-ai/sdk 1.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,3004 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ MemNexus: () => MemNexus,
24
+ SdkError: () => SdkError
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/http.ts
29
+ var RETRY_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
30
+ var MAX_ATTEMPTS = 5;
31
+ var BASE_DELAY_MS = 500;
32
+ var MAX_DELAY_MS = 1e4;
33
+ var BACKOFF_FACTOR = 2;
34
+ var SdkError = class extends Error {
35
+ status;
36
+ statusText;
37
+ data;
38
+ constructor(status, statusText, data) {
39
+ super(`HTTP ${status}: ${statusText}`);
40
+ this.name = "SdkError";
41
+ this.status = status;
42
+ this.statusText = statusText;
43
+ this.data = data;
44
+ }
45
+ };
46
+ function computeDelay(attempt) {
47
+ const delay = BASE_DELAY_MS * Math.pow(BACKOFF_FACTOR, attempt - 1);
48
+ return Math.min(delay, MAX_DELAY_MS);
49
+ }
50
+ function sleep(ms) {
51
+ return new Promise((resolve) => setTimeout(resolve, ms));
52
+ }
53
+ function buildUrl(baseUrl, path, pathParams, queryParams) {
54
+ let url = path;
55
+ for (const [key, value] of Object.entries(pathParams)) {
56
+ url = url.replace(`{${key}}`, encodeURIComponent(String(value)));
57
+ }
58
+ const full = `${baseUrl.replace(/\/+$/, "")}${url}`;
59
+ if (!queryParams) return full;
60
+ const qs = new URLSearchParams();
61
+ for (const [key, value] of Object.entries(queryParams)) {
62
+ if (value !== null && value !== void 0) {
63
+ qs.set(key, String(value));
64
+ }
65
+ }
66
+ const qsStr = qs.toString();
67
+ return qsStr ? `${full}?${qsStr}` : full;
68
+ }
69
+ async function parseBody(response) {
70
+ const ct = response.headers.get("content-type") ?? "";
71
+ if (ct.includes("application/json") && response.body) {
72
+ try {
73
+ return await response.json();
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+ function headersToRecord(headers) {
81
+ const out = {};
82
+ headers.forEach((value, key) => {
83
+ out[key] = value;
84
+ });
85
+ return out;
86
+ }
87
+ var HttpClient = class {
88
+ apiKey;
89
+ baseUrl;
90
+ timeoutMs;
91
+ constructor(options = {}) {
92
+ const apiKey = options.apiKey ?? (typeof process !== "undefined" ? process.env["MEMNEXUS_API_KEY"] : void 0);
93
+ if (!apiKey) {
94
+ throw new Error(
95
+ "apiKey is required. Pass it in options or set the MEMNEXUS_API_KEY environment variable."
96
+ );
97
+ }
98
+ this.apiKey = apiKey;
99
+ this.baseUrl = options.baseUrl ?? "https://api.memnexus.ai";
100
+ this.timeoutMs = options.timeoutMs ?? 3e4;
101
+ }
102
+ async request(opts) {
103
+ const url = buildUrl(
104
+ this.baseUrl,
105
+ opts.path,
106
+ opts.pathParams ?? {},
107
+ opts.queryParams
108
+ );
109
+ const headers = {
110
+ Authorization: `Bearer ${this.apiKey}`,
111
+ "User-Agent": "memnexus-node-sdk/1.0",
112
+ ...opts.headers
113
+ };
114
+ let fetchInit = {
115
+ method: opts.method,
116
+ headers
117
+ };
118
+ if (opts.body !== void 0) {
119
+ headers["Content-Type"] = "application/json";
120
+ fetchInit = { ...fetchInit, body: JSON.stringify(opts.body) };
121
+ }
122
+ let lastError;
123
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
124
+ const controller = new AbortController();
125
+ const timerId = setTimeout(() => controller.abort(), this.timeoutMs);
126
+ try {
127
+ const response = await fetch(url, {
128
+ ...fetchInit,
129
+ signal: controller.signal
130
+ });
131
+ clearTimeout(timerId);
132
+ const data = await parseBody(response);
133
+ const respHeaders = headersToRecord(response.headers);
134
+ if (RETRY_STATUS_CODES.has(response.status) && attempt < MAX_ATTEMPTS) {
135
+ await sleep(computeDelay(attempt));
136
+ continue;
137
+ }
138
+ if (!response.ok) {
139
+ throw new SdkError(response.status, response.statusText, data);
140
+ }
141
+ return {
142
+ status: response.status,
143
+ statusText: response.statusText,
144
+ headers: respHeaders,
145
+ data
146
+ };
147
+ } catch (err) {
148
+ clearTimeout(timerId);
149
+ if (err instanceof SdkError) {
150
+ throw err;
151
+ }
152
+ lastError = err;
153
+ if (attempt < MAX_ATTEMPTS) {
154
+ await sleep(computeDelay(attempt));
155
+ }
156
+ }
157
+ }
158
+ throw lastError ?? new Error("Max retry attempts reached");
159
+ }
160
+ };
161
+
162
+ // src/services/users.ts
163
+ var Users = class {
164
+ _http;
165
+ constructor(http) {
166
+ this._http = http;
167
+ }
168
+ /**
169
+ * Sync user from WorkOS
170
+ *
171
+ * Called by the customer portal after WorkOS authentication.
172
+ * Creates a new user if they don't exist, or updates their profile if they do.
173
+ * This is the main entry point for user provisioning.
174
+ * When the invite gate is closed and a new user is created, the inviteCode
175
+ * is redeemed atomically to track which code was used for registration.
176
+ *
177
+ * @param body — Request body
178
+ */
179
+ async syncUser(body) {
180
+ const pathParams = {};
181
+ return this._http.request({
182
+ method: "POST",
183
+ path: "/api/users/sync",
184
+ pathParams,
185
+ body
186
+ });
187
+ }
188
+ /**
189
+ * Get current user
190
+ *
191
+ * Get the currently authenticated user's profile and usage information
192
+ */
193
+ async getCurrentUser() {
194
+ const pathParams = {};
195
+ return this._http.request({
196
+ method: "GET",
197
+ path: "/api/users/me",
198
+ pathParams
199
+ });
200
+ }
201
+ /**
202
+ * Update current user
203
+ *
204
+ * Update the currently authenticated user's profile
205
+ * @param options — Optional parameters
206
+ */
207
+ async updateCurrentUser(options) {
208
+ const pathParams = {};
209
+ return this._http.request({
210
+ method: "PATCH",
211
+ path: "/api/users/me",
212
+ pathParams,
213
+ body: options?.body
214
+ });
215
+ }
216
+ /**
217
+ * Get current user's usage
218
+ *
219
+ * Get the currently authenticated user's memory usage statistics
220
+ */
221
+ async getCurrentUserUsage() {
222
+ const pathParams = {};
223
+ return this._http.request({
224
+ method: "GET",
225
+ path: "/api/users/me/usage",
226
+ pathParams
227
+ });
228
+ }
229
+ /**
230
+ * Export all user data
231
+ *
232
+ * Export all user data as a JSON archive. Includes profile, memories,
233
+ * conversations, facts, and patterns. Supports GDPR Article 20
234
+ * (right to data portability). Sensitive fields (Stripe customer ID,
235
+ * WorkOS ID, embeddings) are excluded.
236
+ *
237
+ */
238
+ async exportUserData() {
239
+ const pathParams = {};
240
+ return this._http.request({
241
+ method: "GET",
242
+ path: "/api/users/me/export",
243
+ pathParams
244
+ });
245
+ }
246
+ /**
247
+ * Initiate account deletion
248
+ *
249
+ * Schedule the current user's account for deletion after a 7-day grace period.
250
+ * Requires email confirmation. Immediately revokes API keys and cancels
251
+ * any active subscription. The account enters read-only mode.
252
+ *
253
+ * @param body — Request body
254
+ */
255
+ async initiateAccountDeletion(body) {
256
+ const pathParams = {};
257
+ return this._http.request({
258
+ method: "POST",
259
+ path: "/api/users/me/deletion",
260
+ pathParams,
261
+ body
262
+ });
263
+ }
264
+ /**
265
+ * Cancel account deletion
266
+ *
267
+ * Cancel a pending account deletion during the grace period.
268
+ * Note: Previously revoked API keys are not restored — new keys must be created.
269
+ * Stripe subscription may need manual reactivation via the billing portal.
270
+ *
271
+ */
272
+ async cancelAccountDeletion() {
273
+ const pathParams = {};
274
+ return this._http.request({
275
+ method: "DELETE",
276
+ path: "/api/users/me/deletion",
277
+ pathParams
278
+ });
279
+ }
280
+ /**
281
+ * Get user by ID
282
+ *
283
+ * Get a user by their internal ID (admin only)
284
+ * @param id
285
+ */
286
+ async getUserById(id) {
287
+ const pathParams = {
288
+ "id": id
289
+ };
290
+ return this._http.request({
291
+ method: "GET",
292
+ path: "/api/users/{id}",
293
+ pathParams
294
+ });
295
+ }
296
+ };
297
+
298
+ // src/services/topics.ts
299
+ var Topics = class {
300
+ _http;
301
+ constructor(http) {
302
+ this._http = http;
303
+ }
304
+ /**
305
+ * List topics
306
+ *
307
+ * List all topics with pagination
308
+ * @param options — Optional parameters
309
+ */
310
+ async listTopics(options) {
311
+ const pathParams = {};
312
+ const queryParams = {
313
+ "limit": options?.limit,
314
+ "offset": options?.offset,
315
+ "sortBy": options?.sortBy,
316
+ "order": options?.order
317
+ };
318
+ return this._http.request({
319
+ method: "GET",
320
+ path: "/api/topics",
321
+ pathParams,
322
+ queryParams
323
+ });
324
+ }
325
+ /**
326
+ * Get topic by ID
327
+ *
328
+ * Retrieve a specific topic by its ID
329
+ * @param id — The topic ID
330
+ */
331
+ async getTopicById(id) {
332
+ const pathParams = {
333
+ "id": id
334
+ };
335
+ return this._http.request({
336
+ method: "GET",
337
+ path: "/api/topics/{id}",
338
+ pathParams
339
+ });
340
+ }
341
+ /**
342
+ * Merge topics
343
+ *
344
+ * Merge two topics into one
345
+ * @param body — Request body
346
+ */
347
+ async mergeTopics(body) {
348
+ const pathParams = {};
349
+ return this._http.request({
350
+ method: "POST",
351
+ path: "/api/topics/merge",
352
+ pathParams,
353
+ body
354
+ });
355
+ }
356
+ /**
357
+ * Discover related topics
358
+ *
359
+ * Discover topics related to a given topic
360
+ * @param body — Request body
361
+ */
362
+ async discoverRelatedTopics(body) {
363
+ const pathParams = {};
364
+ return this._http.request({
365
+ method: "POST",
366
+ path: "/api/topics/discover-related",
367
+ pathParams,
368
+ body
369
+ });
370
+ }
371
+ /**
372
+ * Calculate topic similarity
373
+ *
374
+ * Calculate similarity score between two topics
375
+ * @param body — Request body
376
+ */
377
+ async calculateTopicSimilarity(body) {
378
+ const pathParams = {};
379
+ return this._http.request({
380
+ method: "POST",
381
+ path: "/api/topics/similarity",
382
+ pathParams,
383
+ body
384
+ });
385
+ }
386
+ /**
387
+ * Find similar topics
388
+ *
389
+ * Find topics similar to a given topic
390
+ * @param body — Request body
391
+ */
392
+ async findSimilarTopics(body) {
393
+ const pathParams = {};
394
+ return this._http.request({
395
+ method: "POST",
396
+ path: "/api/topics/similar",
397
+ pathParams,
398
+ body
399
+ });
400
+ }
401
+ /**
402
+ * Cluster topics
403
+ *
404
+ * Cluster topics using community detection algorithms
405
+ * @param options — Optional parameters
406
+ */
407
+ async clusterTopics(options) {
408
+ const pathParams = {};
409
+ return this._http.request({
410
+ method: "POST",
411
+ path: "/api/topics/cluster",
412
+ pathParams,
413
+ body: options?.body
414
+ });
415
+ }
416
+ /**
417
+ * Detect communities
418
+ *
419
+ * Detect communities in the topic graph using specified algorithm
420
+ * @param options — Optional parameters
421
+ */
422
+ async detectCommunities(options) {
423
+ const pathParams = {};
424
+ return this._http.request({
425
+ method: "POST",
426
+ path: "/api/topics/detect-communities",
427
+ pathParams,
428
+ body: options?.body
429
+ });
430
+ }
431
+ /**
432
+ * Search topics
433
+ *
434
+ * Search topics by query string using fulltext search
435
+ * @param body — Request body
436
+ */
437
+ async searchTopics(body) {
438
+ const pathParams = {};
439
+ return this._http.request({
440
+ method: "POST",
441
+ path: "/api/topics/search",
442
+ pathParams,
443
+ body
444
+ });
445
+ }
446
+ };
447
+
448
+ // src/services/system.ts
449
+ var System = class {
450
+ _http;
451
+ constructor(http) {
452
+ this._http = http;
453
+ }
454
+ /**
455
+ * Get system health status
456
+ *
457
+ * Get the current health status of the system including database connectivity
458
+ */
459
+ async getSystemHealth() {
460
+ const pathParams = {};
461
+ return this._http.request({
462
+ method: "GET",
463
+ path: "/api/system/health",
464
+ pathParams
465
+ });
466
+ }
467
+ /**
468
+ * Get context status
469
+ *
470
+ * Get database statistics and context information
471
+ */
472
+ async getContextStatus() {
473
+ const pathParams = {};
474
+ return this._http.request({
475
+ method: "GET",
476
+ path: "/api/system/context/status",
477
+ pathParams
478
+ });
479
+ }
480
+ /**
481
+ * Get feature flags
482
+ *
483
+ * Get all feature flags for the authenticated user
484
+ */
485
+ async getFeatureFlags() {
486
+ const pathParams = {};
487
+ return this._http.request({
488
+ method: "GET",
489
+ path: "/api/system/feature-flags",
490
+ pathParams
491
+ });
492
+ }
493
+ /**
494
+ * Evaluate feature flag
495
+ *
496
+ * Evaluate a specific feature flag for the authenticated user
497
+ * @param body — Request body
498
+ */
499
+ async evaluateFeatureFlag(body) {
500
+ const pathParams = {};
501
+ return this._http.request({
502
+ method: "POST",
503
+ path: "/api/system/feature-flags/evaluate",
504
+ pathParams,
505
+ body
506
+ });
507
+ }
508
+ /**
509
+ * Analyze memory quality distribution
510
+ *
511
+ * Analyze the quality distribution of memories for the authenticated user
512
+ * @param options — Optional parameters
513
+ */
514
+ async analyzeMemoryQuality(options) {
515
+ const pathParams = {};
516
+ const queryParams = {
517
+ "includeDetails": options?.includeDetails,
518
+ "minQualityThreshold": options?.minQualityThreshold
519
+ };
520
+ return this._http.request({
521
+ method: "GET",
522
+ path: "/api/system/memory/quality",
523
+ pathParams,
524
+ queryParams
525
+ });
526
+ }
527
+ /**
528
+ * Prune low-quality memories
529
+ *
530
+ * Prune (soft delete) low-quality memories for the authenticated user
531
+ * @param options — Optional parameters
532
+ */
533
+ async pruneMemories(options) {
534
+ const pathParams = {};
535
+ return this._http.request({
536
+ method: "POST",
537
+ path: "/api/system/memory/prune",
538
+ pathParams,
539
+ body: options?.body
540
+ });
541
+ }
542
+ /**
543
+ * Get OpenAPI specification
544
+ *
545
+ * Returns the OpenAPI 3.x specification for the entire API. This endpoint is used by CI/CD to sync the API Gateway.
546
+ * @param options — Optional parameters
547
+ */
548
+ async getOpenApiSpec(options) {
549
+ const pathParams = {};
550
+ const queryParams = {
551
+ "noCache": options?.noCache
552
+ };
553
+ return this._http.request({
554
+ method: "GET",
555
+ path: "/api/openapi.json",
556
+ pathParams,
557
+ queryParams
558
+ });
559
+ }
560
+ };
561
+
562
+ // src/services/patterns.ts
563
+ var Patterns = class {
564
+ _http;
565
+ constructor(http) {
566
+ this._http = http;
567
+ }
568
+ /**
569
+ * List patterns
570
+ *
571
+ * List all patterns for the authenticated user
572
+ * @param options — Optional parameters
573
+ */
574
+ async listPatterns(options) {
575
+ const pathParams = {};
576
+ const queryParams = {
577
+ "limit": options?.limit,
578
+ "offset": options?.offset
579
+ };
580
+ return this._http.request({
581
+ method: "GET",
582
+ path: "/api/patterns",
583
+ pathParams,
584
+ queryParams
585
+ });
586
+ }
587
+ /**
588
+ * Compile patterns
589
+ *
590
+ * Compile patterns from user's memories
591
+ * @param options — Optional parameters
592
+ */
593
+ async compilePatterns(options) {
594
+ const pathParams = {};
595
+ return this._http.request({
596
+ method: "POST",
597
+ path: "/api/patterns/compile",
598
+ pathParams,
599
+ body: options?.body
600
+ });
601
+ }
602
+ /**
603
+ * Detect behavioral patterns
604
+ *
605
+ * Run pattern detection algorithms to identify recurring behavioral patterns
606
+ * @param options — Optional parameters
607
+ */
608
+ async detectPatterns(options) {
609
+ const pathParams = {};
610
+ return this._http.request({
611
+ method: "POST",
612
+ path: "/api/patterns/detect",
613
+ pathParams,
614
+ body: options?.body
615
+ });
616
+ }
617
+ /**
618
+ * Analyze pattern trends
619
+ *
620
+ * Analyze pattern trends, correlations, and generate insights
621
+ * @param options — Optional parameters
622
+ */
623
+ async analyzePatterns(options) {
624
+ const pathParams = {};
625
+ return this._http.request({
626
+ method: "POST",
627
+ path: "/api/patterns/analyze",
628
+ pathParams,
629
+ body: options?.body
630
+ });
631
+ }
632
+ /**
633
+ * Update pattern
634
+ *
635
+ * Update an existing pattern with partial data
636
+ * @param id — The pattern ID
637
+ * @param body — Request body
638
+ */
639
+ async updatePattern(id, body) {
640
+ const pathParams = {
641
+ "id": id
642
+ };
643
+ return this._http.request({
644
+ method: "PATCH",
645
+ path: "/api/patterns/{id}",
646
+ pathParams,
647
+ body
648
+ });
649
+ }
650
+ /**
651
+ * Record pattern feedback
652
+ *
653
+ * Record feedback on a pattern
654
+ * @param body — Request body
655
+ */
656
+ async recordPatternFeedback(body) {
657
+ const pathParams = {};
658
+ return this._http.request({
659
+ method: "POST",
660
+ path: "/api/patterns/feedback",
661
+ pathParams,
662
+ body
663
+ });
664
+ }
665
+ /**
666
+ * Compile behavioral instructions from stored patterns
667
+ *
668
+ * Converts stored behavioral patterns into actionable instructions suitable for injection into AI agent context at conversation start. Uses template-based (non-LLM) generation for deterministic output within the P95 <100ms budget.
669
+ *
670
+ * @param options — Optional parameters
671
+ */
672
+ async compileInstructions(options) {
673
+ const pathParams = {};
674
+ return this._http.request({
675
+ method: "POST",
676
+ path: "/api/patterns/compile-instructions",
677
+ pathParams,
678
+ body: options?.body
679
+ });
680
+ }
681
+ };
682
+
683
+ // src/services/behavior.ts
684
+ var Behavior = class {
685
+ _http;
686
+ constructor(http) {
687
+ this._http = http;
688
+ }
689
+ /**
690
+ * Get behavioral state
691
+ *
692
+ * Get current behavioral state for the authenticated user
693
+ */
694
+ async getBehavioralState() {
695
+ const pathParams = {};
696
+ return this._http.request({
697
+ method: "GET",
698
+ path: "/api/patterns/behavior/state",
699
+ pathParams
700
+ });
701
+ }
702
+ /**
703
+ * Update behavioral state
704
+ *
705
+ * Update or mutate behavioral state
706
+ * @param options — Optional parameters
707
+ */
708
+ async updateBehavioralState(options) {
709
+ const pathParams = {};
710
+ return this._http.request({
711
+ method: "POST",
712
+ path: "/api/patterns/behavior/state",
713
+ pathParams,
714
+ body: options?.body
715
+ });
716
+ }
717
+ };
718
+
719
+ // src/services/recommendations.ts
720
+ var Recommendations = class {
721
+ _http;
722
+ constructor(http) {
723
+ this._http = http;
724
+ }
725
+ /**
726
+ * Create an explicit recommendation
727
+ *
728
+ * Create a new explicit recommendation (triggerContext + practice pair). Source is set to 'explicit'; triggerEmbedding is generated synchronously before return. SEC-BL-v2-002: practice content is validated against a prompt-injection deny-list. SEC-BL-v2-003: evidenceMemoryIds ownership is verified against the authenticated user.
729
+ *
730
+ * @param body — Request body
731
+ */
732
+ async createRecommendation(body) {
733
+ const pathParams = {};
734
+ return this._http.request({
735
+ method: "POST",
736
+ path: "/api/patterns/recommendations",
737
+ pathParams,
738
+ body
739
+ });
740
+ }
741
+ /**
742
+ * List pending recommendations
743
+ *
744
+ * Returns recommendations with status='pending_review' for the authenticated user, ordered by confidence DESC, createdAt ASC.
745
+ *
746
+ * @param options — Optional parameters
747
+ */
748
+ async listPendingRecommendations(options) {
749
+ const pathParams = {};
750
+ const queryParams = {
751
+ "limit": options?.limit,
752
+ "offset": options?.offset
753
+ };
754
+ return this._http.request({
755
+ method: "GET",
756
+ path: "/api/patterns/recommendations/pending",
757
+ pathParams,
758
+ queryParams
759
+ });
760
+ }
761
+ /**
762
+ * Approve a pending recommendation
763
+ *
764
+ * Transitions a recommendation from status='pending_review' to status='active'. Returns 404 if the recommendation is not found, not owned by the authenticated user, or is not in pending_review status.
765
+ *
766
+ * @param id — Recommendation ID
767
+ * @param options — Optional parameters
768
+ */
769
+ async approveRecommendation(id, options) {
770
+ const pathParams = {
771
+ "id": id
772
+ };
773
+ return this._http.request({
774
+ method: "PATCH",
775
+ path: "/api/patterns/recommendations/{id}/approve",
776
+ pathParams,
777
+ body: options?.body
778
+ });
779
+ }
780
+ /**
781
+ * Dismiss a recommendation
782
+ *
783
+ * Permanently dismisses a recommendation (any non-dismissed status → dismissed). This transition is terminal — dismissed recommendations cannot be reactivated. Returns 404 if not found, not owned by the authenticated user, or already dismissed.
784
+ *
785
+ * @param id — Recommendation ID
786
+ * @param options — Optional parameters
787
+ */
788
+ async dismissRecommendation(id, options) {
789
+ const pathParams = {
790
+ "id": id
791
+ };
792
+ return this._http.request({
793
+ method: "PATCH",
794
+ path: "/api/patterns/recommendations/{id}/dismiss",
795
+ pathParams,
796
+ body: options?.body
797
+ });
798
+ }
799
+ /**
800
+ * List active recommendations
801
+ *
802
+ * Returns recommendations with status='active' for the authenticated user, ordered by confidence DESC. These are the behavioral preferences currently surfacing in Claude via compile-instructions and build_context. SEC-BL-v2-003: results are scoped to the authenticated user — no cross-user data.
803
+ *
804
+ * @param options — Optional parameters
805
+ */
806
+ async listActiveRecommendations(options) {
807
+ const pathParams = {};
808
+ const queryParams = {
809
+ "limit": options?.limit,
810
+ "offset": options?.offset
811
+ };
812
+ return this._http.request({
813
+ method: "GET",
814
+ path: "/api/patterns/recommendations/active",
815
+ pathParams,
816
+ queryParams
817
+ });
818
+ }
819
+ /**
820
+ * Match active recommendations to content
821
+ *
822
+ * Embeds the supplied content and returns active Recommendations whose triggerContext is semantically similar. Used by the MCP server for just-in-time behavioral nudges on memory save. Results are scoped to the authenticated user — no cross-user data is returned.
823
+ *
824
+ * @param body — Request body
825
+ */
826
+ async matchRecommendations(body) {
827
+ const pathParams = {};
828
+ return this._http.request({
829
+ method: "POST",
830
+ path: "/api/patterns/recommendations/match",
831
+ pathParams,
832
+ body
833
+ });
834
+ }
835
+ /**
836
+ * Pause an active recommendation
837
+ *
838
+ * Transitions a recommendation from status='active' to status='paused'. Paused recommendations are excluded from compile-instructions and build_context surfacing. Returns 404 if the recommendation is not found, not owned by the authenticated user, or is not in active status. SEC-BL-v2-003: MATCH includes userId — no IDOR.
839
+ *
840
+ * @param id — Recommendation ID
841
+ * @param options — Optional parameters
842
+ */
843
+ async pauseRecommendation(id, options) {
844
+ const pathParams = {
845
+ "id": id
846
+ };
847
+ return this._http.request({
848
+ method: "PATCH",
849
+ path: "/api/patterns/recommendations/{id}/pause",
850
+ pathParams,
851
+ body: options?.body
852
+ });
853
+ }
854
+ };
855
+
856
+ // src/services/narratives.ts
857
+ var Narratives = class {
858
+ _http;
859
+ constructor(http) {
860
+ this._http = http;
861
+ }
862
+ /**
863
+ * List narrative threads
864
+ *
865
+ * List all narrative threads for the authenticated user.
866
+ * Narratives group related memories into coherent storylines.
867
+ *
868
+ * @param options — Optional parameters
869
+ */
870
+ async listNarratives(options) {
871
+ const pathParams = {};
872
+ const queryParams = {
873
+ "limit": options?.limit,
874
+ "offset": options?.offset,
875
+ "state": options?.state,
876
+ "topics": options?.topics
877
+ };
878
+ return this._http.request({
879
+ method: "GET",
880
+ path: "/api/narratives",
881
+ pathParams,
882
+ queryParams
883
+ });
884
+ }
885
+ /**
886
+ * Create a narrative thread
887
+ *
888
+ * Create a new narrative thread starting from a root memory.
889
+ * Narratives help organize related memories into coherent storylines.
890
+ *
891
+ * @param body — Request body
892
+ */
893
+ async createNarrative(body) {
894
+ const pathParams = {};
895
+ return this._http.request({
896
+ method: "POST",
897
+ path: "/api/narratives",
898
+ pathParams,
899
+ body
900
+ });
901
+ }
902
+ /**
903
+ * Get a narrative thread
904
+ *
905
+ * Retrieve a specific narrative thread by ID
906
+ * @param id — The narrative ID
907
+ */
908
+ async getNarrative(id) {
909
+ const pathParams = {
910
+ "id": id
911
+ };
912
+ return this._http.request({
913
+ method: "GET",
914
+ path: "/api/narratives/{id}",
915
+ pathParams
916
+ });
917
+ }
918
+ /**
919
+ * Delete a narrative thread
920
+ *
921
+ * Delete a narrative thread.
922
+ * This does not delete the associated memories, only the narrative structure.
923
+ *
924
+ * @param id — The narrative ID
925
+ */
926
+ async deleteNarrative(id) {
927
+ const pathParams = {
928
+ "id": id
929
+ };
930
+ return this._http.request({
931
+ method: "DELETE",
932
+ path: "/api/narratives/{id}",
933
+ pathParams
934
+ });
935
+ }
936
+ /**
937
+ * Update a narrative thread
938
+ *
939
+ * Update a narrative thread's title, topics, or state.
940
+ * Use this to resolve, reopen, or modify narratives.
941
+ *
942
+ * @param id — The narrative ID
943
+ * @param body — Request body
944
+ */
945
+ async updateNarrative(id, body) {
946
+ const pathParams = {
947
+ "id": id
948
+ };
949
+ return this._http.request({
950
+ method: "PATCH",
951
+ path: "/api/narratives/{id}",
952
+ pathParams,
953
+ body
954
+ });
955
+ }
956
+ /**
957
+ * Get narrative timeline
958
+ *
959
+ * Get all memories in a narrative, ordered by their position in the narrative.
960
+ * Each memory includes its position and effective state.
961
+ *
962
+ * @param id — The narrative ID
963
+ * @param options — Optional parameters
964
+ */
965
+ async getNarrativeTimeline(id, options) {
966
+ const pathParams = {
967
+ "id": id
968
+ };
969
+ const queryParams = {
970
+ "limit": options?.limit,
971
+ "offset": options?.offset
972
+ };
973
+ return this._http.request({
974
+ method: "GET",
975
+ path: "/api/narratives/{id}/timeline",
976
+ pathParams,
977
+ queryParams
978
+ });
979
+ }
980
+ /**
981
+ * Add a memory to a narrative
982
+ *
983
+ * Add an existing memory to a narrative thread.
984
+ * Optionally specify a position to insert the memory at.
985
+ *
986
+ * @param id — The narrative ID
987
+ * @param body — Request body
988
+ */
989
+ async addMemoryToNarrative(id, body) {
990
+ const pathParams = {
991
+ "id": id
992
+ };
993
+ return this._http.request({
994
+ method: "POST",
995
+ path: "/api/narratives/{id}/memories",
996
+ pathParams,
997
+ body
998
+ });
999
+ }
1000
+ /**
1001
+ * Remove a memory from a narrative
1002
+ *
1003
+ * Remove a memory from a narrative thread.
1004
+ * This does not delete the memory itself, only removes it from the narrative.
1005
+ *
1006
+ * @param id — The narrative ID
1007
+ * @param memoryId — The memory ID to remove
1008
+ */
1009
+ async removeMemoryFromNarrative(id, memoryId) {
1010
+ const pathParams = {
1011
+ "id": id,
1012
+ "memoryId": memoryId
1013
+ };
1014
+ return this._http.request({
1015
+ method: "DELETE",
1016
+ path: "/api/narratives/{id}/memories/{memoryId}",
1017
+ pathParams
1018
+ });
1019
+ }
1020
+ };
1021
+
1022
+ // src/services/monitoring.ts
1023
+ var Monitoring = class {
1024
+ _http;
1025
+ constructor(http) {
1026
+ this._http = http;
1027
+ }
1028
+ /**
1029
+ * Prometheus metrics endpoint
1030
+ *
1031
+ * Returns Prometheus-formatted metrics for monitoring and observability.
1032
+ * This endpoint is public and requires no authentication.
1033
+ * Designed to be scraped by Prometheus at regular intervals.
1034
+ *
1035
+ */
1036
+ async getMetrics() {
1037
+ const pathParams = {};
1038
+ return this._http.request({
1039
+ method: "GET",
1040
+ path: "/metrics",
1041
+ pathParams
1042
+ });
1043
+ }
1044
+ };
1045
+
1046
+ // src/services/memories.ts
1047
+ var Memories = class {
1048
+ _http;
1049
+ constructor(http) {
1050
+ this._http = http;
1051
+ }
1052
+ /**
1053
+ * Get memory by ID
1054
+ *
1055
+ * Retrieve a specific memory by its ID with configurable detail level.
1056
+ *
1057
+ * **Detail levels:**
1058
+ * - `minimal` — raw memory only, no extra queries
1059
+ * - `standard` (default) — adds userTopics, extractedTopics, entities, facts, relationships
1060
+ * - `full` — adds conversationContext (title, memoryCount, position) and relationship target previews
1061
+ *
1062
+ * @param id — The memory ID
1063
+ * @param options — Optional parameters
1064
+ */
1065
+ async getMemoryById(id, options) {
1066
+ const pathParams = {
1067
+ "id": id
1068
+ };
1069
+ const queryParams = {
1070
+ "detail": options?.detail
1071
+ };
1072
+ return this._http.request({
1073
+ method: "GET",
1074
+ path: "/api/memories/{id}",
1075
+ pathParams,
1076
+ queryParams
1077
+ });
1078
+ }
1079
+ /**
1080
+ * Update a memory
1081
+ *
1082
+ * Update an existing memory for the authenticated user
1083
+ * @param id — Memory ID
1084
+ * @param body — Request body
1085
+ */
1086
+ async updateMemory(id, body) {
1087
+ const pathParams = {
1088
+ "id": id
1089
+ };
1090
+ return this._http.request({
1091
+ method: "PUT",
1092
+ path: "/api/memories/{id}",
1093
+ pathParams,
1094
+ body
1095
+ });
1096
+ }
1097
+ /**
1098
+ * Delete memory
1099
+ *
1100
+ * Delete a memory by its ID
1101
+ * @param id — The memory ID
1102
+ */
1103
+ async deleteMemory(id) {
1104
+ const pathParams = {
1105
+ "id": id
1106
+ };
1107
+ return this._http.request({
1108
+ method: "DELETE",
1109
+ path: "/api/memories/{id}",
1110
+ pathParams
1111
+ });
1112
+ }
1113
+ /**
1114
+ * Aggregated memory analytics
1115
+ *
1116
+ * Return aggregated memory counts grouped by a time dimension (day, week, month)
1117
+ * or by topic. Useful for activity dashboards and trend analysis.
1118
+ *
1119
+ * @param options — Optional parameters
1120
+ */
1121
+ async getMemoriesStats(options) {
1122
+ const pathParams = {};
1123
+ const queryParams = {
1124
+ "groupBy": options?.groupBy,
1125
+ "after": options?.after,
1126
+ "before": options?.before,
1127
+ "recent": options?.recent,
1128
+ "topic": options?.topic,
1129
+ "limit": options?.limit
1130
+ };
1131
+ return this._http.request({
1132
+ method: "GET",
1133
+ path: "/api/memories/stats",
1134
+ pathParams,
1135
+ queryParams
1136
+ });
1137
+ }
1138
+ /**
1139
+ * List memories
1140
+ *
1141
+ * List all memories for the authenticated user with pagination.
1142
+ *
1143
+ * **ID Prefix Search:**
1144
+ * Use the `idPrefix` parameter for git-style short ID lookup. This enables efficient
1145
+ * server-side filtering instead of fetching all memories and filtering client-side.
1146
+ * - Minimum 6 characters required for `idPrefix`
1147
+ * - Returns matching memories directly (no need for secondary fetch)
1148
+ * - Example: `?idPrefix=2d09116a` finds memories starting with that prefix
1149
+ *
1150
+ * @param options — Optional parameters
1151
+ */
1152
+ async listMemories(options) {
1153
+ const pathParams = {};
1154
+ const queryParams = {
1155
+ "idPrefix": options?.idPrefix,
1156
+ "limit": options?.limit,
1157
+ "offset": options?.offset,
1158
+ "page": options?.page,
1159
+ "sortBy": options?.sortBy,
1160
+ "order": options?.order,
1161
+ "from": options?.from$,
1162
+ "to": options?.to,
1163
+ "recent": options?.recent,
1164
+ "topics": options?.topics,
1165
+ "excludeTopics": options?.excludeTopics,
1166
+ "conversationId": options?.conversationId,
1167
+ "scope": options?.scope
1168
+ };
1169
+ return this._http.request({
1170
+ method: "GET",
1171
+ path: "/api/memories",
1172
+ pathParams,
1173
+ queryParams
1174
+ });
1175
+ }
1176
+ /**
1177
+ * Create a memory
1178
+ *
1179
+ * Create a new memory for the authenticated user.
1180
+ *
1181
+ * **Conversation Management:**
1182
+ * - Use `conversationId: "NEW"` to create a new conversation automatically
1183
+ * - Provide an existing conversation ID to add to that conversation
1184
+ *
1185
+ * **Session Management:**
1186
+ * - Sessions are automatically assigned based on 90-minute gap detection
1187
+ * - If the last memory in the conversation was within 90 minutes, the same session is reused
1188
+ * - If the gap exceeds 90 minutes, a new session is created
1189
+ *
1190
+ * **Response:**
1191
+ * - Returns the created memory in `data` field
1192
+ * - Returns session/conversation metadata in `meta` field
1193
+ *
1194
+ * @param body — Request body
1195
+ */
1196
+ async createMemory(body) {
1197
+ const pathParams = {};
1198
+ return this._http.request({
1199
+ method: "POST",
1200
+ path: "/api/memories",
1201
+ pathParams,
1202
+ body
1203
+ });
1204
+ }
1205
+ /**
1206
+ * Search memories (GET)
1207
+ *
1208
+ * Search memories using query parameters. Provides the same functionality as
1209
+ * POST /api/memories/search but accepts parameters via query string.
1210
+ *
1211
+ * **Benefits of GET:**
1212
+ * - Faster response times (~3x improvement)
1213
+ * - Browser/CDN caching support
1214
+ * - Simpler integration for read-only clients
1215
+ *
1216
+ * **Search Methods:**
1217
+ * - **hybrid** (default): Combines semantic and keyword search with Reciprocal Rank Fusion
1218
+ * - **semantic**: Vector-based semantic search using OpenAI embeddings
1219
+ * - **keyword**: Traditional fulltext search using Lucene
1220
+ *
1221
+ * **Array Parameters:**
1222
+ * - `topics`: Provide as comma-separated values (e.g., `topics=typescript,api-design`)
1223
+ *
1224
+ * @param options — Optional parameters
1225
+ */
1226
+ async searchMemoriesGet(options) {
1227
+ const pathParams = {};
1228
+ const queryParams = {
1229
+ "q": options?.q,
1230
+ "searchMethod": options?.searchMethod,
1231
+ "limit": options?.limit,
1232
+ "offset": options?.offset,
1233
+ "threshold": options?.threshold,
1234
+ "mode": options?.mode,
1235
+ "vectorWeight": options?.vectorWeight,
1236
+ "fulltextWeight": options?.fulltextWeight,
1237
+ "topics": options?.topics,
1238
+ "excludeTopics": options?.excludeTopics,
1239
+ "memoryType": options?.memoryType,
1240
+ "conversationId": options?.conversationId,
1241
+ "explain": options?.explain,
1242
+ "includeTopics": options?.includeTopics,
1243
+ "includeEntities": options?.includeEntities,
1244
+ "includeFacts": options?.includeFacts,
1245
+ "includeClaims": options?.includeClaims,
1246
+ "asOfTime": options?.asOfTime,
1247
+ "validAtTime": options?.validAtTime,
1248
+ "eventTimeFrom": options?.eventTimeFrom,
1249
+ "eventTimeTo": options?.eventTimeTo,
1250
+ "ingestionTimeFrom": options?.ingestionTimeFrom,
1251
+ "ingestionTimeTo": options?.ingestionTimeTo,
1252
+ "includeExpired": options?.includeExpired,
1253
+ "temporalMode": options?.temporalMode,
1254
+ "sortBy": options?.sortBy,
1255
+ "order": options?.order,
1256
+ "expandEntities": options?.expandEntities,
1257
+ "expandTopics": options?.expandTopics,
1258
+ "expandFacts": options?.expandFacts,
1259
+ "includeSuperseded": options?.includeSuperseded,
1260
+ "entityWeight": options?.entityWeight,
1261
+ "topicWeight": options?.topicWeight,
1262
+ "factWeight": options?.factWeight,
1263
+ "questionWeight": options?.questionWeight,
1264
+ "claimsWeight": options?.claimsWeight,
1265
+ "includeFacets": options?.includeFacets,
1266
+ "embeddingProvider": options?.embeddingProvider,
1267
+ "scope": options?.scope,
1268
+ "taskId": options?.taskId,
1269
+ "outcomeFilter": options?.outcomeFilter
1270
+ };
1271
+ return this._http.request({
1272
+ method: "GET",
1273
+ path: "/api/memories/search",
1274
+ pathParams,
1275
+ queryParams
1276
+ });
1277
+ }
1278
+ /**
1279
+ * Search all memories
1280
+ *
1281
+ * Search memories using different search methods:
1282
+ * - **hybrid** (default): Combines semantic and keyword search with Reciprocal Rank Fusion
1283
+ * - **semantic**: Vector-based semantic search using OpenAI embeddings
1284
+ * - **keyword**: Traditional fulltext search using Lucene
1285
+ *
1286
+ * The `mode` parameter controls content filtering (unified, content, facts).
1287
+ * The `searchMethod` parameter controls the search algorithm.
1288
+ *
1289
+ * @param body — Request body
1290
+ */
1291
+ async searchMemories(body) {
1292
+ const pathParams = {};
1293
+ return this._http.request({
1294
+ method: "POST",
1295
+ path: "/api/memories/search",
1296
+ pathParams,
1297
+ body
1298
+ });
1299
+ }
1300
+ /**
1301
+ * Get multiple memories by IDs
1302
+ *
1303
+ * Retrieve multiple memories by their IDs in a single request.
1304
+ * More efficient than making multiple individual GET requests.
1305
+ *
1306
+ * Returns memories in the order requested, with metadata about
1307
+ * which IDs were found or missing.
1308
+ *
1309
+ * @param body — Request body
1310
+ */
1311
+ async getMemoriesBatch(body) {
1312
+ const pathParams = {};
1313
+ return this._http.request({
1314
+ method: "POST",
1315
+ path: "/api/memories/batch",
1316
+ pathParams,
1317
+ body
1318
+ });
1319
+ }
1320
+ /**
1321
+ * Generate memory digest
1322
+ *
1323
+ * Synthesizes a comprehensive, structured briefing from all relevant memories
1324
+ * on a topic. Instead of multiple search rounds, one call returns a complete digest.
1325
+ *
1326
+ * **Formats:**
1327
+ * - `structured` (default): Sections with headers, bullet points, key decisions
1328
+ * - `narrative`: Chronological prose narrative
1329
+ * - `timeline`: Dated event list
1330
+ * - `status-report`: Done/In Progress/Blocked grouping
1331
+ *
1332
+ * **Pipeline:**
1333
+ * 1. Gather: High-limit search + conversation expansion
1334
+ * 2. Organize: Group by conversation, status, timeline
1335
+ * 3. Synthesize: LLM generates formatted digest
1336
+ *
1337
+ * Requires an LLM provider to be configured (EXTRACTION_ENABLED=true).
1338
+ * Returns 503 if the LLM provider is unavailable and 3+ memories are found.
1339
+ *
1340
+ * @param body — Request body
1341
+ */
1342
+ async generateMemoryDigest(body) {
1343
+ const pathParams = {};
1344
+ return this._http.request({
1345
+ method: "POST",
1346
+ path: "/api/memories/digest",
1347
+ pathParams,
1348
+ body
1349
+ });
1350
+ }
1351
+ /**
1352
+ * Generate memory digest (SSE streaming)
1353
+ *
1354
+ * Same as POST /api/memories/digest but uses Server-Sent Events (SSE) to stream
1355
+ * the response. Sends `: heartbeat` comments every 10 seconds during processing
1356
+ * to prevent gateway read-timeout (default 60s) from killing long-running digests.
1357
+ *
1358
+ * **Event sequence:**
1359
+ * - `: heartbeat` — keep-alive comment, sent every 10s during processing
1360
+ * - `event: result` / `data: <DigestResponse JSON>` — digest completed successfully
1361
+ * - `event: error` / `data: {"error":"...","statusCode":N}` — digest failed
1362
+ * - `event: done` / `data: {}` — stream complete (sent after result)
1363
+ *
1364
+ * **Formats and pipeline:** identical to POST /api/memories/digest.
1365
+ *
1366
+ * @param body — Request body
1367
+ */
1368
+ async streamMemoryDigest(body) {
1369
+ const pathParams = {};
1370
+ return this._http.request({
1371
+ method: "POST",
1372
+ path: "/api/memories/digest/stream",
1373
+ pathParams,
1374
+ body
1375
+ });
1376
+ }
1377
+ /**
1378
+ * Build a context briefing
1379
+ *
1380
+ * Answers "What should I know before working on X?" by combining active work
1381
+ * detection, fact retrieval, gotcha detection, recent activity, and pattern
1382
+ * matching into a single call. Eliminates the 5+ round-trip pattern agents
1383
+ * use today.
1384
+ *
1385
+ * @param body — Request body
1386
+ */
1387
+ async buildContext(body) {
1388
+ const pathParams = {};
1389
+ return this._http.request({
1390
+ method: "POST",
1391
+ path: "/api/memories/build-context",
1392
+ pathParams,
1393
+ body
1394
+ });
1395
+ }
1396
+ /**
1397
+ * Get version history for a named memory
1398
+ *
1399
+ * Returns the full version chain for a named memory, ordered newest-first.
1400
+ * Walks the SUPERSEDES chain from HEAD backwards.
1401
+ *
1402
+ * @param name — Memory name (kebab-case, 2-64 chars)
1403
+ * @param options — Optional parameters
1404
+ */
1405
+ async getNamedMemoryHistory(name, options) {
1406
+ const pathParams = {
1407
+ "name": name
1408
+ };
1409
+ const queryParams = {
1410
+ "limit": options?.limit
1411
+ };
1412
+ return this._http.request({
1413
+ method: "GET",
1414
+ path: "/api/memories/named/{name}/history",
1415
+ pathParams,
1416
+ queryParams
1417
+ });
1418
+ }
1419
+ /**
1420
+ * Get a memory by name
1421
+ *
1422
+ * Retrieve the current HEAD version of a named memory by its user-assigned name.
1423
+ * Supports the same detail levels as GET /api/memories/{id}.
1424
+ *
1425
+ * @param name — Memory name (kebab-case, 2-64 chars)
1426
+ * @param options — Optional parameters
1427
+ */
1428
+ async getMemoryByName(name, options) {
1429
+ const pathParams = {
1430
+ "name": name
1431
+ };
1432
+ const queryParams = {
1433
+ "detail": options?.detail
1434
+ };
1435
+ return this._http.request({
1436
+ method: "GET",
1437
+ path: "/api/memories/named/{name}",
1438
+ pathParams,
1439
+ queryParams
1440
+ });
1441
+ }
1442
+ /**
1443
+ * Update a named memory (create new version)
1444
+ *
1445
+ * Creates a new version of a named memory. The name pointer moves to the new version,
1446
+ * and a SUPERSEDES relationship links the new version to the old one.
1447
+ * The old version's effectiveState becomes 'superseded'.
1448
+ *
1449
+ * @param name — Memory name (kebab-case, 2-64 chars)
1450
+ * @param body — Request body
1451
+ */
1452
+ async updateNamedMemory(name, body) {
1453
+ const pathParams = {
1454
+ "name": name
1455
+ };
1456
+ return this._http.request({
1457
+ method: "PUT",
1458
+ path: "/api/memories/named/{name}",
1459
+ pathParams,
1460
+ body
1461
+ });
1462
+ }
1463
+ /**
1464
+ * Bulk delete multiple memories
1465
+ *
1466
+ * Soft-delete multiple memories at once. Requires confirmDeletion=true.
1467
+ * Each memory is verified to belong to the authenticated user.
1468
+ * Maximum 100 IDs per request.
1469
+ *
1470
+ * @param body — Request body
1471
+ */
1472
+ async bulkDeleteMemories(body) {
1473
+ const pathParams = {};
1474
+ return this._http.request({
1475
+ method: "DELETE",
1476
+ path: "/api/memories/bulk",
1477
+ pathParams,
1478
+ body
1479
+ });
1480
+ }
1481
+ /**
1482
+ * Repair orphaned effectiveState values
1483
+ *
1484
+ * Finds memories with effectiveState='superseded' or 'contradicted' but no
1485
+ * corresponding incoming SUPERSEDES/CONTRADICTS edges, and resets them to 'current'.
1486
+ * This handles cases where edges were deleted but effectiveState wasn't recalculated.
1487
+ *
1488
+ */
1489
+ async repairEffectiveState() {
1490
+ const pathParams = {};
1491
+ return this._http.request({
1492
+ method: "POST",
1493
+ path: "/api/memories/repair-effective-state",
1494
+ pathParams
1495
+ });
1496
+ }
1497
+ /**
1498
+ * Record behavioral feedback on a search result
1499
+ *
1500
+ * Record whether a search result was selected or ignored by the user.
1501
+ * Used to build behavioral signals for retrieval quality measurement.
1502
+ *
1503
+ * @param body — Request body
1504
+ */
1505
+ async recordSearchResultFeedback(body) {
1506
+ const pathParams = {};
1507
+ return this._http.request({
1508
+ method: "POST",
1509
+ path: "/api/memories/search/feedback",
1510
+ pathParams,
1511
+ body
1512
+ });
1513
+ }
1514
+ /**
1515
+ * Find similar memories
1516
+ *
1517
+ * Find memories that are semantically similar to the given memory.
1518
+ *
1519
+ * Uses vector similarity search if embeddings are available for the memory.
1520
+ * Falls back to topic-based similarity if embeddings are not available.
1521
+ *
1522
+ * The `relationship` field in results indicates the method used:
1523
+ * - `similar` - Found via vector/semantic similarity
1524
+ * - `similar-by-topic` - Fallback using shared topics
1525
+ *
1526
+ * @param id — The source memory ID
1527
+ * @param options — Optional parameters
1528
+ */
1529
+ async getSimilarMemories(id, options) {
1530
+ const pathParams = {
1531
+ "id": id
1532
+ };
1533
+ const queryParams = {
1534
+ "limit": options?.limit
1535
+ };
1536
+ return this._http.request({
1537
+ method: "GET",
1538
+ path: "/api/memories/{id}/similar",
1539
+ pathParams,
1540
+ queryParams
1541
+ });
1542
+ }
1543
+ /**
1544
+ * Find memories from same conversation
1545
+ *
1546
+ * Find other memories that belong to the same conversation as the given memory.
1547
+ *
1548
+ * Returns memories sorted chronologically (oldest first) to show the conversation flow.
1549
+ * If the memory doesn't belong to a conversation, returns an empty array.
1550
+ *
1551
+ * @param id — The source memory ID
1552
+ * @param options — Optional parameters
1553
+ */
1554
+ async getConversationMemories(id, options) {
1555
+ const pathParams = {
1556
+ "id": id
1557
+ };
1558
+ const queryParams = {
1559
+ "limit": options?.limit
1560
+ };
1561
+ return this._http.request({
1562
+ method: "GET",
1563
+ path: "/api/memories/{id}/conversation-memories",
1564
+ pathParams,
1565
+ queryParams
1566
+ });
1567
+ }
1568
+ /**
1569
+ * Find related memories by topics
1570
+ *
1571
+ * Find memories that share topics with the given memory.
1572
+ *
1573
+ * The score indicates the ratio of shared topics (1.0 = all topics match).
1574
+ * Results are sorted by score (most related first), then by timestamp.
1575
+ *
1576
+ * If the source memory has no topics, returns an empty array.
1577
+ *
1578
+ * @param id — The source memory ID
1579
+ * @param options — Optional parameters
1580
+ */
1581
+ async getRelatedMemories(id, options) {
1582
+ const pathParams = {
1583
+ "id": id
1584
+ };
1585
+ const queryParams = {
1586
+ "limit": options?.limit
1587
+ };
1588
+ return this._http.request({
1589
+ method: "GET",
1590
+ path: "/api/memories/{id}/related",
1591
+ pathParams,
1592
+ queryParams
1593
+ });
1594
+ }
1595
+ /**
1596
+ * Get relationships for a memory
1597
+ *
1598
+ * Retrieve all relationships for a memory.
1599
+ *
1600
+ * **Direction Options:**
1601
+ * - **outgoing**: Relationships where this memory is the source
1602
+ * - **incoming**: Relationships where this memory is the target
1603
+ * - **both**: All relationships involving this memory
1604
+ *
1605
+ * @param id — The memory ID
1606
+ * @param options — Optional parameters
1607
+ */
1608
+ async getMemoryRelationships(id, options) {
1609
+ const pathParams = {
1610
+ "id": id
1611
+ };
1612
+ const queryParams = {
1613
+ "direction": options?.direction
1614
+ };
1615
+ return this._http.request({
1616
+ method: "GET",
1617
+ path: "/api/memories/{id}/relationships",
1618
+ pathParams,
1619
+ queryParams
1620
+ });
1621
+ }
1622
+ /**
1623
+ * Create a relationship between memories
1624
+ *
1625
+ * Create a relationship between the source memory and a target memory.
1626
+ *
1627
+ * **Relationship Types:**
1628
+ * - **SUPERSEDES**: The source memory replaces/updates the target memory
1629
+ * - **FOLLOWS**: The source memory follows chronologically from the target
1630
+ * - **RESOLVES**: The source memory resolves an issue mentioned in the target
1631
+ * - **CONTRADICTS**: The source memory contradicts the target memory
1632
+ * - **REFERENCES**: The source memory references the target memory
1633
+ *
1634
+ * When creating SUPERSEDES or CONTRADICTS relationships, the target memory's
1635
+ * effectiveState will be automatically updated.
1636
+ *
1637
+ * @param id — The source memory ID
1638
+ * @param body — Request body
1639
+ */
1640
+ async createMemoryRelationship(id, body) {
1641
+ const pathParams = {
1642
+ "id": id
1643
+ };
1644
+ return this._http.request({
1645
+ method: "POST",
1646
+ path: "/api/memories/{id}/relationships",
1647
+ pathParams,
1648
+ body
1649
+ });
1650
+ }
1651
+ /**
1652
+ * Delete a relationship
1653
+ *
1654
+ * Delete a specific relationship from a memory
1655
+ * @param id — The source memory ID
1656
+ * @param relationshipId — The relationship ID to delete
1657
+ */
1658
+ async deleteMemoryRelationship(id, relationshipId) {
1659
+ const pathParams = {
1660
+ "id": id,
1661
+ "relationshipId": relationshipId
1662
+ };
1663
+ return this._http.request({
1664
+ method: "DELETE",
1665
+ path: "/api/memories/{id}/relationships/{relationshipId}",
1666
+ pathParams
1667
+ });
1668
+ }
1669
+ /**
1670
+ * Get timeline context for a memory
1671
+ *
1672
+ * Get the chronological context around a memory.
1673
+ * Returns preceding and following memories ordered by event time.
1674
+ * Useful for understanding the narrative flow.
1675
+ *
1676
+ * @param id — The memory ID
1677
+ * @param options — Optional parameters
1678
+ */
1679
+ async getMemoryTimeline(id, options) {
1680
+ const pathParams = {
1681
+ "id": id
1682
+ };
1683
+ const queryParams = {
1684
+ "before": options?.before,
1685
+ "after": options?.after
1686
+ };
1687
+ return this._http.request({
1688
+ method: "GET",
1689
+ path: "/api/memories/{id}/timeline",
1690
+ pathParams,
1691
+ queryParams
1692
+ });
1693
+ }
1694
+ /**
1695
+ * Detect potential relationships for a memory
1696
+ *
1697
+ * Analyze a memory and detect potential relationships with other memories.
1698
+ * Uses semantic similarity and pattern detection to suggest relationships.
1699
+ *
1700
+ * Set `autoCreate: true` to automatically create high-confidence relationships.
1701
+ *
1702
+ * @param id — The memory ID
1703
+ * @param options — Optional parameters
1704
+ */
1705
+ async detectMemoryRelationships(id, options) {
1706
+ const pathParams = {
1707
+ "id": id
1708
+ };
1709
+ return this._http.request({
1710
+ method: "POST",
1711
+ path: "/api/memories/{id}/detect-relationships",
1712
+ pathParams,
1713
+ body: options?.body
1714
+ });
1715
+ }
1716
+ /**
1717
+ * Generate LLM explanation for a memory relationship
1718
+ *
1719
+ * Uses an LLM to explain why two memories have been flagged with a
1720
+ * particular relationship (e.g. contradiction). Returns a short
1721
+ * plain-text explanation highlighting the specific differences.
1722
+ *
1723
+ * @param id — The ID of the source memory
1724
+ * @param body — Request body
1725
+ */
1726
+ async explainMemoryRelationship(id, body) {
1727
+ const pathParams = {
1728
+ "id": id
1729
+ };
1730
+ return this._http.request({
1731
+ method: "POST",
1732
+ path: "/api/memories/{id}/explain-relationship",
1733
+ pathParams,
1734
+ body
1735
+ });
1736
+ }
1737
+ /**
1738
+ * Export memories matching filters
1739
+ *
1740
+ * Export memories matching an optional search query and filters to JSON or CSV format.
1741
+ * When a query is provided, uses hybrid search. When no query is provided, lists memories
1742
+ * with optional topic and memoryType filters. Maximum 1000 results per export.
1743
+ *
1744
+ * @param body — Request body
1745
+ */
1746
+ async exportMemories(body) {
1747
+ const pathParams = {};
1748
+ return this._http.request({
1749
+ method: "POST",
1750
+ path: "/api/memories/export",
1751
+ pathParams,
1752
+ body
1753
+ });
1754
+ }
1755
+ /**
1756
+ * Bulk update multiple memories
1757
+ *
1758
+ * Update multiple memories at once. Supports updating topics and memoryType.
1759
+ * Each memory is verified to belong to the authenticated user.
1760
+ * Maximum 100 IDs per request.
1761
+ *
1762
+ * @param body — Request body
1763
+ */
1764
+ async bulkUpdateMemories(body) {
1765
+ const pathParams = {};
1766
+ return this._http.request({
1767
+ method: "POST",
1768
+ path: "/api/memories/bulk-update",
1769
+ pathParams,
1770
+ body
1771
+ });
1772
+ }
1773
+ /**
1774
+ * Bulk add or remove topics from memories
1775
+ *
1776
+ * Add and/or remove topics from multiple memories at once.
1777
+ * At least one of addTopics or removeTopics must be provided.
1778
+ * Each memory is verified to belong to the authenticated user.
1779
+ * Maximum 100 IDs per request.
1780
+ *
1781
+ * @param body — Request body
1782
+ */
1783
+ async bulkTagMemories(body) {
1784
+ const pathParams = {};
1785
+ return this._http.request({
1786
+ method: "POST",
1787
+ path: "/api/memories/bulk-tag",
1788
+ pathParams,
1789
+ body
1790
+ });
1791
+ }
1792
+ };
1793
+
1794
+ // src/services/invites.ts
1795
+ var Invites = class {
1796
+ _http;
1797
+ constructor(http) {
1798
+ this._http = http;
1799
+ }
1800
+ /**
1801
+ * Check invite gate status
1802
+ *
1803
+ * Check whether the invite gate is currently open or closed.
1804
+ * When gated is true, new signups require a valid invite code.
1805
+ * Response is cached server-side (30-second TTL).
1806
+ *
1807
+ */
1808
+ async getGateStatus() {
1809
+ const pathParams = {};
1810
+ return this._http.request({
1811
+ method: "GET",
1812
+ path: "/api/invites/gate-status",
1813
+ pathParams
1814
+ });
1815
+ }
1816
+ /**
1817
+ * Validate an invite code
1818
+ *
1819
+ * Validate an invite code without redeeming it.
1820
+ * Rate limited to 10 requests per minute per IP to prevent enumeration.
1821
+ * Error messages are intentionally generic.
1822
+ *
1823
+ * @param body — Request body
1824
+ */
1825
+ async validateInviteCode(body) {
1826
+ const pathParams = {};
1827
+ return this._http.request({
1828
+ method: "POST",
1829
+ path: "/api/invites/validate",
1830
+ pathParams,
1831
+ body
1832
+ });
1833
+ }
1834
+ };
1835
+
1836
+ // src/services/health.ts
1837
+ var Health = class {
1838
+ _http;
1839
+ constructor(http) {
1840
+ this._http = http;
1841
+ }
1842
+ /**
1843
+ * Liveness probe endpoint
1844
+ *
1845
+ * Returns 200 if the process is alive. Does not check external dependencies.
1846
+ * Used by Kubernetes liveness probes to determine if the container should be restarted.
1847
+ * Unlike /health, this endpoint does not query the database — a database outage
1848
+ * should not cause the API process to be killed and restarted.
1849
+ *
1850
+ */
1851
+ async livenessCheck() {
1852
+ const pathParams = {};
1853
+ return this._http.request({
1854
+ method: "GET",
1855
+ path: "/livez",
1856
+ pathParams
1857
+ });
1858
+ }
1859
+ /**
1860
+ * API health check endpoint
1861
+ *
1862
+ * Returns the health status and uptime of the API service.
1863
+ * This endpoint is public and requires no authentication.
1864
+ * Use this endpoint for monitoring, health checks, and service availability verification.
1865
+ * Returns 200 when healthy, 503 when the database is unreachable.
1866
+ *
1867
+ */
1868
+ async healthCheck() {
1869
+ const pathParams = {};
1870
+ return this._http.request({
1871
+ method: "GET",
1872
+ path: "/health",
1873
+ pathParams
1874
+ });
1875
+ }
1876
+ };
1877
+
1878
+ // src/services/graphrag.ts
1879
+ var Graphrag = class {
1880
+ _http;
1881
+ constructor(http) {
1882
+ this._http = http;
1883
+ }
1884
+ /**
1885
+ * Explain a GraphRAG query
1886
+ *
1887
+ * Get explanation for a previously executed GraphRAG query result
1888
+ * @param options — Optional parameters
1889
+ */
1890
+ async explainGraphRAGQuery(options) {
1891
+ const pathParams = {};
1892
+ const queryParams = {
1893
+ "queryId": options?.queryId
1894
+ };
1895
+ return this._http.request({
1896
+ method: "GET",
1897
+ path: "/api/graphrag/explain",
1898
+ pathParams,
1899
+ queryParams
1900
+ });
1901
+ }
1902
+ /**
1903
+ * Query communities
1904
+ *
1905
+ * Query communities for relevant information using semantic search
1906
+ * @param body — Request body
1907
+ */
1908
+ async queryCommunities(body) {
1909
+ const pathParams = {};
1910
+ return this._http.request({
1911
+ method: "POST",
1912
+ path: "/api/graphrag/query-communities",
1913
+ pathParams,
1914
+ body
1915
+ });
1916
+ }
1917
+ /**
1918
+ * Execute a GraphRAG query
1919
+ *
1920
+ * Execute a graph-based retrieval augmented generation query
1921
+ * @param body — Request body
1922
+ */
1923
+ async executeGraphRAGQuery(body) {
1924
+ const pathParams = {};
1925
+ return this._http.request({
1926
+ method: "POST",
1927
+ path: "/api/graphrag/query",
1928
+ pathParams,
1929
+ body
1930
+ });
1931
+ }
1932
+ };
1933
+
1934
+ // src/services/facts.ts
1935
+ var Facts = class {
1936
+ _http;
1937
+ constructor(http) {
1938
+ this._http = http;
1939
+ }
1940
+ /**
1941
+ * List facts
1942
+ *
1943
+ * List all facts for the authenticated user
1944
+ * @param options — Optional parameters
1945
+ */
1946
+ async listFacts(options) {
1947
+ const pathParams = {};
1948
+ const queryParams = {
1949
+ "limit": options?.limit,
1950
+ "offset": options?.offset,
1951
+ "memoryId": options?.memoryId,
1952
+ "sortBy": options?.sortBy,
1953
+ "order": options?.order
1954
+ };
1955
+ return this._http.request({
1956
+ method: "GET",
1957
+ path: "/api/facts",
1958
+ pathParams,
1959
+ queryParams
1960
+ });
1961
+ }
1962
+ /**
1963
+ * Create fact
1964
+ *
1965
+ * Create a new semantic fact
1966
+ * @param body — Request body
1967
+ */
1968
+ async createFact(body) {
1969
+ const pathParams = {};
1970
+ return this._http.request({
1971
+ method: "POST",
1972
+ path: "/api/facts",
1973
+ pathParams,
1974
+ body
1975
+ });
1976
+ }
1977
+ /**
1978
+ * Get fact by ID
1979
+ *
1980
+ * Retrieve a specific fact by its ID
1981
+ * @param id — The fact ID
1982
+ */
1983
+ async getFactById(id) {
1984
+ const pathParams = {
1985
+ "id": id
1986
+ };
1987
+ return this._http.request({
1988
+ method: "GET",
1989
+ path: "/api/facts/{id}",
1990
+ pathParams
1991
+ });
1992
+ }
1993
+ /**
1994
+ * Update fact
1995
+ *
1996
+ * Update an existing fact completely
1997
+ * @param id — The fact ID
1998
+ * @param body — Request body
1999
+ */
2000
+ async updateFact(id, body) {
2001
+ const pathParams = {
2002
+ "id": id
2003
+ };
2004
+ return this._http.request({
2005
+ method: "PUT",
2006
+ path: "/api/facts/{id}",
2007
+ pathParams,
2008
+ body
2009
+ });
2010
+ }
2011
+ /**
2012
+ * Delete fact
2013
+ *
2014
+ * Delete a fact by its ID
2015
+ * @param id — The fact ID
2016
+ */
2017
+ async deleteFact(id) {
2018
+ const pathParams = {
2019
+ "id": id
2020
+ };
2021
+ return this._http.request({
2022
+ method: "DELETE",
2023
+ path: "/api/facts/{id}",
2024
+ pathParams
2025
+ });
2026
+ }
2027
+ /**
2028
+ * Search facts
2029
+ *
2030
+ * Search semantic facts by query string
2031
+ * @param body — Request body
2032
+ */
2033
+ async searchFacts(body) {
2034
+ const pathParams = {};
2035
+ return this._http.request({
2036
+ method: "POST",
2037
+ path: "/api/facts/search",
2038
+ pathParams,
2039
+ body
2040
+ });
2041
+ }
2042
+ };
2043
+
2044
+ // src/services/entities.ts
2045
+ var Entities = class {
2046
+ _http;
2047
+ constructor(http) {
2048
+ this._http = http;
2049
+ }
2050
+ /**
2051
+ * List entities
2052
+ *
2053
+ * List all entities for the authenticated user, optionally filtered by type
2054
+ * @param options — Optional parameters
2055
+ */
2056
+ async listEntities(options) {
2057
+ const pathParams = {};
2058
+ const queryParams = {
2059
+ "query": options?.query,
2060
+ "type": options?.type$,
2061
+ "limit": options?.limit,
2062
+ "offset": options?.offset
2063
+ };
2064
+ return this._http.request({
2065
+ method: "GET",
2066
+ path: "/api/entities",
2067
+ pathParams,
2068
+ queryParams
2069
+ });
2070
+ }
2071
+ /**
2072
+ * Get entity by ID
2073
+ *
2074
+ * Retrieve a specific entity by its ID
2075
+ * @param id — The entity ID
2076
+ */
2077
+ async getEntityById(id) {
2078
+ const pathParams = {
2079
+ "id": id
2080
+ };
2081
+ return this._http.request({
2082
+ method: "GET",
2083
+ path: "/api/entities/{id}",
2084
+ pathParams
2085
+ });
2086
+ }
2087
+ /**
2088
+ * Get memories mentioning entity
2089
+ *
2090
+ * Get all memories that mention a specific entity
2091
+ * @param id — The entity ID
2092
+ * @param options — Optional parameters
2093
+ */
2094
+ async getEntityMemories(id, options) {
2095
+ const pathParams = {
2096
+ "id": id
2097
+ };
2098
+ const queryParams = {
2099
+ "limit": options?.limit,
2100
+ "offset": options?.offset
2101
+ };
2102
+ return this._http.request({
2103
+ method: "GET",
2104
+ path: "/api/entities/{id}/memories",
2105
+ pathParams,
2106
+ queryParams
2107
+ });
2108
+ }
2109
+ /**
2110
+ * Get graph health metrics
2111
+ *
2112
+ * Returns knowledge graph health metrics including entity counts, fact counts, topic counts, and extraction coverage
2113
+ */
2114
+ async getGraphHealth() {
2115
+ const pathParams = {};
2116
+ return this._http.request({
2117
+ method: "GET",
2118
+ path: "/api/entities/health",
2119
+ pathParams
2120
+ });
2121
+ }
2122
+ };
2123
+
2124
+ // src/services/conversations.ts
2125
+ var Conversations = class {
2126
+ _http;
2127
+ constructor(http) {
2128
+ this._http = http;
2129
+ }
2130
+ /**
2131
+ * List conversations
2132
+ *
2133
+ * List all conversations for the authenticated user with pagination
2134
+ * @param options — Optional parameters
2135
+ */
2136
+ async listConversations(options) {
2137
+ const pathParams = {};
2138
+ const queryParams = {
2139
+ "limit": options?.limit,
2140
+ "offset": options?.offset,
2141
+ "since": options?.since,
2142
+ "sortBy": options?.sortBy,
2143
+ "order": options?.order,
2144
+ "minMemories": options?.minMemories
2145
+ };
2146
+ return this._http.request({
2147
+ method: "GET",
2148
+ path: "/api/conversations",
2149
+ pathParams,
2150
+ queryParams
2151
+ });
2152
+ }
2153
+ /**
2154
+ * Create conversation
2155
+ *
2156
+ * Create a new conversation for the authenticated user
2157
+ * @param body — Request body
2158
+ */
2159
+ async createConversation(body) {
2160
+ const pathParams = {};
2161
+ return this._http.request({
2162
+ method: "POST",
2163
+ path: "/api/conversations",
2164
+ pathParams,
2165
+ body
2166
+ });
2167
+ }
2168
+ /**
2169
+ * Get conversation summary
2170
+ *
2171
+ * Retrieve a conversation summary by its ID
2172
+ * @param conversationId — The conversation ID
2173
+ */
2174
+ async getConversationSummary(conversationId) {
2175
+ const pathParams = {
2176
+ "conversationId": conversationId
2177
+ };
2178
+ return this._http.request({
2179
+ method: "GET",
2180
+ path: "/api/conversations/{conversationId}",
2181
+ pathParams
2182
+ });
2183
+ }
2184
+ /**
2185
+ * Delete conversation
2186
+ *
2187
+ * Delete a conversation and soft-delete all associated memories
2188
+ * @param conversationId — The conversation ID
2189
+ */
2190
+ async deleteConversation(conversationId) {
2191
+ const pathParams = {
2192
+ "conversationId": conversationId
2193
+ };
2194
+ return this._http.request({
2195
+ method: "DELETE",
2196
+ path: "/api/conversations/{conversationId}",
2197
+ pathParams
2198
+ });
2199
+ }
2200
+ /**
2201
+ * Get conversation timeline
2202
+ *
2203
+ * Get all memories in a conversation in chronological order
2204
+ * @param conversationId — The conversation ID
2205
+ */
2206
+ async getConversationTimeline(conversationId) {
2207
+ const pathParams = {
2208
+ "conversationId": conversationId
2209
+ };
2210
+ return this._http.request({
2211
+ method: "GET",
2212
+ path: "/api/conversations/{conversationId}/timeline",
2213
+ pathParams
2214
+ });
2215
+ }
2216
+ /**
2217
+ * Search conversations
2218
+ *
2219
+ * Search conversations by query string
2220
+ * @param body — Request body
2221
+ */
2222
+ async searchConversations(body) {
2223
+ const pathParams = {};
2224
+ return this._http.request({
2225
+ method: "POST",
2226
+ path: "/api/conversations/search",
2227
+ pathParams,
2228
+ body
2229
+ });
2230
+ }
2231
+ /**
2232
+ * Find conversations by topic
2233
+ *
2234
+ * Find conversations that contain a specific topic
2235
+ * @param body — Request body
2236
+ */
2237
+ async findConversationsByTopic(body) {
2238
+ const pathParams = {};
2239
+ return this._http.request({
2240
+ method: "POST",
2241
+ path: "/api/conversations/by-topic",
2242
+ pathParams,
2243
+ body
2244
+ });
2245
+ }
2246
+ };
2247
+
2248
+ // src/services/billing.ts
2249
+ var Billing = class {
2250
+ _http;
2251
+ constructor(http) {
2252
+ this._http = http;
2253
+ }
2254
+ /**
2255
+ * Get billing overview
2256
+ *
2257
+ * Get subscription, payment method, and upcoming invoice information
2258
+ */
2259
+ async getBillingOverview() {
2260
+ const pathParams = {};
2261
+ return this._http.request({
2262
+ method: "GET",
2263
+ path: "/api/billing/overview",
2264
+ pathParams
2265
+ });
2266
+ }
2267
+ /**
2268
+ * Create checkout session
2269
+ *
2270
+ * Create a Stripe checkout session for subscription upgrade
2271
+ * @param body — Request body
2272
+ */
2273
+ async createCheckoutSession(body) {
2274
+ const pathParams = {};
2275
+ return this._http.request({
2276
+ method: "POST",
2277
+ path: "/api/billing/checkout",
2278
+ pathParams,
2279
+ body
2280
+ });
2281
+ }
2282
+ /**
2283
+ * Create billing portal session
2284
+ *
2285
+ * Create a Stripe billing portal session for managing subscription
2286
+ * @param body — Request body
2287
+ */
2288
+ async createPortalSession(body) {
2289
+ const pathParams = {};
2290
+ return this._http.request({
2291
+ method: "POST",
2292
+ path: "/api/billing/portal",
2293
+ pathParams,
2294
+ body
2295
+ });
2296
+ }
2297
+ /**
2298
+ * Get current subscription
2299
+ *
2300
+ * Get the current subscription details for the authenticated user
2301
+ */
2302
+ async getSubscription() {
2303
+ const pathParams = {};
2304
+ return this._http.request({
2305
+ method: "GET",
2306
+ path: "/api/billing/subscription",
2307
+ pathParams
2308
+ });
2309
+ }
2310
+ /**
2311
+ * Cancel subscription
2312
+ *
2313
+ * Cancel the current subscription at the end of the billing period
2314
+ * @param options — Optional parameters
2315
+ */
2316
+ async cancelSubscription(options) {
2317
+ const pathParams = {};
2318
+ return this._http.request({
2319
+ method: "POST",
2320
+ path: "/api/billing/subscription/cancel",
2321
+ pathParams,
2322
+ body: options?.body
2323
+ });
2324
+ }
2325
+ /**
2326
+ * Reactivate subscription
2327
+ *
2328
+ * Reactivate a subscription that was scheduled for cancellation
2329
+ * @param options — Optional parameters
2330
+ */
2331
+ async reactivateSubscription(options) {
2332
+ const pathParams = {};
2333
+ return this._http.request({
2334
+ method: "POST",
2335
+ path: "/api/billing/subscription/reactivate",
2336
+ pathParams,
2337
+ body: options?.body
2338
+ });
2339
+ }
2340
+ /**
2341
+ * List invoices
2342
+ *
2343
+ * Get a list of invoices for the authenticated user
2344
+ * @param options — Optional parameters
2345
+ */
2346
+ async listInvoices(options) {
2347
+ const pathParams = {};
2348
+ const queryParams = {
2349
+ "limit": options?.limit
2350
+ };
2351
+ return this._http.request({
2352
+ method: "GET",
2353
+ path: "/api/billing/invoices",
2354
+ pathParams,
2355
+ queryParams
2356
+ });
2357
+ }
2358
+ /**
2359
+ * List payment methods
2360
+ *
2361
+ * Get a list of payment methods for the authenticated user
2362
+ */
2363
+ async listPaymentMethods() {
2364
+ const pathParams = {};
2365
+ return this._http.request({
2366
+ method: "GET",
2367
+ path: "/api/billing/payment-methods",
2368
+ pathParams
2369
+ });
2370
+ }
2371
+ /**
2372
+ * Set default payment method
2373
+ *
2374
+ * Set a payment method as the default for future payments
2375
+ * @param id — The payment method ID
2376
+ * @param options — Optional parameters
2377
+ */
2378
+ async setDefaultPaymentMethod(id, options) {
2379
+ const pathParams = {
2380
+ "id": id
2381
+ };
2382
+ return this._http.request({
2383
+ method: "POST",
2384
+ path: "/api/billing/payment-methods/{id}/default",
2385
+ pathParams,
2386
+ body: options?.body
2387
+ });
2388
+ }
2389
+ /**
2390
+ * Delete payment method
2391
+ *
2392
+ * Remove a payment method from the account
2393
+ * @param id — The payment method ID
2394
+ */
2395
+ async deletePaymentMethod(id) {
2396
+ const pathParams = {
2397
+ "id": id
2398
+ };
2399
+ return this._http.request({
2400
+ method: "DELETE",
2401
+ path: "/api/billing/payment-methods/{id}",
2402
+ pathParams
2403
+ });
2404
+ }
2405
+ /**
2406
+ * Stripe webhook endpoint
2407
+ *
2408
+ * Receive and process Stripe webhook events
2409
+ * @param body — Request body
2410
+ */
2411
+ async stripeWebhook(body) {
2412
+ const pathParams = {};
2413
+ return this._http.request({
2414
+ method: "POST",
2415
+ path: "/api/billing/webhooks",
2416
+ pathParams,
2417
+ body
2418
+ });
2419
+ }
2420
+ };
2421
+
2422
+ // src/services/artifacts.ts
2423
+ var Artifacts = class {
2424
+ _http;
2425
+ constructor(http) {
2426
+ this._http = http;
2427
+ }
2428
+ /**
2429
+ * List artifacts
2430
+ *
2431
+ * List all artifacts for the authenticated user with optional filters
2432
+ * @param options — Optional parameters
2433
+ */
2434
+ async listArtifacts(options) {
2435
+ const pathParams = {};
2436
+ const queryParams = {
2437
+ "limit": options?.limit,
2438
+ "offset": options?.offset,
2439
+ "memoryId": options?.memoryId,
2440
+ "conversationId": options?.conversationId,
2441
+ "type": options?.type$
2442
+ };
2443
+ return this._http.request({
2444
+ method: "GET",
2445
+ path: "/api/artifacts",
2446
+ pathParams,
2447
+ queryParams
2448
+ });
2449
+ }
2450
+ /**
2451
+ * Create artifact
2452
+ *
2453
+ * Create a new artifact for the authenticated user
2454
+ * @param body — Request body
2455
+ */
2456
+ async createArtifact(body) {
2457
+ const pathParams = {};
2458
+ return this._http.request({
2459
+ method: "POST",
2460
+ path: "/api/artifacts",
2461
+ pathParams,
2462
+ body
2463
+ });
2464
+ }
2465
+ /**
2466
+ * Get artifact by ID
2467
+ *
2468
+ * Retrieve a specific artifact by its ID
2469
+ * @param id — The artifact ID
2470
+ */
2471
+ async getArtifactById(id) {
2472
+ const pathParams = {
2473
+ "id": id
2474
+ };
2475
+ return this._http.request({
2476
+ method: "GET",
2477
+ path: "/api/artifacts/{id}",
2478
+ pathParams
2479
+ });
2480
+ }
2481
+ /**
2482
+ * Delete artifact
2483
+ *
2484
+ * Delete an artifact by its ID
2485
+ * @param id — The artifact ID
2486
+ */
2487
+ async deleteArtifact(id) {
2488
+ const pathParams = {
2489
+ "id": id
2490
+ };
2491
+ return this._http.request({
2492
+ method: "DELETE",
2493
+ path: "/api/artifacts/{id}",
2494
+ pathParams
2495
+ });
2496
+ }
2497
+ /**
2498
+ * Update artifact
2499
+ *
2500
+ * Update an existing artifact with partial data
2501
+ * @param id — The artifact ID
2502
+ * @param body — Request body
2503
+ */
2504
+ async updateArtifact(id, body) {
2505
+ const pathParams = {
2506
+ "id": id
2507
+ };
2508
+ return this._http.request({
2509
+ method: "PATCH",
2510
+ path: "/api/artifacts/{id}",
2511
+ pathParams,
2512
+ body
2513
+ });
2514
+ }
2515
+ };
2516
+
2517
+ // src/services/api-keys.ts
2518
+ var ApiKeys = class {
2519
+ _http;
2520
+ constructor(http) {
2521
+ this._http = http;
2522
+ }
2523
+ /**
2524
+ * Get user information for current API key
2525
+ *
2526
+ * Debug endpoint to retrieve user ID and authentication method from the current API key
2527
+ */
2528
+ async debugUser() {
2529
+ const pathParams = {};
2530
+ return this._http.request({
2531
+ method: "GET",
2532
+ path: "/api/apikeys/debug-user",
2533
+ pathParams
2534
+ });
2535
+ }
2536
+ /**
2537
+ * List API keys
2538
+ *
2539
+ * List all API keys for the authenticated user
2540
+ */
2541
+ async listApiKeys() {
2542
+ const pathParams = {};
2543
+ return this._http.request({
2544
+ method: "GET",
2545
+ path: "/api/apikeys",
2546
+ pathParams
2547
+ });
2548
+ }
2549
+ /**
2550
+ * Create API key
2551
+ *
2552
+ * Create a new API key for the authenticated user
2553
+ * @param options — Optional parameters
2554
+ */
2555
+ async createApiKey(options) {
2556
+ const pathParams = {};
2557
+ return this._http.request({
2558
+ method: "POST",
2559
+ path: "/api/apikeys",
2560
+ pathParams,
2561
+ body: options?.body
2562
+ });
2563
+ }
2564
+ /**
2565
+ * Delete API key
2566
+ *
2567
+ * Delete (revoke) an API key by its ID
2568
+ * @param id — The API key ID
2569
+ */
2570
+ async deleteApiKey(id) {
2571
+ const pathParams = {
2572
+ "id": id
2573
+ };
2574
+ return this._http.request({
2575
+ method: "DELETE",
2576
+ path: "/api/apikeys/{id}",
2577
+ pathParams
2578
+ });
2579
+ }
2580
+ };
2581
+
2582
+ // src/services/alerts.ts
2583
+ var Alerts = class {
2584
+ _http;
2585
+ constructor(http) {
2586
+ this._http = http;
2587
+ }
2588
+ /**
2589
+ * List active system alerts for the current user
2590
+ *
2591
+ * Returns all active, non-expired system alerts that target either
2592
+ * all users or the authenticated user specifically. Used by the
2593
+ * customer portal to render the system alerts banner.
2594
+ *
2595
+ */
2596
+ async getActiveSystemAlerts() {
2597
+ const pathParams = {};
2598
+ return this._http.request({
2599
+ method: "GET",
2600
+ path: "/api/alerts/active",
2601
+ pathParams
2602
+ });
2603
+ }
2604
+ };
2605
+
2606
+ // src/services/admin.ts
2607
+ var Admin = class {
2608
+ _http;
2609
+ constructor(http) {
2610
+ this._http = http;
2611
+ }
2612
+ /**
2613
+ * List invite codes
2614
+ *
2615
+ * List all invite codes with optional status filter
2616
+ * @param options — Optional parameters
2617
+ */
2618
+ async adminListInviteCodes(options) {
2619
+ const pathParams = {};
2620
+ const queryParams = {
2621
+ "status": options?.status,
2622
+ "limit": options?.limit,
2623
+ "offset": options?.offset
2624
+ };
2625
+ return this._http.request({
2626
+ method: "GET",
2627
+ path: "/api/admin/invites",
2628
+ pathParams,
2629
+ queryParams
2630
+ });
2631
+ }
2632
+ /**
2633
+ * Create invite code
2634
+ *
2635
+ * Create a new invite code for the gated preview
2636
+ * @param body — Request body
2637
+ */
2638
+ async adminCreateInviteCode(body) {
2639
+ const pathParams = {};
2640
+ return this._http.request({
2641
+ method: "POST",
2642
+ path: "/api/admin/invites",
2643
+ pathParams,
2644
+ body
2645
+ });
2646
+ }
2647
+ /**
2648
+ * Get invite system statistics
2649
+ *
2650
+ * Aggregate statistics for the invite system
2651
+ */
2652
+ async adminGetInviteStats() {
2653
+ const pathParams = {};
2654
+ return this._http.request({
2655
+ method: "GET",
2656
+ path: "/api/admin/invites/stats",
2657
+ pathParams
2658
+ });
2659
+ }
2660
+ /**
2661
+ * Get invite code details
2662
+ *
2663
+ * Get details for a single invite code including redemptions
2664
+ * @param code — The invite code
2665
+ */
2666
+ async adminGetInviteCode(code) {
2667
+ const pathParams = {
2668
+ "code": code
2669
+ };
2670
+ return this._http.request({
2671
+ method: "GET",
2672
+ path: "/api/admin/invites/{code}",
2673
+ pathParams
2674
+ });
2675
+ }
2676
+ /**
2677
+ * Revoke an invite code
2678
+ *
2679
+ * Revoke an invite code. Existing accounts created with this code are unaffected.
2680
+ * @param code
2681
+ */
2682
+ async adminRevokeInviteCode(code) {
2683
+ const pathParams = {
2684
+ "code": code
2685
+ };
2686
+ return this._http.request({
2687
+ method: "DELETE",
2688
+ path: "/api/admin/invites/{code}",
2689
+ pathParams
2690
+ });
2691
+ }
2692
+ /**
2693
+ * Get gate status with audit info
2694
+ *
2695
+ * Get current invite gate state with audit information
2696
+ */
2697
+ async adminGetGateStatus() {
2698
+ const pathParams = {};
2699
+ return this._http.request({
2700
+ method: "GET",
2701
+ path: "/api/admin/gate",
2702
+ pathParams
2703
+ });
2704
+ }
2705
+ /**
2706
+ * Toggle invite gate
2707
+ *
2708
+ * Toggle the invite gate. When enabled (true), new signups require a valid invite code.
2709
+ * When disabled (false), registration is open. Takes effect immediately.
2710
+ *
2711
+ * @param body — Request body
2712
+ */
2713
+ async adminSetGateStatus(body) {
2714
+ const pathParams = {};
2715
+ return this._http.request({
2716
+ method: "POST",
2717
+ path: "/api/admin/gate",
2718
+ pathParams,
2719
+ body
2720
+ });
2721
+ }
2722
+ /**
2723
+ * Backfill per-stage memory pipeline status fields by inspecting actual graph state
2724
+ * @param options — Optional parameters
2725
+ */
2726
+ async adminMigratePerStageStatus(options) {
2727
+ const pathParams = {};
2728
+ return this._http.request({
2729
+ method: "POST",
2730
+ path: "/api/admin/migrate/per-stage-status",
2731
+ pathParams,
2732
+ body: options?.body
2733
+ });
2734
+ }
2735
+ };
2736
+
2737
+ // src/services/admin-alerts.ts
2738
+ var AdminAlerts = class {
2739
+ _http;
2740
+ constructor(http) {
2741
+ this._http = http;
2742
+ }
2743
+ /**
2744
+ * List system alerts
2745
+ * @param options — Optional parameters
2746
+ */
2747
+ async adminListSystemAlerts(options) {
2748
+ const pathParams = {};
2749
+ const queryParams = {
2750
+ "activeOnly": options?.activeOnly
2751
+ };
2752
+ return this._http.request({
2753
+ method: "GET",
2754
+ path: "/api/admin/alerts",
2755
+ pathParams,
2756
+ queryParams
2757
+ });
2758
+ }
2759
+ /**
2760
+ * Create a system alert
2761
+ * @param body — Request body
2762
+ */
2763
+ async adminCreateSystemAlert(body) {
2764
+ const pathParams = {};
2765
+ return this._http.request({
2766
+ method: "POST",
2767
+ path: "/api/admin/alerts",
2768
+ pathParams,
2769
+ body
2770
+ });
2771
+ }
2772
+ /**
2773
+ * Get a system alert by id
2774
+ * @param id — System alert id
2775
+ */
2776
+ async adminGetSystemAlert(id) {
2777
+ const pathParams = {
2778
+ "id": id
2779
+ };
2780
+ return this._http.request({
2781
+ method: "GET",
2782
+ path: "/api/admin/alerts/{id}",
2783
+ pathParams
2784
+ });
2785
+ }
2786
+ /**
2787
+ * Delete a system alert
2788
+ * @param id — System alert id
2789
+ */
2790
+ async adminDeleteSystemAlert(id) {
2791
+ const pathParams = {
2792
+ "id": id
2793
+ };
2794
+ return this._http.request({
2795
+ method: "DELETE",
2796
+ path: "/api/admin/alerts/{id}",
2797
+ pathParams
2798
+ });
2799
+ }
2800
+ /**
2801
+ * Update a system alert
2802
+ * @param id
2803
+ * @param body — Request body
2804
+ */
2805
+ async adminUpdateSystemAlert(id, body) {
2806
+ const pathParams = {
2807
+ "id": id
2808
+ };
2809
+ return this._http.request({
2810
+ method: "PATCH",
2811
+ path: "/api/admin/alerts/{id}",
2812
+ pathParams,
2813
+ body
2814
+ });
2815
+ }
2816
+ };
2817
+
2818
+ // src/services/admin-pipeline.ts
2819
+ var AdminPipeline = class {
2820
+ _http;
2821
+ constructor(http) {
2822
+ this._http = http;
2823
+ }
2824
+ /**
2825
+ * Re-enqueue a single memory through one pipeline
2826
+ *
2827
+ * Admin-only. Re-publishes the requested pipeline job for the given
2828
+ * memory and resets the corresponding per-stage status field(s) to
2829
+ * `queued`. Used to recover individual memories from transient
2830
+ * worker failures or to replay a stage after a code change.
2831
+ *
2832
+ * @param id — Memory id (admin can target any tenant).
2833
+ * @param body — Request body
2834
+ */
2835
+ async adminRerunMemoryPipeline(id, body) {
2836
+ const pathParams = {
2837
+ "id": id
2838
+ };
2839
+ return this._http.request({
2840
+ method: "POST",
2841
+ path: "/api/admin/memories/{id}/rerun",
2842
+ pathParams,
2843
+ body
2844
+ });
2845
+ }
2846
+ /**
2847
+ * Per-queue depth + failure counts for the memory-creation pipelines
2848
+ *
2849
+ * Returns BullMQ `getJobCounts()` for each known pipeline queue. Queues
2850
+ * that have not yet been provisioned (e.g. `summary-qna` while task 2.3
2851
+ * is in flight) are reported with `{ status: "not_configured" }` rather
2852
+ * than throwing.
2853
+ *
2854
+ */
2855
+ async adminGetPipelineHealth() {
2856
+ const pathParams = {};
2857
+ return this._http.request({
2858
+ method: "GET",
2859
+ path: "/api/admin/pipeline/health",
2860
+ pathParams
2861
+ });
2862
+ }
2863
+ /**
2864
+ * Inspect per-stage pipeline status for a single memory
2865
+ *
2866
+ * Debugging affordance — returns the six per-stage status fields and graphSkipReason.
2867
+ * @param id
2868
+ */
2869
+ async adminGetMemoryPipelineStatus(id) {
2870
+ const pathParams = {
2871
+ "id": id
2872
+ };
2873
+ return this._http.request({
2874
+ method: "GET",
2875
+ path: "/api/admin/memories/{id}/pipeline-status",
2876
+ pathParams
2877
+ });
2878
+ }
2879
+ };
2880
+
2881
+ // src/client.ts
2882
+ var MemNexus = class {
2883
+ _http;
2884
+ /** User management and profile endpoints */
2885
+ users;
2886
+ /** Topic detection, clustering, and management endpoints */
2887
+ topics;
2888
+ /** System health, monitoring, and configuration endpoints */
2889
+ system;
2890
+ /** Pattern detection and behavioral analysis endpoints */
2891
+ patterns;
2892
+ /** Behavioral pattern tracking and state management endpoints */
2893
+ behavior;
2894
+ /** Behavioral recommendation management endpoints (v2) */
2895
+ recommendations;
2896
+ /** Narrative thread management endpoints */
2897
+ narratives;
2898
+ /** Observability and metrics endpoints for production monitoring */
2899
+ monitoring;
2900
+ /** Memory management and retrieval endpoints */
2901
+ memories;
2902
+ /** Invite code validation and gate status endpoints */
2903
+ invites;
2904
+ /** Health check endpoints */
2905
+ health;
2906
+ /** Graph-based retrieval augmented generation endpoints */
2907
+ graphrag;
2908
+ /** Fact extraction and management endpoints */
2909
+ facts;
2910
+ /** Entity extraction and discovery endpoints */
2911
+ entities;
2912
+ /** Conversation tracking and analysis endpoints */
2913
+ conversations;
2914
+ /** Subscription billing and payment management endpoints */
2915
+ billing;
2916
+ /** Artifact storage and retrieval endpoints */
2917
+ artifacts;
2918
+ /** API key management endpoints */
2919
+ apiKeys;
2920
+ /** System alerts banner endpoints (customer portal) */
2921
+ alerts;
2922
+ /** Admin management endpoints for invite codes and platform configuration */
2923
+ admin;
2924
+ /** Admin endpoints for managing system alerts */
2925
+ adminAlerts;
2926
+ /** Admin Pipeline operations */
2927
+ adminPipeline;
2928
+ constructor(options = {}) {
2929
+ this._http = new HttpClient({ baseUrl: "https://api.memnexus.ai", ...options });
2930
+ this.users = new Users(this._http);
2931
+ this.topics = new Topics(this._http);
2932
+ this.system = new System(this._http);
2933
+ this.patterns = new Patterns(this._http);
2934
+ this.behavior = new Behavior(this._http);
2935
+ this.recommendations = new Recommendations(this._http);
2936
+ this.narratives = new Narratives(this._http);
2937
+ this.monitoring = new Monitoring(this._http);
2938
+ this.memories = new Memories(this._http);
2939
+ this.invites = new Invites(this._http);
2940
+ this.health = new Health(this._http);
2941
+ this.graphrag = new Graphrag(this._http);
2942
+ this.facts = new Facts(this._http);
2943
+ this.entities = new Entities(this._http);
2944
+ this.conversations = new Conversations(this._http);
2945
+ this.billing = new Billing(this._http);
2946
+ this.artifacts = new Artifacts(this._http);
2947
+ this.apiKeys = new ApiKeys(this._http);
2948
+ this.alerts = new Alerts(this._http);
2949
+ this.admin = new Admin(this._http);
2950
+ this.adminAlerts = new AdminAlerts(this._http);
2951
+ this.adminPipeline = new AdminPipeline(this._http);
2952
+ }
2953
+ /**
2954
+ * Save a memory.
2955
+ * Convenience wrapper around `memories.createMemory`.
2956
+ *
2957
+ * @param content — The memory content to save.
2958
+ * @param extra — Additional fields passed to CreateMemoryRequest.
2959
+ */
2960
+ async remember(content, extra = {}) {
2961
+ return this.memories.createMemory({ content, ...extra });
2962
+ }
2963
+ /**
2964
+ * Get an AI-synthesized recall digest.
2965
+ * Convenience wrapper.
2966
+ *
2967
+ * @param query — The recall query or topic.
2968
+ */
2969
+ async recall(query, extra = {}) {
2970
+ return this.memories.generateMemoryDigest({ query, ...extra });
2971
+ }
2972
+ /**
2973
+ * Search memories.
2974
+ * Convenience wrapper.
2975
+ *
2976
+ * @param query — The search query.
2977
+ */
2978
+ async search(query, extra = {}) {
2979
+ return this.memories.searchMemories({ query, ...extra });
2980
+ }
2981
+ /**
2982
+ * Build a context briefing.
2983
+ * Convenience wrapper.
2984
+ *
2985
+ * @param context — Context description for the briefing.
2986
+ */
2987
+ async brief(context, extra = {}) {
2988
+ return this.memories.buildContext({ context, ...extra });
2989
+ }
2990
+ /**
2991
+ * Delete a memory by ID.
2992
+ * Convenience wrapper.
2993
+ *
2994
+ * @param memoryId — The ID of the memory to delete.
2995
+ */
2996
+ async forget(memoryId) {
2997
+ return this.memories.deleteMemory(memoryId);
2998
+ }
2999
+ };
3000
+ // Annotate the CommonJS export names for ESM import in node:
3001
+ 0 && (module.exports = {
3002
+ MemNexus,
3003
+ SdkError
3004
+ });