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