@memnexus-ai/typescript-sdk 1.45.0 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -49,6 +49,14 @@ __export(index_exports, {
49
49
  batchGetMemoriesRequest: () => batchGetMemoriesRequest,
50
50
  batchGetMemoriesResponse: () => batchGetMemoriesResponse,
51
51
  billingOverview: () => billingOverview,
52
+ buildContextActiveWork: () => buildContextActiveWork,
53
+ buildContextActivity: () => buildContextActivity,
54
+ buildContextFact: () => buildContextFact,
55
+ buildContextGotcha: () => buildContextGotcha,
56
+ buildContextMeta: () => buildContextMeta,
57
+ buildContextPattern: () => buildContextPattern,
58
+ buildContextRequest: () => buildContextRequest,
59
+ buildContextResponse: () => buildContextResponse,
52
60
  checkoutSessionResponse: () => checkoutSessionResponse,
53
61
  community: () => community,
54
62
  conversation: () => conversation,
@@ -63,11 +71,14 @@ __export(index_exports, {
63
71
  createNarrativeRequest: () => createNarrativeRequest,
64
72
  createPortalSessionRequest: () => createPortalSessionRequest,
65
73
  default: () => index_default,
74
+ digestEntity: () => digestEntity,
75
+ digestKeyFact: () => digestKeyFact,
66
76
  digestMetadata: () => digestMetadata,
67
77
  digestRequest: () => digestRequest,
68
78
  digestResponse: () => digestResponse,
69
79
  digestSource: () => digestSource,
70
80
  digestTimeRange: () => digestTimeRange,
81
+ effectiveStateBreakdown: () => effectiveStateBreakdown,
71
82
  entity: () => entity,
72
83
  entityNode: () => entityNode,
73
84
  error: () => error,
@@ -2628,6 +2639,34 @@ var MemoriesService = class extends BaseService {
2628
2639
  }
2629
2640
  return this.client.call(request);
2630
2641
  }
2642
+ /**
2643
+ * Build a context briefing
2644
+ * Answers "What should I know before working on X?" by combining active work
2645
+ detection, fact retrieval, gotcha detection, recent activity, and pattern
2646
+ matching into a single call. Eliminates the 5+ round-trip pattern agents
2647
+ use today.
2648
+
2649
+ * @param body - Request body
2650
+ */
2651
+ async buildContext(body) {
2652
+ const request = new Request({
2653
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
2654
+ method: "POST",
2655
+ path: "/api/memories/build-context",
2656
+ config: this.config,
2657
+ retry: {
2658
+ attempts: 3,
2659
+ delayMs: 150,
2660
+ maxDelayMs: 5e3,
2661
+ jitterMs: 50,
2662
+ backoffFactor: 2
2663
+ }
2664
+ });
2665
+ if (body !== void 0) {
2666
+ request.addBody(body);
2667
+ }
2668
+ return this.client.call(request);
2669
+ }
2631
2670
  /**
2632
2671
  * Get version history for a named memory
2633
2672
  * Returns the full version chain for a named memory, ordered newest-first.
@@ -5854,13 +5893,124 @@ var digestSource = import_zod.z.object({
5854
5893
  /** Conversation ID this memory belongs to */
5855
5894
  conversation: import_zod.z.string().optional()
5856
5895
  });
5896
+ var digestKeyFact = import_zod.z.object({
5897
+ /** Fact subject */
5898
+ subject: import_zod.z.string(),
5899
+ /** Relationship type */
5900
+ predicate: import_zod.z.string(),
5901
+ /** Fact value */
5902
+ object: import_zod.z.string(),
5903
+ /** Confidence score */
5904
+ confidence: import_zod.z.number().min(0).max(1)
5905
+ });
5906
+ var digestEntity = import_zod.z.object({
5907
+ /** Entity name */
5908
+ name: import_zod.z.string(),
5909
+ /** Entity type */
5910
+ type: import_zod.z.string()
5911
+ });
5912
+ var effectiveStateBreakdown = import_zod.z.object({
5913
+ /** Active memories used in synthesis */
5914
+ current: import_zod.z.number().min(0),
5915
+ /** Superseded memories (deprioritized in synthesis) */
5916
+ superseded: import_zod.z.number().min(0),
5917
+ /** Contradicted memories (deprioritized in synthesis) */
5918
+ contradicted: import_zod.z.number().min(0)
5919
+ });
5857
5920
  var digestResponse = import_zod.z.lazy(() => import_zod.z.object({
5858
5921
  /** The generated digest content (markdown formatted) */
5859
5922
  digest: import_zod.z.string(),
5860
5923
  /** Generation metadata including source statistics */
5861
5924
  metadata: digestMetadata,
5862
5925
  /** Source memories used to generate the digest, for traceability */
5863
- sources: import_zod.z.array(digestSource)
5926
+ sources: import_zod.z.array(digestSource),
5927
+ /** Top extracted facts relevant to the digest, deduplicated and ranked by frequency */
5928
+ keyFacts: import_zod.z.array(digestKeyFact).optional(),
5929
+ /** Key entities mentioned across source memories */
5930
+ entities: import_zod.z.array(digestEntity).optional(),
5931
+ /** Breakdown of source memories by effective state (current/superseded/contradicted) */
5932
+ effectiveStateBreakdown: effectiveStateBreakdown.optional()
5933
+ }));
5934
+ var buildContextRequest = import_zod.z.object({
5935
+ /** What you are about to work on */
5936
+ context: import_zod.z.string().min(1).max(2e3),
5937
+ /** File paths you will be touching */
5938
+ files: import_zod.z.array(import_zod.z.string()).optional(),
5939
+ /** How far back to look for recent activity (hours, default 24) */
5940
+ recentHours: import_zod.z.number().min(1).max(720).optional()
5941
+ });
5942
+ var buildContextActiveWork = import_zod.z.object({
5943
+ /** Conversation ID */
5944
+ conversationId: import_zod.z.string(),
5945
+ /** Conversation title */
5946
+ title: import_zod.z.string().nullable(),
5947
+ /** ISO 8601 timestamp of last activity */
5948
+ lastActivity: import_zod.z.string(),
5949
+ /** Most recent memory in this conversation */
5950
+ lastMemory: import_zod.z.object({
5951
+ /** Memory ID */
5952
+ id: import_zod.z.string(),
5953
+ /** Truncated content summary */
5954
+ summary: import_zod.z.string()
5955
+ })
5956
+ }).nullable();
5957
+ var buildContextFact = import_zod.z.object({
5958
+ /** Fact subject */
5959
+ subject: import_zod.z.string(),
5960
+ /** Fact predicate */
5961
+ predicate: import_zod.z.string(),
5962
+ /** Fact object */
5963
+ object: import_zod.z.string(),
5964
+ /** Confidence score (0-1) */
5965
+ confidence: import_zod.z.number(),
5966
+ /** Memory this fact was extracted from */
5967
+ sourceMemoryId: import_zod.z.string()
5968
+ });
5969
+ var buildContextGotcha = import_zod.z.object({
5970
+ /** The gotcha fact text */
5971
+ fact: import_zod.z.string(),
5972
+ /** Number of distinct source memories mentioning this */
5973
+ sourceCount: import_zod.z.number(),
5974
+ /** Source memory IDs */
5975
+ sourceMemories: import_zod.z.array(import_zod.z.string()),
5976
+ /** ISO 8601 timestamp of most recent source */
5977
+ lastSeen: import_zod.z.string()
5978
+ });
5979
+ var buildContextActivity = import_zod.z.object({
5980
+ /** Memory ID */
5981
+ id: import_zod.z.string(),
5982
+ /** Truncated content summary (max 200 chars) */
5983
+ summary: import_zod.z.string(),
5984
+ /** ISO 8601 timestamp */
5985
+ date: import_zod.z.string(),
5986
+ /** Conversation ID */
5987
+ conversationId: import_zod.z.string().nullable()
5988
+ });
5989
+ var buildContextPattern = import_zod.z.object({
5990
+ /** Pattern description */
5991
+ pattern: import_zod.z.string(),
5992
+ /** Confidence score (0-1) */
5993
+ confidence: import_zod.z.number()
5994
+ });
5995
+ var buildContextMeta = import_zod.z.object({
5996
+ /** Search terms extracted from the context and files */
5997
+ contextTerms: import_zod.z.array(import_zod.z.string()),
5998
+ /** Hours window used for recent activity */
5999
+ recentHours: import_zod.z.number()
6000
+ });
6001
+ var buildContextResponse = import_zod.z.lazy(() => import_zod.z.object({
6002
+ /** Most relevant active conversation, or null if none found */
6003
+ activeWork: buildContextActiveWork,
6004
+ /** Facts related to the context terms */
6005
+ relevantFacts: import_zod.z.array(buildContextFact),
6006
+ /** Gotchas — facts appearing in 2+ source memories */
6007
+ gotchas: import_zod.z.array(buildContextGotcha),
6008
+ /** Recent relevant memories within the time window */
6009
+ recentActivity: import_zod.z.array(buildContextActivity),
6010
+ /** Behavioral patterns related to the context */
6011
+ relatedPatterns: import_zod.z.array(buildContextPattern),
6012
+ /** Request metadata for transparency */
6013
+ meta: buildContextMeta
5864
6014
  }));
5865
6015
 
5866
6016
  // src/index.ts
@@ -6038,6 +6188,14 @@ var index_default = Memnexus;
6038
6188
  batchGetMemoriesRequest,
6039
6189
  batchGetMemoriesResponse,
6040
6190
  billingOverview,
6191
+ buildContextActiveWork,
6192
+ buildContextActivity,
6193
+ buildContextFact,
6194
+ buildContextGotcha,
6195
+ buildContextMeta,
6196
+ buildContextPattern,
6197
+ buildContextRequest,
6198
+ buildContextResponse,
6041
6199
  checkoutSessionResponse,
6042
6200
  community,
6043
6201
  conversation,
@@ -6051,11 +6209,14 @@ var index_default = Memnexus;
6051
6209
  createMemoryResponseMeta,
6052
6210
  createNarrativeRequest,
6053
6211
  createPortalSessionRequest,
6212
+ digestEntity,
6213
+ digestKeyFact,
6054
6214
  digestMetadata,
6055
6215
  digestRequest,
6056
6216
  digestResponse,
6057
6217
  digestSource,
6058
6218
  digestTimeRange,
6219
+ effectiveStateBreakdown,
6059
6220
  entity,
6060
6221
  entityNode,
6061
6222
  error,