@pyxmate/memory 1.17.1 → 1.17.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.
package/dist/cli/pyx-mem.mjs
CHANGED
|
@@ -835,7 +835,7 @@ function createProxyServer(client, version, uploadLocalFile) {
|
|
|
835
835
|
return server;
|
|
836
836
|
}
|
|
837
837
|
async function runMcpProxyServer(opts) {
|
|
838
|
-
const version = opts.version ?? (true ? "1.17.
|
|
838
|
+
const version = opts.version ?? (true ? "1.17.3" : "0.0.0-dev");
|
|
839
839
|
const read = await opts.readCredentials();
|
|
840
840
|
if (!read.ok) {
|
|
841
841
|
const text = read.result.content.map((c) => c.type === "text" ? c.text : "").join(" ").trim();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const DATA_PLANE_CONTRACT_VERSION: "pyx-data-plane-contract-v1";
|
|
2
2
|
declare const DATA_PLANE_CATALOG_VERSION: "maas-request-v1";
|
|
3
3
|
declare const DATA_PLANE_MANIFEST_VERSION: "pyx-data-plane-manifest-v1";
|
|
4
|
+
declare const DATA_PLANE_SEARCH_EMBEDDING_CONTRACT: "single_precomputed_query_v1";
|
|
4
5
|
declare const DATA_PLANE_STEP_INPUT_FRAME: "pyx-data-plane-step-input-v1\0";
|
|
5
6
|
declare const DATA_PLANE_MANIFEST_FRAME: "pyx-data-plane-manifest-v1\0";
|
|
6
7
|
declare const DATA_PLANE_HTTP_RESPONSE_FRAME: "pyx-data-plane-http-response-v1\0";
|
|
@@ -231,4 +232,4 @@ declare function hashDataPlaneManifestV1(value: unknown): {
|
|
|
231
232
|
declare function hashDataPlaneHttpResponseV1(statusCode: number, contentType: string, body: Uint8Array): string;
|
|
232
233
|
declare function compileDataPlaneRequest(request: CompileDataPlaneRequest): CompileDataPlaneResult;
|
|
233
234
|
|
|
234
|
-
export { type CanonicalDataPlaneObject, type CanonicalDataPlaneValue, type CompileContext, type CompileDataPlaneRequest, type CompileDataPlaneResult, type CompiledDataPlaneExecutionPlan, DATA_PLANE_CATALOG_VERSION, DATA_PLANE_COMPILER_LIMITS, DATA_PLANE_CONTRACT_VERSION, DATA_PLANE_HTTP_RESPONSE_FRAME, DATA_PLANE_MANIFEST_FRAME, DATA_PLANE_MANIFEST_VERSION, DATA_PLANE_OPERATION_COVERAGE, DATA_PLANE_STEP_INPUT_FRAME, type DataPlaneCatalogOperation, type DataPlaneUnsupportedReasonCode, type SupportedDataPlaneCatalogOperation, canonicalDataPlaneJson, compileDataPlaneRequest, hashDataPlaneHttpResponseV1, hashDataPlaneManifestV1, hashDataPlaneStepInputV1 };
|
|
235
|
+
export { type CanonicalDataPlaneObject, type CanonicalDataPlaneValue, type CompileContext, type CompileDataPlaneRequest, type CompileDataPlaneResult, type CompiledDataPlaneExecutionPlan, DATA_PLANE_CATALOG_VERSION, DATA_PLANE_COMPILER_LIMITS, DATA_PLANE_CONTRACT_VERSION, DATA_PLANE_HTTP_RESPONSE_FRAME, DATA_PLANE_MANIFEST_FRAME, DATA_PLANE_MANIFEST_VERSION, DATA_PLANE_OPERATION_COVERAGE, DATA_PLANE_SEARCH_EMBEDDING_CONTRACT, DATA_PLANE_STEP_INPUT_FRAME, type DataPlaneCatalogOperation, type DataPlaneUnsupportedReasonCode, type SupportedDataPlaneCatalogOperation, canonicalDataPlaneJson, compileDataPlaneRequest, hashDataPlaneHttpResponseV1, hashDataPlaneManifestV1, hashDataPlaneStepInputV1 };
|
|
@@ -8,6 +8,7 @@ import { createHash } from "crypto";
|
|
|
8
8
|
var DATA_PLANE_CONTRACT_VERSION = "pyx-data-plane-contract-v1";
|
|
9
9
|
var DATA_PLANE_CATALOG_VERSION = "maas-request-v1";
|
|
10
10
|
var DATA_PLANE_MANIFEST_VERSION = "pyx-data-plane-manifest-v1";
|
|
11
|
+
var DATA_PLANE_SEARCH_EMBEDDING_CONTRACT = "single_precomputed_query_v1";
|
|
11
12
|
var DATA_PLANE_STEP_INPUT_FRAME = "pyx-data-plane-step-input-v1\0";
|
|
12
13
|
var DATA_PLANE_MANIFEST_FRAME = "pyx-data-plane-manifest-v1\0";
|
|
13
14
|
var DATA_PLANE_HTTP_RESPONSE_FRAME = "pyx-data-plane-http-response-v1\0";
|
|
@@ -536,7 +537,38 @@ function normalizeMcpStoreMetadata(value) {
|
|
|
536
537
|
}
|
|
537
538
|
return { ...caller, ...serverOwned };
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function mergeCanonicalGraphInput(entities, relationships, triples) {
|
|
541
|
+
const uniqueEntities = /* @__PURE__ */ new Map();
|
|
542
|
+
const addEntity = (entity) => {
|
|
543
|
+
const key = `${normalizeNameKey(entity.name)}\0${normalizeGraphLabel(entity.type, "CONCEPT")}`;
|
|
544
|
+
if (!uniqueEntities.has(key)) uniqueEntities.set(key, entity);
|
|
545
|
+
};
|
|
546
|
+
const uniqueRelationships = /* @__PURE__ */ new Map();
|
|
547
|
+
const addRelationship = (relationship) => {
|
|
548
|
+
const key = [
|
|
549
|
+
normalizeNameKey(relationship.source),
|
|
550
|
+
normalizeNameKey(relationship.target),
|
|
551
|
+
normalizeGraphLabel(relationship.type, "RELATED_TO")
|
|
552
|
+
].join("\0");
|
|
553
|
+
if (!uniqueRelationships.has(key)) uniqueRelationships.set(key, relationship);
|
|
554
|
+
};
|
|
555
|
+
for (const entity of entities) addEntity(entity);
|
|
556
|
+
for (const relationship of relationships) addRelationship(relationship);
|
|
557
|
+
for (const triple of triples) {
|
|
558
|
+
addEntity(triple.subject);
|
|
559
|
+
addEntity(triple.object);
|
|
560
|
+
addRelationship({
|
|
561
|
+
source: triple.subject.name,
|
|
562
|
+
target: triple.object.name,
|
|
563
|
+
type: normalizeGraphLabel(triple.relation, "RELATED_TO")
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
entities: [...uniqueEntities.values()],
|
|
568
|
+
relationships: [...uniqueRelationships.values()]
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function canonicalizeStorePayload(input, resolvedAt, mcp, compileAdmission) {
|
|
540
572
|
const value = requireObject(input, "input");
|
|
541
573
|
const common = [
|
|
542
574
|
"id",
|
|
@@ -559,19 +591,14 @@ function normalizeStore(input, context, mcp) {
|
|
|
559
591
|
mcp ? [...common, "topic", "project", "metadata", "triples", "entitiesOnly"] : [...common, "metadata"],
|
|
560
592
|
"input"
|
|
561
593
|
);
|
|
562
|
-
|
|
563
|
-
throw new Error("input.namespaceId does not match trusted context.scope.namespaceId");
|
|
564
|
-
}
|
|
565
|
-
if (value.extractEntities === true) {
|
|
566
|
-
throw new Error("input.extractEntities=true requires external I/O and is not execution-ready");
|
|
567
|
-
}
|
|
594
|
+
compileAdmission?.(value);
|
|
568
595
|
const normalized = {
|
|
569
596
|
content: requireString(value.content, "input.content"),
|
|
570
597
|
type: optionalEnum(value.type, MEMORY_TYPES, "input.type") ?? "long-term",
|
|
571
598
|
targets: normalizeStoreTargets(value.targets),
|
|
572
599
|
metadata: mcp ? normalizeMcpStoreMetadata(value) : canonicalValue(value.metadata ?? {}, "input.metadata"),
|
|
573
|
-
createdAt:
|
|
574
|
-
ingestTime:
|
|
600
|
+
createdAt: resolvedAt,
|
|
601
|
+
ingestTime: resolvedAt,
|
|
575
602
|
extractEntities: false
|
|
576
603
|
};
|
|
577
604
|
withOptional(normalized, "id", optionalCallerEntryId(value.id, "input.id"));
|
|
@@ -591,6 +618,7 @@ function normalizeStore(input, context, mcp) {
|
|
|
591
618
|
}
|
|
592
619
|
const entities = normalizeGraphEntities(value.entities) ?? [];
|
|
593
620
|
const relationships = normalizeGraphRelationships(value.relationships) ?? [];
|
|
621
|
+
const triples = [];
|
|
594
622
|
if (mcp && value.triples !== void 0) {
|
|
595
623
|
if (!Array.isArray(value.triples) || value.triples.length > 256) {
|
|
596
624
|
throw new Error("input.triples must be an array of at most 256 items");
|
|
@@ -602,57 +630,45 @@ function normalizeStore(input, context, mcp) {
|
|
|
602
630
|
const subject = tripleEntities?.[0];
|
|
603
631
|
const object = tripleEntities?.[1];
|
|
604
632
|
if (!subject || !object) throw new Error(`input.triples[${index}] has invalid endpoints`);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
type: normalizeGraphLabel(
|
|
610
|
-
requireString(triple.relation, `input.triples[${index}].relation`),
|
|
611
|
-
"RELATED_TO"
|
|
612
|
-
)
|
|
633
|
+
triples.push({
|
|
634
|
+
subject,
|
|
635
|
+
relation: requireString(triple.relation, `input.triples[${index}].relation`),
|
|
636
|
+
object
|
|
613
637
|
});
|
|
614
638
|
}
|
|
615
639
|
}
|
|
616
|
-
const
|
|
617
|
-
for (const entity of entities) {
|
|
618
|
-
const key = `${normalizeNameKey(entity.name)}\0${entity.type}`;
|
|
619
|
-
if (!uniqueEntities.has(key)) uniqueEntities.set(key, entity);
|
|
620
|
-
}
|
|
621
|
-
const uniqueRelationships = /* @__PURE__ */ new Map();
|
|
622
|
-
for (const relationship of relationships) {
|
|
623
|
-
const key = [
|
|
624
|
-
normalizeNameKey(relationship.source),
|
|
625
|
-
normalizeNameKey(relationship.target),
|
|
626
|
-
normalizeGraphLabel(relationship.type, "RELATED_TO")
|
|
627
|
-
].join("\0");
|
|
628
|
-
if (!uniqueRelationships.has(key)) uniqueRelationships.set(key, relationship);
|
|
629
|
-
}
|
|
640
|
+
const merged = mergeCanonicalGraphInput(entities, relationships, triples);
|
|
630
641
|
const graphTargeted = normalized.targets.includes(
|
|
631
642
|
"graph"
|
|
632
643
|
);
|
|
633
|
-
const entityNames = new Set(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
)
|
|
637
|
-
);
|
|
638
|
-
const hasResolvableRelationship = [...uniqueRelationships.values()].some((relationship) => {
|
|
639
|
-
const value2 = relationship;
|
|
640
|
-
const source = normalizeNameKey(value2.source);
|
|
641
|
-
const target = normalizeNameKey(value2.target);
|
|
644
|
+
const entityNames = new Set(merged.entities.map((entity) => normalizeNameKey(entity.name)));
|
|
645
|
+
const hasResolvableRelationship = merged.relationships.some((relationship) => {
|
|
646
|
+
const source = normalizeNameKey(relationship.source);
|
|
647
|
+
const target = normalizeNameKey(relationship.target);
|
|
642
648
|
return source !== target && entityNames.has(source) && entityNames.has(target);
|
|
643
649
|
});
|
|
644
650
|
const entitiesOnly = mcp && value.entitiesOnly !== void 0 ? requireBoolean(value.entitiesOnly, "input.entitiesOnly") : false;
|
|
645
|
-
if (mcp && graphTargeted &&
|
|
651
|
+
if (mcp && graphTargeted && merged.entities.length >= 2 && !hasResolvableRelationship && !entitiesOnly) {
|
|
646
652
|
throw new Error(
|
|
647
653
|
"GRAPH_RELATIONSHIPS_REQUIRED: graph stores with two or more entities require a relationship that connects declared entity names, or entitiesOnly=true"
|
|
648
654
|
);
|
|
649
655
|
}
|
|
650
|
-
if (
|
|
651
|
-
if (
|
|
652
|
-
normalized.relationships = [...uniqueRelationships.values()];
|
|
653
|
-
}
|
|
656
|
+
if (merged.entities.length > 0) normalized.entities = merged.entities;
|
|
657
|
+
if (merged.relationships.length > 0) normalized.relationships = merged.relationships;
|
|
654
658
|
return normalized;
|
|
655
659
|
}
|
|
660
|
+
function normalizeStore(input, context, mcp) {
|
|
661
|
+
return canonicalizeStorePayload(input, context.resolvedAt, mcp, (value) => {
|
|
662
|
+
if (value.namespaceId !== void 0 && value.namespaceId !== context.scope.namespaceId) {
|
|
663
|
+
throw new Error("input.namespaceId does not match trusted context.scope.namespaceId");
|
|
664
|
+
}
|
|
665
|
+
if (value.extractEntities === true) {
|
|
666
|
+
throw new Error(
|
|
667
|
+
"input.extractEntities=true requires external I/O and is not execution-ready"
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
656
672
|
function normalizeBatchStore(input, context) {
|
|
657
673
|
const value = requireObject(input, "input");
|
|
658
674
|
requireExactKeys(value, ["entries"], "input");
|
|
@@ -1246,6 +1262,7 @@ export {
|
|
|
1246
1262
|
DATA_PLANE_MANIFEST_FRAME,
|
|
1247
1263
|
DATA_PLANE_MANIFEST_VERSION,
|
|
1248
1264
|
DATA_PLANE_OPERATION_COVERAGE,
|
|
1265
|
+
DATA_PLANE_SEARCH_EMBEDDING_CONTRACT,
|
|
1249
1266
|
DATA_PLANE_STEP_INPUT_FRAME,
|
|
1250
1267
|
canonicalDataPlaneJson,
|
|
1251
1268
|
compileDataPlaneRequest,
|