@pyxmate/memory 1.31.0 → 1.32.1

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.
@@ -2,7 +2,7 @@ import {
2
2
  RAGStrategy,
3
3
  assertGraphExtractionPayload,
4
4
  mergeExtractedEntities
5
- } from "./chunk-HTQBKJTD.mjs";
5
+ } from "./chunk-MD5RCZCA.mjs";
6
6
 
7
7
  // ../client/src/disabled-memory.ts
8
8
  var DEFAULT_PAGE_LIMIT = 20;
@@ -405,6 +405,9 @@ var MemoryClient = class {
405
405
  const formData = new FormData();
406
406
  formData.append("file", file);
407
407
  if (options?.description) formData.append("description", options.description);
408
+ if (options?.agentId !== void 0) formData.append("agentId", options.agentId);
409
+ if (options?.metadata !== void 0)
410
+ formData.append("metadata", JSON.stringify(options.metadata));
408
411
  if (options?.namespaceId) formData.append("namespaceId", options.namespaceId);
409
412
  if (options?.documentKey !== void 0) {
410
413
  formData.append("documentKey", options.documentKey);
@@ -473,14 +473,24 @@ function normalizeLog(input, defaultAgentId) {
473
473
  }
474
474
  function normalizeCorrectionRecord(input, defaultAgentId) {
475
475
  const value = requireObject(input, "input");
476
- const keys = ["whatWasWrong", "whatToDoInstead", "appliesWhen", "project", "taskShape"];
476
+ const keys = [
477
+ "whatWasWrong",
478
+ "whatToDoInstead",
479
+ "appliesWhen",
480
+ "project",
481
+ "taskShape",
482
+ "agentId",
483
+ "metadata"
484
+ ];
477
485
  requireExactKeys(value, keys, "input");
478
486
  const normalized = {
479
487
  whatWasWrong: requireString(value.whatWasWrong, "input.whatWasWrong"),
480
488
  whatToDoInstead: requireString(value.whatToDoInstead, "input.whatToDoInstead"),
481
489
  appliesWhen: requireString(value.appliesWhen, "input.appliesWhen")
482
490
  };
483
- withOptional(normalized, "agentId", defaultAgentId ?? void 0);
491
+ const attribution = normalizeMemoryAttribution(value);
492
+ withOptional(normalized, "agentId", attribution.agentId ?? defaultAgentId ?? void 0);
493
+ withOptional(normalized, "metadata", attribution.metadata);
484
494
  withOptional(normalized, "project", optionalNonemptyString(value.project, "input.project"));
485
495
  withOptional(normalized, "taskShape", optionalNonemptyString(value.taskShape, "input.taskShape"));
486
496
  return normalized;
@@ -777,6 +787,25 @@ function normalizeGraphRelationships(value) {
777
787
  });
778
788
  }
779
789
  var MCP_SERVER_OWNED_METADATA_KEYS = ["source", "topic", "project", "_kind"];
790
+ var MEMORY_ATTRIBUTION_MAX_BYTES = 1024;
791
+ function normalizeMemoryAttribution(value) {
792
+ const attribution = {};
793
+ const agentId = optionalNonemptyString(value.agentId, "input.agentId");
794
+ if (agentId !== void 0) attribution.agentId = agentId;
795
+ if (value.metadata !== void 0) {
796
+ const caller = requireObject(value.metadata, "input.metadata");
797
+ for (const key of Object.keys(caller)) {
798
+ if (key.startsWith("_") || MCP_SERVER_OWNED_METADATA_KEYS.some((owned) => owned === key)) {
799
+ throw new Error(`input.metadata.${key} is server-owned and cannot be caller-supplied`);
800
+ }
801
+ }
802
+ attribution.metadata = canonicalValue(caller, "input.metadata");
803
+ }
804
+ if (Buffer.byteLength(canonicalDataPlaneJson(attribution), "utf8") > MEMORY_ATTRIBUTION_MAX_BYTES) {
805
+ throw new Error(`input attribution exceeds ${MEMORY_ATTRIBUTION_MAX_BYTES} UTF-8 bytes`);
806
+ }
807
+ return attribution;
808
+ }
780
809
  function normalizeMcpStoreMetadata(value) {
781
810
  const serverOwned = {
782
811
  source: "agent",
@@ -987,7 +1016,11 @@ function requireHostedFileIngestFilename(value, field) {
987
1016
  }
988
1017
  function normalizeFileIngestBegin(input) {
989
1018
  const value = requireObject(input, "input");
990
- requireExactKeys(value, ["jobId", "filename", "byteLength", "sha256", "description"], "input");
1019
+ requireExactKeys(
1020
+ value,
1021
+ ["jobId", "filename", "byteLength", "sha256", "description", "agentId", "metadata"],
1022
+ "input"
1023
+ );
991
1024
  const normalized = {
992
1025
  jobId: requireHostedFileIngestJobId(value.jobId, "input.jobId"),
993
1026
  filename: requireHostedFileIngestFilename(value.filename, "input.filename"),
@@ -1000,7 +1033,7 @@ function normalizeFileIngestBegin(input) {
1000
1033
  sha256: requireSha256Hex(value.sha256, "input.sha256")
1001
1034
  };
1002
1035
  withOptional(normalized, "description", optionalString(value.description, "input.description"));
1003
- return normalized;
1036
+ return { ...normalized, ...normalizeMemoryAttribution(value) };
1004
1037
  }
1005
1038
  function normalizeFileIngestJob(input) {
1006
1039
  const value = requireObject(input, "input");
@@ -1940,6 +1973,7 @@ export {
1940
1973
  DATA_PLANE_OPERATION_COVERAGE,
1941
1974
  encodeListCursorToken,
1942
1975
  parseListCursorToken,
1976
+ normalizeMemoryAttribution,
1943
1977
  requireHostedFileIngestFilename,
1944
1978
  normalizeHostedFileIngestPageDescriptor,
1945
1979
  canonicalDataPlaneJson,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MemoryClient
3
- } from "./chunk-M67SXB7C.mjs";
3
+ } from "./chunk-F2G2TBLW.mjs";
4
4
 
5
5
  // ../dashboard/src/aggregations/consolidation-analytics.ts
6
6
  function analyzeConsolidationLog(entries) {
@@ -144,7 +144,7 @@ async function runMcpInstall(target, scope, remote, noRules) {
144
144
  }
145
145
  async function runMcpCommand(parsed) {
146
146
  if (parsed.subcommand === void 0) {
147
- const { mcpCommand, resolveMcpMode } = await import("../mcp-OPC3BV7H.mjs");
147
+ const { mcpCommand, resolveMcpMode } = await import("../mcp-GGI7LUYO.mjs");
148
148
  const resolved = resolveMcpMode({
149
149
  remote: parsed.flags.remote === true,
150
150
  bundled: parsed.flags.bundled === true
@@ -249,7 +249,7 @@ async function main() {
249
249
  process.stderr.write("Error: `pyx-mem insights` requires --json.\n");
250
250
  return EXIT.USAGE;
251
251
  }
252
- const { insightsCommand } = await import("../insights-PD7Y6QDX.mjs");
252
+ const { insightsCommand } = await import("../insights-E7USP2C5.mjs");
253
253
  return insightsCommand({
254
254
  withIdentity: parsed.flags["with-identity"] === true,
255
255
  withProvenance: parsed.flags["with-provenance"] === true
@@ -260,7 +260,7 @@ async function main() {
260
260
  process.stderr.write("Error: `pyx-mem taxonomy` requires --json.\n");
261
261
  return EXIT.USAGE;
262
262
  }
263
- const { taxonomyCommand } = await import("../taxonomy-EKDFDFXW.mjs");
263
+ const { taxonomyCommand } = await import("../taxonomy-65DFVGRY.mjs");
264
264
  return taxonomyCommand({ withIdentity: parsed.flags["with-identity"] === true });
265
265
  }
266
266
  case "logout": {
@@ -11,10 +11,10 @@ import {
11
11
  toGraphologyFormat,
12
12
  transformGraphData,
13
13
  unreachableHealth
14
- } from "./chunk-N4KDRRLY.mjs";
15
- import "./chunk-M67SXB7C.mjs";
14
+ } from "./chunk-UIR5VDPF.mjs";
15
+ import "./chunk-F2G2TBLW.mjs";
16
16
  import "./chunk-RWQTBXUC.mjs";
17
- import "./chunk-HTQBKJTD.mjs";
17
+ import "./chunk-MD5RCZCA.mjs";
18
18
  export {
19
19
  DashboardClient,
20
20
  Poller,
@@ -27,7 +27,7 @@ import {
27
27
  parseHostedFileIngestJobView,
28
28
  parseHostedFileIngestPublishResult,
29
29
  requireHostedFileIngestFilename
30
- } from "./chunk-HTQBKJTD.mjs";
30
+ } from "./chunk-MD5RCZCA.mjs";
31
31
  export {
32
32
  DATA_PLANE_CATALOG_VERSION,
33
33
  DATA_PLANE_COMPILER_LIMITS,
package/dist/index.d.ts CHANGED
@@ -602,6 +602,8 @@ interface CorrectionInput {
602
602
  taskShape?: string;
603
603
  /** Optional agent id; defaults to the Memory instance's `agentId`. */
604
604
  agentId?: string;
605
+ /** Caller audit metadata; server-owned keys cannot be supplied over REST/MCP. */
606
+ metadata?: Record<string, unknown>;
605
607
  }
606
608
  /** Input to `Memory.fetchApplicableCorrections`. */
607
609
  interface FetchCorrectionsInput {
@@ -1155,6 +1157,9 @@ interface EnrichmentCallbacks {
1155
1157
  * (server v0.17.4+; required when `requireNamespaceForTenantWrites=true`).
1156
1158
  */
1157
1159
  interface IngestFileOptions {
1160
+ /** Audit attribution frozen for this ingest and its enrichment callbacks. */
1161
+ agentId?: string;
1162
+ metadata?: Record<string, unknown>;
1158
1163
  description?: string;
1159
1164
  enrichment?: EnrichmentCallbacks;
1160
1165
  signal?: AbortSignal;
@@ -1479,6 +1484,8 @@ declare class MemoryClient implements ExtendedMemoryInterface {
1479
1484
  appliesWhen: string;
1480
1485
  project?: string;
1481
1486
  taskShape?: string;
1487
+ agentId?: string;
1488
+ metadata?: Record<string, unknown>;
1482
1489
  }): Promise<{
1483
1490
  id: string;
1484
1491
  createdAt: string;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  DisabledMemory,
3
3
  MemoryClient,
4
4
  MemoryServerError
5
- } from "./chunk-M67SXB7C.mjs";
5
+ } from "./chunk-F2G2TBLW.mjs";
6
6
  import {
7
7
  DEFAULTS,
8
8
  MCP_ACTOR_META_KEY,
@@ -40,7 +40,7 @@ import {
40
40
  normalizeGraphLabel,
41
41
  normalizeNameKey,
42
42
  parseListCursorToken
43
- } from "./chunk-HTQBKJTD.mjs";
43
+ } from "./chunk-MD5RCZCA.mjs";
44
44
 
45
45
  // src/preset.ts
46
46
  var DEFAULT_MEMORY_URL = `http://localhost:${DEFAULTS.MEMORY_SERVER_PORT}`;
@@ -8,7 +8,7 @@ import {
8
8
  TAXONOMY_MAX_PROJECTS,
9
9
  normalizeMemoryActorLabel
10
10
  } from "./chunk-RWQTBXUC.mjs";
11
- import "./chunk-HTQBKJTD.mjs";
11
+ import "./chunk-MD5RCZCA.mjs";
12
12
  import {
13
13
  EXIT
14
14
  } from "./chunk-4DXEQC6X.mjs";
@@ -19,12 +19,13 @@ import {
19
19
  import {
20
20
  HOSTED_FILE_INGEST_PROTOCOL,
21
21
  HOSTED_FILE_INGEST_RETRYABLE_CODES,
22
+ normalizeMemoryAttribution,
22
23
  parseHostedFileIngestAuthorization,
23
24
  parseHostedFileIngestCommitResult,
24
25
  parseHostedFileIngestJobView,
25
26
  parseHostedFileIngestPublishResult,
26
27
  requireHostedFileIngestFilename
27
- } from "./chunk-HTQBKJTD.mjs";
28
+ } from "./chunk-MD5RCZCA.mjs";
28
29
  import {
29
30
  syncMemoryRulesFromServer
30
31
  } from "./chunk-QR5K7ETI.mjs";
@@ -80,7 +81,10 @@ function parseIntent(raw, file) {
80
81
  if (value?.version !== 1 || typeof value.jobId !== "string" || typeof value.endpoint !== "string" || typeof value.delivered !== "boolean" || typeof value.createdAt !== "string" || typeof value.updatedAt !== "string" || typeof fp?.path !== "string" || typeof fp.byteLength !== "number" || typeof fp.sha256 !== "string") {
81
82
  throw new Error(`file ingest intent ${file} is not a version 1 record; remove it to continue`);
82
83
  }
83
- return value;
84
+ return {
85
+ ...value,
86
+ fingerprint: { ...fp, ...normalizeMemoryAttribution(fp) }
87
+ };
84
88
  }
85
89
  async function readIntents(dir) {
86
90
  let names;
@@ -157,7 +161,14 @@ function parseArgs(args) {
157
161
  if (maxCostCents !== void 0 && maxCostMicrocents === void 0) {
158
162
  return "`maxCostCents` must be a non-negative number of cents.";
159
163
  }
164
+ let attribution;
165
+ try {
166
+ attribution = normalizeMemoryAttribution(args);
167
+ } catch (error) {
168
+ return error instanceof Error ? error.message : String(error);
169
+ }
160
170
  return {
171
+ ...attribution,
161
172
  path: isAbsolute(path) ? path : resolve(path),
162
173
  description: description || null,
163
174
  namespaceId: namespaceId ?? null,
@@ -483,7 +494,8 @@ ${NEW_IMPORT}`, true));
483
494
  filename: call.filename,
484
495
  byteLength: fingerprint.byteLength,
485
496
  sha256: fingerprint.sha256,
486
- ...fingerprint.description === null ? {} : { description: fingerprint.description }
497
+ ...fingerprint.description === null ? {} : { description: fingerprint.description },
498
+ ...normalizeMemoryAttribution(fingerprint)
487
499
  },
488
500
  parseHostedFileIngestJobView
489
501
  );
@@ -577,7 +589,8 @@ Call this tool with cancel: true again to confirm.`,
577
589
  byteLength,
578
590
  sha256,
579
591
  description: args.description,
580
- namespaceId: args.namespaceId
592
+ namespaceId: args.namespaceId,
593
+ ...normalizeMemoryAttribution(args)
581
594
  },
582
595
  lastState: null,
583
596
  delivered: false,
@@ -773,6 +786,15 @@ function createLocalFileUploader(credentials, readCredentials, fetchImpl = fetch
773
786
  return async (descriptor, args) => {
774
787
  try {
775
788
  await guard();
789
+ const attribution = normalizeMemoryAttribution(args);
790
+ for (const key of ["agentId", "metadata"]) {
791
+ if (attribution[key] !== void 0 && !descriptor.optionalArgs?.includes(key)) {
792
+ return mcpText(
793
+ `The server does not support ingest ${key}; upgrade it before sending attribution.`,
794
+ true
795
+ );
796
+ }
797
+ }
776
798
  const file = await readCappedLocalFile(args[descriptor.pathArg], descriptor);
777
799
  if (!file.ok) return file.result;
778
800
  const http = createHttpClient(credentials, fetchImpl);
@@ -783,7 +805,12 @@ function createLocalFileUploader(credentials, readCredentials, fetchImpl = fetch
783
805
  const form = new FormData();
784
806
  form.set(descriptor.fileField, new File([new Uint8Array(file.bytes)], file.name));
785
807
  for (const key of descriptor.optionalArgs ?? []) {
786
- const value = args[key];
808
+ if (key === "metadata") {
809
+ if (attribution.metadata !== void 0)
810
+ form.set(key, JSON.stringify(attribution.metadata));
811
+ continue;
812
+ }
813
+ const value = key === "agentId" ? attribution.agentId : args[key];
787
814
  if (typeof value === "string" && value.length > 0) form.set(key, value);
788
815
  }
789
816
  return form;
@@ -874,7 +901,7 @@ function createProxyServer(client, version, uploadLocalFile, hostedFileIngest) {
874
901
  return server;
875
902
  }
876
903
  async function runMcpProxyServer(opts) {
877
- const version = opts.version ?? (true ? "1.31.0" : "0.0.0-dev");
904
+ const version = opts.version ?? (true ? "1.32.1" : "0.0.0-dev");
878
905
  const read = await opts.readCredentials();
879
906
  if (!read.ok) {
880
907
  throw new Error(
package/dist/react.mjs CHANGED
@@ -11,10 +11,10 @@ import {
11
11
  toGraphologyFormat,
12
12
  transformGraphData,
13
13
  unreachableHealth
14
- } from "./chunk-N4KDRRLY.mjs";
15
- import "./chunk-M67SXB7C.mjs";
14
+ } from "./chunk-UIR5VDPF.mjs";
15
+ import "./chunk-F2G2TBLW.mjs";
16
16
  import "./chunk-RWQTBXUC.mjs";
17
- import "./chunk-HTQBKJTD.mjs";
17
+ import "./chunk-MD5RCZCA.mjs";
18
18
 
19
19
  // ../dashboard/src/hooks/use-consolidation-log.ts
20
20
  import { useCallback as useCallback2, useMemo } from "react";
@@ -10,7 +10,7 @@ import {
10
10
  TAXONOMY_MAX_SAMPLE_TOPICS,
11
11
  TAXONOMY_MAX_TOP_ENTITIES
12
12
  } from "./chunk-RWQTBXUC.mjs";
13
- import "./chunk-HTQBKJTD.mjs";
13
+ import "./chunk-MD5RCZCA.mjs";
14
14
  import {
15
15
  EXIT
16
16
  } from "./chunk-4DXEQC6X.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyxmate/memory",
3
- "version": "1.31.0",
3
+ "version": "1.32.1",
4
4
  "type": "module",
5
5
  "description": "SDK for pyx-memory — Memory as a Service for AI agents",
6
6
  "license": "MIT",