@pyxmate/memory 0.26.1 → 0.26.3

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MemoryClient
3
- } from "./chunk-AKQIZAFT.mjs";
3
+ } from "./chunk-5X2HOMDQ.mjs";
4
4
 
5
5
  // ../dashboard/src/aggregations/consolidation-analytics.ts
6
6
  function analyzeConsolidationLog(entries) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mergeExtractedEntities
3
- } from "./chunk-573W637Y.mjs";
3
+ } from "./chunk-SSUYQJUI.mjs";
4
4
 
5
5
  // ../client/src/memory-client.ts
6
6
  var MemoryServerError = class extends Error {
@@ -125,8 +125,11 @@ var MemoryClient = class {
125
125
  );
126
126
  return result.cleared;
127
127
  }
128
- async stats() {
129
- const stats = await this.fetchApi("/api/memory/stats");
128
+ async stats(options = {}) {
129
+ const searchParams = new URLSearchParams();
130
+ if (options.graphVisibility) searchParams.set("graphVisibility", options.graphVisibility);
131
+ const qs = searchParams.toString();
132
+ const stats = await this.fetchApi(`/api/memory/stats${qs ? `?${qs}` : ""}`);
130
133
  return { ...stats, connected: true };
131
134
  }
132
135
  /**
@@ -517,9 +520,7 @@ var MemoryClient = class {
517
520
  return result.nodes;
518
521
  }
519
522
  async graphEdges() {
520
- return this.fetchApi(
521
- "/api/memory/graph/edges"
522
- );
523
+ return this.fetchApi("/api/memory/graph/edges");
523
524
  }
524
525
  async graphQuery(query) {
525
526
  return this.fetchApi("/api/memory/graph/query", {
@@ -575,6 +576,9 @@ var MemoryClient = class {
575
576
  });
576
577
  return result.deleted;
577
578
  }
579
+ async repairGraph() {
580
+ return this.fetchApi("/api/memory/graph/repair", { method: "POST" });
581
+ }
578
582
  async deleteBySource(source) {
579
583
  const result = await this.fetchApi(
580
584
  `/api/memory/source/${this.encodePathSegment(source)}`,
@@ -630,6 +634,35 @@ var MemoryClient = class {
630
634
  );
631
635
  return result.entry;
632
636
  }
637
+ /**
638
+ * v0.26 user-profile snapshot — upsert. The server derives `userId`
639
+ * from `X-User-Id` (caller wires it via `defaultHeaders` on the
640
+ * client constructor or per-request middleware); the body cannot
641
+ * override it. See spec §Requirements 10.
642
+ */
643
+ async upsertUserProfile(input) {
644
+ return this.fetchApi("/api/memory/profile/user", {
645
+ method: "PUT",
646
+ body: JSON.stringify(input)
647
+ });
648
+ }
649
+ /**
650
+ * v0.26 user-profile snapshot — fetch by namespace. Returns `null` on
651
+ * HTTP 404 (`isNotFound`), rethrows any other non-2xx as
652
+ * `MemoryServerError`. Mirrors `get()`'s 404-to-null pattern so callers
653
+ * can branch on "no profile yet" without inspecting status codes.
654
+ */
655
+ async getUserProfile(namespaceId) {
656
+ const params = new URLSearchParams({ namespaceId });
657
+ try {
658
+ return await this.fetchApi(
659
+ `/api/memory/profile/user?${params}`
660
+ );
661
+ } catch (error) {
662
+ if (error instanceof MemoryServerError && error.isNotFound) return null;
663
+ throw error;
664
+ }
665
+ }
633
666
  async fetchApi(path, options) {
634
667
  const signal = options?.signal ?? AbortSignal.timeout(this._requestTimeoutMs);
635
668
  let res;
@@ -58,9 +58,11 @@ var SensitivityLevel = {
58
58
  var RAGStrategy = {
59
59
  NAIVE: "naive",
60
60
  GRAPH: "graph",
61
- AGENTIC: "agentic",
62
61
  HYBRID: "hybrid"
63
62
  };
63
+ var DEPRECATED_RAG_STRATEGIES = /* @__PURE__ */ new Map([
64
+ ["agentic", "strategy.deprecated:agentic \u2014 removed in v0.26, use hybrid"]
65
+ ]);
64
66
  var VectorProvider = {
65
67
  LANCEDB: "lancedb"
66
68
  };
@@ -110,6 +112,7 @@ export {
110
112
  MemoryType,
111
113
  SensitivityLevel,
112
114
  RAGStrategy,
115
+ DEPRECATED_RAG_STRATEGIES,
113
116
  VectorProvider,
114
117
  EmbeddingProviderName,
115
118
  StoreTarget,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  __export,
4
4
  mergeExtractedEntities
5
- } from "../chunk-573W637Y.mjs";
5
+ } from "../chunk-SSUYQJUI.mjs";
6
6
 
7
7
  // src/cli/exit-codes.ts
8
8
  var EXIT = {
@@ -338,7 +338,7 @@ async function readSingleLineFromStdin() {
338
338
 
339
339
  // src/cli/commands/login.ts
340
340
  var DEFAULT_ENDPOINT = "https://memory.api.pyxmate.com";
341
- var PROBE_PATH = "/api/memory/stats";
341
+ var PROBE_PATH = "/api/memory/stats?graphVisibility=raw";
342
342
  var PROBE_TIMEOUT_MS = 8e3;
343
343
  async function loginCommand(opts = {}) {
344
344
  const provider = opts.keychain ?? getDefaultKeychain();
@@ -15334,11 +15334,66 @@ var listMemoriesTool = {
15334
15334
  }
15335
15335
  };
15336
15336
 
15337
+ // src/mcp/tools/profile.ts
15338
+ var getInputShape = {
15339
+ namespaceId: external_exports.string().min(1).describe("Namespace id whose user-profile to fetch."),
15340
+ ...scopeShape
15341
+ };
15342
+ var getUserProfileTool = {
15343
+ name: "get_user_profile",
15344
+ config: {
15345
+ title: "Get pyx-memory user profile",
15346
+ description: "Fetch the current user-profile snapshot for a namespace. HTTP proxy to GET /api/memory/profile/user \u2014 returns `{content, updatedAt, contentSize}` or a not-found error.",
15347
+ inputSchema: getInputShape,
15348
+ annotations: { readOnlyHint: true, openWorldHint: true }
15349
+ },
15350
+ handler: (deps) => async (raw) => {
15351
+ const args = raw;
15352
+ const creds = await deps.readCredentials();
15353
+ if (!creds.ok) return creds.result;
15354
+ const http = createHttpClient(creds.credentials, deps.fetchImpl);
15355
+ const res = await http.requestJson({
15356
+ method: "GET",
15357
+ path: "/api/memory/profile/user",
15358
+ query: { namespaceId: args.namespaceId },
15359
+ scope: args
15360
+ });
15361
+ return res.ok ? mcpJson(res.data) : res.result;
15362
+ }
15363
+ };
15364
+ var upsertInputShape = {
15365
+ namespaceId: external_exports.string().min(1).describe("Namespace id to upsert the user-profile into."),
15366
+ content: external_exports.string().min(1).describe("Full freeform profile content (UTF-8, \u22648192 bytes; server enforces the cap)."),
15367
+ ...scopeShape
15368
+ };
15369
+ var upsertUserProfileTool = {
15370
+ name: "upsert_user_profile",
15371
+ config: {
15372
+ title: "Upsert pyx-memory user profile",
15373
+ description: "Upsert the user-profile snapshot for a namespace. HTTP proxy to PUT /api/memory/profile/user \u2014 returns `{updatedAt, contentSize}`. Idempotent: re-upsert preserves `createdAt` and refreshes `updatedAt`.",
15374
+ inputSchema: upsertInputShape,
15375
+ annotations: { readOnlyHint: false, openWorldHint: true }
15376
+ },
15377
+ handler: (deps) => async (raw) => {
15378
+ const args = raw;
15379
+ const creds = await deps.readCredentials();
15380
+ if (!creds.ok) return creds.result;
15381
+ const http = createHttpClient(creds.credentials, deps.fetchImpl);
15382
+ const res = await http.requestJson({
15383
+ method: "PUT",
15384
+ path: "/api/memory/profile/user",
15385
+ body: { namespaceId: args.namespaceId, content: args.content },
15386
+ scope: args
15387
+ });
15388
+ return res.ok ? mcpJson(res.data) : res.result;
15389
+ }
15390
+ };
15391
+
15337
15392
  // src/mcp/tools/search.ts
15338
15393
  var inputShape5 = {
15339
15394
  query: external_exports.string().min(1).describe("Required natural-language search text."),
15340
15395
  limit: external_exports.number().int().min(1).max(100).optional().describe("Maximum results; server clamps to 1\u2013100. Default 5."),
15341
- strategy: external_exports.enum(["naive", "graph", "agentic", "hybrid"]).optional().describe(
15396
+ strategy: external_exports.enum(["naive", "graph", "hybrid"]).optional().describe(
15342
15397
  "RAG strategy. Server default is `naive`; use `hybrid` for cross-encoder reranking, multi-entity decomposition, and confidence scoring."
15343
15398
  ),
15344
15399
  type: external_exports.enum(["short-term", "long-term", "working", "episodic", "summary"]).optional().describe("Filter by memory type."),
@@ -15614,14 +15669,16 @@ var ALL_TOOLS = [
15614
15669
  deleteMemoryTool,
15615
15670
  ingestMemoryFileTool,
15616
15671
  summarizeMemoryEntityTool,
15617
- statusTool
15672
+ statusTool,
15673
+ getUserProfileTool,
15674
+ upsertUserProfileTool
15618
15675
  ];
15619
15676
  var ALL_TOOL_NAMES = ALL_TOOLS.map((t) => t.name);
15620
15677
 
15621
15678
  // src/mcp/server.ts
15622
15679
  async function runMcpServer(opts) {
15623
15680
  const fetchImpl = opts.fetchImpl ?? fetch;
15624
- const version2 = opts.version ?? (true ? "0.26.1" : "0.0.0-dev");
15681
+ const version2 = opts.version ?? (true ? "0.26.3" : "0.0.0-dev");
15625
15682
  const server = new McpServer(
15626
15683
  { name: "pyx-memory", version: version2 },
15627
15684
  { instructions: PYX_MEMORY_INSTRUCTIONS, capabilities: { tools: {} } }
@@ -11,9 +11,9 @@ import {
11
11
  toGraphologyFormat,
12
12
  transformGraphData,
13
13
  unreachableHealth
14
- } from "./chunk-CE3ZBDTM.mjs";
15
- import "./chunk-AKQIZAFT.mjs";
16
- import "./chunk-573W637Y.mjs";
14
+ } from "./chunk-4BJCSQOO.mjs";
15
+ import "./chunk-5X2HOMDQ.mjs";
16
+ import "./chunk-SSUYQJUI.mjs";
17
17
  export {
18
18
  DashboardClient,
19
19
  Poller,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StoreInput as StoreInput$1, MemoryEntry as MemoryEntry$1, MemorySearchParams as MemorySearchParams$1, MemorySearchResult as MemorySearchResult$1, MemoryType as MemoryType$1, PrincipalContext as PrincipalContext$1, MemoryStats as MemoryStats$1, WikiLintReport as WikiLintReport$1, ExtractedImageMeta as ExtractedImageMeta$1, IngestEntity as IngestEntity$1, IngestRelationship as IngestRelationship$1, EntityExtractionResult as EntityExtractionResult$1, Topology as Topology$1, IngestEvent as IngestEvent$1, GraphNode as GraphNode$1, GraphTraversalResult as GraphTraversalResult$1 } from '@pyx-memory/shared';
1
+ import { StoreInput as StoreInput$1, MemoryEntry as MemoryEntry$1, MemorySearchParams as MemorySearchParams$1, MemorySearchResult as MemorySearchResult$1, MemoryType as MemoryType$1, PrincipalContext as PrincipalContext$1, MemoryStats as MemoryStats$1, WikiLintReport as WikiLintReport$1, GraphRepairResult as GraphRepairResult$1, ExtractedImageMeta as ExtractedImageMeta$1, IngestEntity as IngestEntity$1, IngestRelationship as IngestRelationship$1, EntityExtractionResult as EntityExtractionResult$1, Topology as Topology$1, IngestEvent as IngestEvent$1, GraphNode as GraphNode$1, GraphTraversalResult as GraphTraversalResult$1 } from '@pyx-memory/shared';
2
2
 
3
3
  /** Parameters for paginated entry listing. */
4
4
  interface MemoryListParams {
@@ -56,6 +56,11 @@ interface MemoryLogFilters {
56
56
  /** Options for scoping operations to a specific tenant. */
57
57
  interface TenantScopeOptions {
58
58
  tenantId?: string;
59
+ /**
60
+ * Graph count mode for stats(). Use raw on liveness/admin-health paths
61
+ * that should avoid the visible graph projection.
62
+ */
63
+ graphVisibility?: 'visible' | 'raw';
59
64
  /**
60
65
  * Calling principal. When supplied alongside or instead of tenantId,
61
66
  * the operation applies the AuthzPlan visibility filter — get/delete
@@ -111,6 +116,8 @@ interface ExtendedMemoryInterface extends MemoryInterface {
111
116
  reindex(): Promise<void>;
112
117
  /** Delete all entries matching a source, cleaning up all stores. */
113
118
  deleteBySource(source: string): Promise<number>;
119
+ /** Repair stale graph references left by older delete paths or crashed cleanup. */
120
+ repairGraph(): Promise<GraphRepairResult$1>;
114
121
  /**
115
122
  * Chronological feed of memory entries (Karpathy `log.md` primitive).
116
123
  * Cursor-based via `since` (created_at lower bound). No totalCount.
@@ -248,7 +255,7 @@ declare class MemoryClient implements ExtendedMemoryInterface {
248
255
  get(id: string): Promise<MemoryEntry$1 | null>;
249
256
  delete(id: string): Promise<boolean>;
250
257
  clearSession(sessionId: string): Promise<number>;
251
- stats(): Promise<MemoryStats$1>;
258
+ stats(options?: TenantScopeOptions): Promise<MemoryStats$1>;
252
259
  /**
253
260
  * Fetch the running server's topology snapshot (build variant, declared
254
261
  * role, embedding location, active model profile). Round-trips the
@@ -319,6 +326,8 @@ declare class MemoryClient implements ExtendedMemoryInterface {
319
326
  stats: {
320
327
  nodeCount: number;
321
328
  edgeCount: number;
329
+ rawNodeCount: number;
330
+ rawEdgeCount: number;
322
331
  };
323
332
  }>;
324
333
  graphQuery(query: {
@@ -334,12 +343,37 @@ declare class MemoryClient implements ExtendedMemoryInterface {
334
343
  runDecay(): Promise<number>;
335
344
  reindex(): Promise<void>;
336
345
  clearGraph(): Promise<number>;
346
+ repairGraph(): Promise<GraphRepairResult$1>;
337
347
  deleteBySource(source: string): Promise<number>;
338
348
  queryAsOf(asOfDate: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
339
349
  log(filters?: MemoryLogFilters): Promise<MemoryEntry$1[]>;
340
350
  queryByEventTime(startTime: string, endTime: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
341
351
  summarizeEntity(name: string): Promise<MemoryEntry$1>;
342
352
  getEntitySynthesis(name: string): Promise<MemoryEntry$1 | null>;
353
+ /**
354
+ * v0.26 user-profile snapshot — upsert. The server derives `userId`
355
+ * from `X-User-Id` (caller wires it via `defaultHeaders` on the
356
+ * client constructor or per-request middleware); the body cannot
357
+ * override it. See spec §Requirements 10.
358
+ */
359
+ upsertUserProfile(input: {
360
+ namespaceId: string;
361
+ content: string;
362
+ }): Promise<{
363
+ updatedAt: string;
364
+ contentSize: number;
365
+ }>;
366
+ /**
367
+ * v0.26 user-profile snapshot — fetch by namespace. Returns `null` on
368
+ * HTTP 404 (`isNotFound`), rethrows any other non-2xx as
369
+ * `MemoryServerError`. Mirrors `get()`'s 404-to-null pattern so callers
370
+ * can branch on "no profile yet" without inspecting status codes.
371
+ */
372
+ getUserProfile(namespaceId: string): Promise<{
373
+ content: string;
374
+ updatedAt: string;
375
+ contentSize: number;
376
+ } | null>;
343
377
  protected fetchApi<T>(path: string, options?: RequestInit): Promise<T>;
344
378
  /**
345
379
  * Map fetch-layer rejections into a typed `MemoryServerError` so callers
@@ -388,10 +422,20 @@ type SensitivityLevel = (typeof SensitivityLevel)[keyof typeof SensitivityLevel]
388
422
  declare const RAGStrategy: {
389
423
  readonly NAIVE: "naive";
390
424
  readonly GRAPH: "graph";
391
- readonly AGENTIC: "agentic";
392
425
  readonly HYBRID: "hybrid";
393
426
  };
394
427
  type RAGStrategy = (typeof RAGStrategy)[keyof typeof RAGStrategy];
428
+ /**
429
+ * Strategy identifiers that were public in earlier versions and have been
430
+ * removed. Server/SDK reject requests using these with a stable
431
+ * `strategy.deprecated:<name>` error code (not the generic "invalid
432
+ * strategy" message) so callers and dashboards can detect the removal
433
+ * cleanly across a version bump.
434
+ *
435
+ * v0.26: `agentic` removed (Codex pair: silent-catch in agentic.ts
436
+ * violated Production-ready; behavior subsumed by HybridRAGEngine).
437
+ */
438
+ declare const DEPRECATED_RAG_STRATEGIES: ReadonlyMap<string, string>;
395
439
  declare const VectorProvider: {
396
440
  readonly LANCEDB: "lancedb";
397
441
  };
@@ -634,11 +678,20 @@ interface MemoryStats {
634
678
  recentAccessCount: number;
635
679
  graphNodeCount?: number;
636
680
  graphEdgeCount?: number;
681
+ /** Raw graph node count before tenant/ReBAC visibility filtering. */
682
+ graphRawNodeCount?: number;
683
+ /** Raw graph edge count before tenant/ReBAC visibility filtering. */
684
+ graphRawEdgeCount?: number;
637
685
  /** Name of the active graph store ('neo4j', 'sqlite', or undefined if none). */
638
686
  graphStore?: string;
639
687
  /** Whether the memory service is connected. False when using DisabledMemory. */
640
688
  connected?: boolean;
641
689
  }
690
+ interface GraphRepairResult {
691
+ staleEdgesDeleted: number;
692
+ staleNodeRefsRemoved: number;
693
+ orphanNodesDeleted: number;
694
+ }
642
695
  interface GraphNode {
643
696
  id: string;
644
697
  name: string;
@@ -1036,4 +1089,4 @@ interface PrincipalContext {
1036
1089
  /** Sentinel tenant ID used in single-tenant deployments. */
1037
1090
  declare const SINGLE_TENANT_ID = "_single";
1038
1091
 
1039
- export { type AgentId, type ApiResponse, type ConsolidationRunResult, DEFAULTS, EmbeddingProviderName, type EnrichmentCallbacks, type EntityExtractionResult, type ExtendedMemoryInterface, type GraphFailureMode, type GraphNode, type GraphRelationship, type GraphTraversalResult, type IngestEntity, type IngestErrorEvent, type IngestEvent, type IngestFileOptions, type IngestHeartbeatEvent, type IngestProgressEvent, type IngestRelationship, type IngestResultEvent, type IngestStage, type IngestionResult, MemoryClient, type MemoryClientOptions, type MemoryEntry, type MemoryIngestRequest, type MemoryInterface, type MemoryListParams, type MemoryListResult, type MemoryLogFilters, type MemorySearchParams, type MemorySearchResult, MemoryServerError, type MemoryStats, MemoryType, type MoveEntriesFilter, MoveFailureReason, type MoveResult, type MoveTarget, NamespaceIsolation, type PrincipalContext, RAGStrategy, SINGLE_TENANT_ID, SensitivityLevel, type StoreInput, StoreTarget, type TemporalQueryFilters, type TenantScopeOptions, type Timestamp, type Topology, type TopologyServiceVariant, VectorProvider, type WikiLintReport, mergeExtractedEntities };
1092
+ export { type AgentId, type ApiResponse, type ConsolidationRunResult, DEFAULTS, DEPRECATED_RAG_STRATEGIES, EmbeddingProviderName, type EnrichmentCallbacks, type EntityExtractionResult, type ExtendedMemoryInterface, type GraphFailureMode, type GraphNode, type GraphRelationship, type GraphRepairResult, type GraphTraversalResult, type IngestEntity, type IngestErrorEvent, type IngestEvent, type IngestFileOptions, type IngestHeartbeatEvent, type IngestProgressEvent, type IngestRelationship, type IngestResultEvent, type IngestStage, type IngestionResult, MemoryClient, type MemoryClientOptions, type MemoryEntry, type MemoryIngestRequest, type MemoryInterface, type MemoryListParams, type MemoryListResult, type MemoryLogFilters, type MemorySearchParams, type MemorySearchResult, MemoryServerError, type MemoryStats, MemoryType, type MoveEntriesFilter, MoveFailureReason, type MoveResult, type MoveTarget, NamespaceIsolation, type PrincipalContext, RAGStrategy, SINGLE_TENANT_ID, SensitivityLevel, type StoreInput, StoreTarget, type TemporalQueryFilters, type TenantScopeOptions, type Timestamp, type Topology, type TopologyServiceVariant, VectorProvider, type WikiLintReport, mergeExtractedEntities };
package/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  MemoryClient,
3
3
  MemoryServerError
4
- } from "./chunk-AKQIZAFT.mjs";
4
+ } from "./chunk-5X2HOMDQ.mjs";
5
5
  import {
6
6
  DEFAULTS,
7
+ DEPRECATED_RAG_STRATEGIES,
7
8
  EmbeddingProviderName,
8
9
  MemoryType,
9
10
  MoveFailureReason,
@@ -14,9 +15,10 @@ import {
14
15
  StoreTarget,
15
16
  VectorProvider,
16
17
  mergeExtractedEntities
17
- } from "./chunk-573W637Y.mjs";
18
+ } from "./chunk-SSUYQJUI.mjs";
18
19
  export {
19
20
  DEFAULTS,
21
+ DEPRECATED_RAG_STRATEGIES,
20
22
  EmbeddingProviderName,
21
23
  MemoryClient,
22
24
  MemoryServerError,
package/dist/react.mjs CHANGED
@@ -11,9 +11,9 @@ import {
11
11
  toGraphologyFormat,
12
12
  transformGraphData,
13
13
  unreachableHealth
14
- } from "./chunk-CE3ZBDTM.mjs";
15
- import "./chunk-AKQIZAFT.mjs";
16
- import "./chunk-573W637Y.mjs";
14
+ } from "./chunk-4BJCSQOO.mjs";
15
+ import "./chunk-5X2HOMDQ.mjs";
16
+ import "./chunk-SSUYQJUI.mjs";
17
17
 
18
18
  // ../dashboard/src/hooks/use-consolidation-log.ts
19
19
  import { useCallback as useCallback2, useMemo } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyxmate/memory",
3
- "version": "0.26.1",
3
+ "version": "0.26.3",
4
4
  "type": "module",
5
5
  "description": "SDK for pyx-memory — Memory as a Service for AI agents",
6
6
  "license": "MIT",