vecmindb 1.1.2__tar.gz → 1.2.0__tar.gz
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.
- {vecmindb-1.1.2 → vecmindb-1.2.0}/PKG-INFO +1 -1
- {vecmindb-1.1.2 → vecmindb-1.2.0}/pyproject.toml +1 -1
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/__init__.py +1 -1
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/mcp.py +610 -17
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb.egg-info/PKG-INFO +1 -1
- {vecmindb-1.1.2 → vecmindb-1.2.0}/README.md +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/setup.cfg +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/tests/test_agent_memory.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/tests/test_agent_turns.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/tests/test_client.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/tests/test_integrations.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/agent_turns.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/async_client.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/auth.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/client.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/exceptions.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/gate_calibrate.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/integrations/__init__.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/integrations/langchain.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/integrations/llamaindex.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/mcp_server.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/memory.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/memory_plugin.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/models.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/py.typed +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb/retry.py +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb.egg-info/SOURCES.txt +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb.egg-info/dependency_links.txt +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb.egg-info/requires.txt +0 -0
- {vecmindb-1.1.2 → vecmindb-1.2.0}/vecmindb.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vecmindb"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.2.0"
|
|
8
8
|
description = "Python SDK for VecminDB - High-performance vector database HTTP client"
|
|
9
9
|
authors = [{email = "contact@lingxinmind.com", name = "VecminDB Team"}]
|
|
10
10
|
license = {text = "MIT OR Apache-2.0"}
|
|
@@ -342,6 +342,8 @@ class McpClient:
|
|
|
342
342
|
agent_id: str = "default",
|
|
343
343
|
source: Optional[str] = "sdk",
|
|
344
344
|
is_factual: bool = False,
|
|
345
|
+
is_obsolete: Optional[bool] = None,
|
|
346
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
345
347
|
) -> Any:
|
|
346
348
|
"""Store a memory via the ``store_memory`` MCP tool.
|
|
347
349
|
|
|
@@ -351,6 +353,9 @@ class McpClient:
|
|
|
351
353
|
the authenticated identity bound to the API key).
|
|
352
354
|
source: Optional origin tag, stored in the memory metadata.
|
|
353
355
|
is_factual: If true, exempts this memory from biological forgetting.
|
|
356
|
+
is_obsolete: If true, strips any anchor so this outdated memory
|
|
357
|
+
re-enters normal LTSM decay.
|
|
358
|
+
metadata: Optional metadata JSON object (merged with ``source``).
|
|
354
359
|
|
|
355
360
|
Returns:
|
|
356
361
|
Tool result.
|
|
@@ -360,10 +365,15 @@ class McpClient:
|
|
|
360
365
|
"text": content,
|
|
361
366
|
"is_factual": is_factual,
|
|
362
367
|
}
|
|
368
|
+
if is_obsolete is not None:
|
|
369
|
+
arguments["is_obsolete"] = is_obsolete
|
|
370
|
+
merged_metadata = dict(metadata or {})
|
|
363
371
|
if source:
|
|
364
372
|
# The server schema has no top-level "source" field; fold it into
|
|
365
373
|
# the documented metadata object instead.
|
|
366
|
-
|
|
374
|
+
merged_metadata.setdefault("source", source)
|
|
375
|
+
if merged_metadata:
|
|
376
|
+
arguments["metadata"] = merged_metadata
|
|
367
377
|
return await self.call_tool("store_memory", arguments)
|
|
368
378
|
|
|
369
379
|
async def search_memory(
|
|
@@ -372,6 +382,10 @@ class McpClient:
|
|
|
372
382
|
*,
|
|
373
383
|
agent_id: str = "default",
|
|
374
384
|
top_k: int = 5,
|
|
385
|
+
since_ts: Optional[int] = None,
|
|
386
|
+
until_ts: Optional[int] = None,
|
|
387
|
+
tags: Optional[List[str]] = None,
|
|
388
|
+
keyword: Optional[str] = None,
|
|
375
389
|
) -> Any:
|
|
376
390
|
"""Search memories via the ``search_memory`` MCP tool.
|
|
377
391
|
|
|
@@ -380,14 +394,28 @@ class McpClient:
|
|
|
380
394
|
agent_id: Agent or session identifier (server overrides this with
|
|
381
395
|
the authenticated identity bound to the API key).
|
|
382
396
|
top_k: Number of results.
|
|
397
|
+
since_ts: Epoch seconds — only entries created at or after
|
|
398
|
+
this time.
|
|
399
|
+
until_ts: Epoch seconds — only entries created at or before
|
|
400
|
+
this time.
|
|
401
|
+
tags: Only entries whose metadata.tags contains at least one
|
|
402
|
+
of these tags (any-of).
|
|
403
|
+
keyword: Only entries whose text contains this substring
|
|
404
|
+
(case-insensitive).
|
|
383
405
|
|
|
384
406
|
Returns:
|
|
385
407
|
Tool result.
|
|
386
408
|
"""
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
409
|
+
arguments: Dict[str, Any] = {"agent_id": agent_id, "query": query, "top_k": top_k}
|
|
410
|
+
if since_ts is not None:
|
|
411
|
+
arguments["since_ts"] = since_ts
|
|
412
|
+
if until_ts is not None:
|
|
413
|
+
arguments["until_ts"] = until_ts
|
|
414
|
+
if tags is not None:
|
|
415
|
+
arguments["tags"] = tags
|
|
416
|
+
if keyword is not None:
|
|
417
|
+
arguments["keyword"] = keyword
|
|
418
|
+
return await self.call_tool("search_memory", arguments)
|
|
391
419
|
|
|
392
420
|
async def store_media(
|
|
393
421
|
self,
|
|
@@ -482,16 +510,52 @@ class McpClient:
|
|
|
482
510
|
},
|
|
483
511
|
)
|
|
484
512
|
|
|
485
|
-
async def list_memories(
|
|
486
|
-
|
|
513
|
+
async def list_memories(
|
|
514
|
+
self,
|
|
515
|
+
*,
|
|
516
|
+
limit: int = 20,
|
|
517
|
+
shared_with_me: Optional[bool] = None,
|
|
518
|
+
since_hours: Optional[int] = None,
|
|
519
|
+
since_ts: Optional[int] = None,
|
|
520
|
+
until_ts: Optional[int] = None,
|
|
521
|
+
tags: Optional[List[str]] = None,
|
|
522
|
+
keyword: Optional[str] = None,
|
|
523
|
+
) -> Any:
|
|
524
|
+
"""List memories via the ``list_memories`` MCP tool.
|
|
487
525
|
|
|
488
526
|
Args:
|
|
489
527
|
limit: Maximum number of memories to return.
|
|
528
|
+
shared_with_me: If true, inbox view — only entries other
|
|
529
|
+
tenants shared with you (granted collections, own space
|
|
530
|
+
excluded).
|
|
531
|
+
since_hours: Inbox only — window for the "Recent sharing
|
|
532
|
+
activity" summary (default 168 = 7 days).
|
|
533
|
+
since_ts: Epoch seconds — only entries created at or after
|
|
534
|
+
this time.
|
|
535
|
+
until_ts: Epoch seconds — only entries created at or before
|
|
536
|
+
this time.
|
|
537
|
+
tags: Only entries whose metadata.tags contains at least one
|
|
538
|
+
of these tags (any-of).
|
|
539
|
+
keyword: Only entries whose text contains this substring
|
|
540
|
+
(case-insensitive).
|
|
490
541
|
|
|
491
542
|
Returns:
|
|
492
543
|
Tool result.
|
|
493
544
|
"""
|
|
494
|
-
|
|
545
|
+
arguments: Dict[str, Any] = {"limit": limit}
|
|
546
|
+
if shared_with_me is not None:
|
|
547
|
+
arguments["shared_with_me"] = shared_with_me
|
|
548
|
+
if since_hours is not None:
|
|
549
|
+
arguments["since_hours"] = since_hours
|
|
550
|
+
if since_ts is not None:
|
|
551
|
+
arguments["since_ts"] = since_ts
|
|
552
|
+
if until_ts is not None:
|
|
553
|
+
arguments["until_ts"] = until_ts
|
|
554
|
+
if tags is not None:
|
|
555
|
+
arguments["tags"] = tags
|
|
556
|
+
if keyword is not None:
|
|
557
|
+
arguments["keyword"] = keyword
|
|
558
|
+
return await self.call_tool("list_memories", arguments)
|
|
495
559
|
|
|
496
560
|
async def get_memory(self, memory_id: str) -> Any:
|
|
497
561
|
"""Fetch one memory by its vector ID via the ``get_memory`` MCP tool.
|
|
@@ -593,6 +657,311 @@ class McpClient:
|
|
|
593
657
|
"""
|
|
594
658
|
return await self.call_tool("remove_factuality_template", {"text": text})
|
|
595
659
|
|
|
660
|
+
async def update_memory(
|
|
661
|
+
self,
|
|
662
|
+
memory_id: str,
|
|
663
|
+
text: str,
|
|
664
|
+
*,
|
|
665
|
+
is_factual: Optional[bool] = None,
|
|
666
|
+
) -> Any:
|
|
667
|
+
"""Correct a memory in place via the ``update_memory`` MCP tool.
|
|
668
|
+
|
|
669
|
+
The correction keeps the same id and anchors while the corrected
|
|
670
|
+
text is re-embedded; the previous text is appended to a bounded
|
|
671
|
+
history. Corrections of shared entries are audit-trailed (grantees
|
|
672
|
+
see the new text). Only the authoring agent may correct its own
|
|
673
|
+
entries.
|
|
674
|
+
|
|
675
|
+
Args:
|
|
676
|
+
memory_id: Memory vector ID to correct (own collection only).
|
|
677
|
+
text: The corrected content — replaces the previous text.
|
|
678
|
+
is_factual: Optional explicit re-grade: true = strong anchor,
|
|
679
|
+
false = weak; absent preserves the current anchor.
|
|
680
|
+
|
|
681
|
+
Returns:
|
|
682
|
+
Tool result.
|
|
683
|
+
"""
|
|
684
|
+
arguments: Dict[str, Any] = {"id": memory_id, "text": text}
|
|
685
|
+
if is_factual is not None:
|
|
686
|
+
arguments["is_factual"] = is_factual
|
|
687
|
+
return await self.call_tool("update_memory", arguments)
|
|
688
|
+
|
|
689
|
+
async def freeze_memory(self, memory_id: str, frozen: bool) -> Any:
|
|
690
|
+
"""Freeze (or unfreeze) one of your memories via the
|
|
691
|
+
``freeze_memory`` MCP tool.
|
|
692
|
+
|
|
693
|
+
Frozen entries are exempt from LTSM distillation and staleness
|
|
694
|
+
scavenging — "do not touch this memory". Advisory on top of
|
|
695
|
+
anchoring (does not re-grade strong/weak), reversible any time,
|
|
696
|
+
author-only.
|
|
697
|
+
|
|
698
|
+
Args:
|
|
699
|
+
memory_id: Memory vector ID (own collection only).
|
|
700
|
+
frozen: True = exempt from distillation/vacuum, false = back
|
|
701
|
+
to the normal lifecycle.
|
|
702
|
+
|
|
703
|
+
Returns:
|
|
704
|
+
Tool result.
|
|
705
|
+
"""
|
|
706
|
+
return await self.call_tool(
|
|
707
|
+
"freeze_memory", {"id": memory_id, "frozen": frozen}
|
|
708
|
+
)
|
|
709
|
+
|
|
710
|
+
async def export_memory(self, *, format: str = "json") -> Any:
|
|
711
|
+
"""Export your memories via the ``export_memory`` MCP tool.
|
|
712
|
+
|
|
713
|
+
Author-scoped, own collection only: a self-contained JSON array
|
|
714
|
+
or human-readable Markdown. The lightweight "my data" answer —
|
|
715
|
+
no admin gate.
|
|
716
|
+
|
|
717
|
+
Args:
|
|
718
|
+
format: Output format — ``"json"`` (default) or ``"markdown"``.
|
|
719
|
+
|
|
720
|
+
Returns:
|
|
721
|
+
Tool result.
|
|
722
|
+
"""
|
|
723
|
+
return await self.call_tool("export_memory", {"format": format})
|
|
724
|
+
|
|
725
|
+
async def import_memories(self, memories: Sequence[Dict[str, Any]]) -> Any:
|
|
726
|
+
"""Batch-import memories via the ``import_memories`` MCP tool.
|
|
727
|
+
|
|
728
|
+
First-run cold start: every entry goes through the same ingestion
|
|
729
|
+
core as ``store_memory`` (anchoring, gate, LTSM), with per-entry
|
|
730
|
+
independence and an honest partial-failure report. Cap: 200
|
|
731
|
+
entries per call.
|
|
732
|
+
|
|
733
|
+
Args:
|
|
734
|
+
memories: Batch of entries; each dict needs ``text`` and may
|
|
735
|
+
carry ``is_factual`` (bool) and/or ``metadata`` (object).
|
|
736
|
+
|
|
737
|
+
Returns:
|
|
738
|
+
Tool result.
|
|
739
|
+
"""
|
|
740
|
+
return await self.call_tool("import_memories", {"memories": list(memories)})
|
|
741
|
+
|
|
742
|
+
async def update_memory_sharing(
|
|
743
|
+
self,
|
|
744
|
+
*,
|
|
745
|
+
shared: bool,
|
|
746
|
+
memory_id: Optional[str] = None,
|
|
747
|
+
memory_ids: Optional[List[str]] = None,
|
|
748
|
+
scope: Optional[str] = None,
|
|
749
|
+
except_tag: Optional[str] = None,
|
|
750
|
+
except_ids: Optional[List[str]] = None,
|
|
751
|
+
shared_scope: Optional[str] = None,
|
|
752
|
+
confirm: Optional[bool] = None,
|
|
753
|
+
) -> Any:
|
|
754
|
+
"""Flip the cross-tenant sharing flag via the
|
|
755
|
+
``update_memory_sharing`` MCP tool.
|
|
756
|
+
|
|
757
|
+
Owner-side only: ``shared=True`` makes entries visible (read-only,
|
|
758
|
+
full text and detail) to tenants granted your collection;
|
|
759
|
+
``shared=False`` makes them private again. Target a single id, an
|
|
760
|
+
ids array, or a scope selector (``"all"``, ``"tag:<name>"``,
|
|
761
|
+
``"query:<text>"``); ``except_tag`` / ``except_ids`` exclude
|
|
762
|
+
entries from the match set. Batch exposure (>1 entry,
|
|
763
|
+
shared=true) is two-phase: the first call returns a dry-run
|
|
764
|
+
summary — re-issue with ``confirm=True`` to apply.
|
|
765
|
+
|
|
766
|
+
Args:
|
|
767
|
+
shared: True = share with granted tenants, false = private.
|
|
768
|
+
memory_id: Single memory vector ID (own collection only).
|
|
769
|
+
memory_ids: Batch: explicit list of memory IDs.
|
|
770
|
+
scope: Batch selector — ``"all"``, ``"tag:<name>"``, or
|
|
771
|
+
``"query:<text>"`` (share by meaning without tags).
|
|
772
|
+
except_tag: Exclude entries whose metadata.tags contains
|
|
773
|
+
this tag from the match set.
|
|
774
|
+
except_ids: Exclude these entry IDs from the match set.
|
|
775
|
+
shared_scope: Field-level exposure — ``"full"`` (default,
|
|
776
|
+
WYSIWYG) or ``"summary"`` (detail stripped for grantees).
|
|
777
|
+
confirm: Required true to apply a batch exposure of more
|
|
778
|
+
than one entry.
|
|
779
|
+
|
|
780
|
+
Returns:
|
|
781
|
+
Tool result (dry-run summary when a batch is not confirmed).
|
|
782
|
+
"""
|
|
783
|
+
arguments: Dict[str, Any] = {"shared": shared}
|
|
784
|
+
if memory_id is not None:
|
|
785
|
+
arguments["id"] = memory_id
|
|
786
|
+
if memory_ids is not None:
|
|
787
|
+
arguments["ids"] = memory_ids
|
|
788
|
+
if scope is not None:
|
|
789
|
+
arguments["scope"] = scope
|
|
790
|
+
if except_tag is not None:
|
|
791
|
+
arguments["except_tag"] = except_tag
|
|
792
|
+
if except_ids is not None:
|
|
793
|
+
arguments["except_ids"] = except_ids
|
|
794
|
+
if shared_scope is not None:
|
|
795
|
+
arguments["shared_scope"] = shared_scope
|
|
796
|
+
if confirm is not None:
|
|
797
|
+
arguments["confirm"] = confirm
|
|
798
|
+
return await self.call_tool("update_memory_sharing", arguments)
|
|
799
|
+
|
|
800
|
+
async def list_memory_tags(self) -> Any:
|
|
801
|
+
"""List your distinct memory tags via the ``list_memory_tags``
|
|
802
|
+
MCP tool: per-tag counts plus the number of untagged entries
|
|
803
|
+
(author-only). Useful before sharing by tag.
|
|
804
|
+
|
|
805
|
+
Returns:
|
|
806
|
+
Tool result.
|
|
807
|
+
"""
|
|
808
|
+
return await self.call_tool("list_memory_tags", {})
|
|
809
|
+
|
|
810
|
+
async def set_tenant_grant(
|
|
811
|
+
self,
|
|
812
|
+
tenant: str,
|
|
813
|
+
*,
|
|
814
|
+
collections: Optional[List[str]] = None,
|
|
815
|
+
revoke: Optional[bool] = None,
|
|
816
|
+
) -> Any:
|
|
817
|
+
"""Grant (or revoke) another tenant read access via the
|
|
818
|
+
``set_tenant_grant`` MCP tool.
|
|
819
|
+
|
|
820
|
+
Owner-side only — you decide unilaterally; the grantee cannot
|
|
821
|
+
self-provision a grant. Live immediately (no restart). Grantees
|
|
822
|
+
still only see entries you marked shared via
|
|
823
|
+
``update_memory_sharing``.
|
|
824
|
+
|
|
825
|
+
Args:
|
|
826
|
+
tenant: Grantee tenant id (must already exist in
|
|
827
|
+
security.tenant_keys).
|
|
828
|
+
collections: Collections to grant; defaults to your own
|
|
829
|
+
memory collection. You may only name collections you own.
|
|
830
|
+
revoke: True = revoke the grant; false/omit = grant.
|
|
831
|
+
Idempotent.
|
|
832
|
+
|
|
833
|
+
Returns:
|
|
834
|
+
Tool result.
|
|
835
|
+
"""
|
|
836
|
+
arguments: Dict[str, Any] = {"tenant": tenant}
|
|
837
|
+
if collections is not None:
|
|
838
|
+
arguments["collections"] = collections
|
|
839
|
+
if revoke is not None:
|
|
840
|
+
arguments["revoke"] = revoke
|
|
841
|
+
return await self.call_tool("set_tenant_grant", arguments)
|
|
842
|
+
|
|
843
|
+
async def list_tenant_grants(self) -> Any:
|
|
844
|
+
"""List which tenants currently hold read access to your
|
|
845
|
+
collection via the ``list_tenant_grants`` MCP tool.
|
|
846
|
+
|
|
847
|
+
Owner-side reverse lookup, shared-entry subset only, read-only.
|
|
848
|
+
Revoke with ``set_tenant_grant(revoke=True)``.
|
|
849
|
+
|
|
850
|
+
Returns:
|
|
851
|
+
Tool result.
|
|
852
|
+
"""
|
|
853
|
+
return await self.call_tool("list_tenant_grants", {})
|
|
854
|
+
|
|
855
|
+
async def share_with_tenant(
|
|
856
|
+
self,
|
|
857
|
+
tenant: str,
|
|
858
|
+
what: str,
|
|
859
|
+
*,
|
|
860
|
+
shared_scope: Optional[str] = None,
|
|
861
|
+
confirm: Optional[bool] = None,
|
|
862
|
+
) -> Any:
|
|
863
|
+
"""Guided one-shot share via the ``share_with_tenant`` MCP tool.
|
|
864
|
+
|
|
865
|
+
Grants the tenant read access AND semantically selects matching
|
|
866
|
+
entries of yours, then returns a dry-run with per-entry previews
|
|
867
|
+
and sensitivity flags; re-issue with ``confirm=True`` to apply.
|
|
868
|
+
Pure composition of ``set_tenant_grant`` +
|
|
869
|
+
``update_memory_sharing(scope="query:…")`` — same two-phase
|
|
870
|
+
confirm. Revoke later with ``set_tenant_grant(revoke=True)``.
|
|
871
|
+
|
|
872
|
+
Args:
|
|
873
|
+
tenant: Grantee tenant id (must already exist in
|
|
874
|
+
security.tenant_keys).
|
|
875
|
+
what: Plain-words description of what to share — matched
|
|
876
|
+
semantically against your own entries.
|
|
877
|
+
shared_scope: ``"full"`` (default, WYSIWYG) or ``"summary"``
|
|
878
|
+
(detail stripped for grantees).
|
|
879
|
+
confirm: Required true to apply (first call returns a
|
|
880
|
+
dry-run summary).
|
|
881
|
+
|
|
882
|
+
Returns:
|
|
883
|
+
Tool result (dry-run summary when not confirmed).
|
|
884
|
+
"""
|
|
885
|
+
arguments: Dict[str, Any] = {"tenant": tenant, "what": what}
|
|
886
|
+
if shared_scope is not None:
|
|
887
|
+
arguments["shared_scope"] = shared_scope
|
|
888
|
+
if confirm is not None:
|
|
889
|
+
arguments["confirm"] = confirm
|
|
890
|
+
return await self.call_tool("share_with_tenant", arguments)
|
|
891
|
+
|
|
892
|
+
async def update_share_subscription(
|
|
893
|
+
self,
|
|
894
|
+
*,
|
|
895
|
+
what: Optional[str] = None,
|
|
896
|
+
tenant: Optional[str] = None,
|
|
897
|
+
shared_scope: Optional[str] = None,
|
|
898
|
+
remove: Optional[bool] = None,
|
|
899
|
+
) -> Any:
|
|
900
|
+
"""Manage your standing share rule via the
|
|
901
|
+
``update_share_subscription`` MCP tool.
|
|
902
|
+
|
|
903
|
+
"Future entries matching <what> go to <tenant>". Pure storage —
|
|
904
|
+
never shares anything by itself: pending matches appear via
|
|
905
|
+
``check_share_subscriptions`` and apply only after your explicit
|
|
906
|
+
confirm. ``remove=True`` clears the subscription.
|
|
907
|
+
|
|
908
|
+
Args:
|
|
909
|
+
what: Plain-words description of the kind of content to
|
|
910
|
+
share (semantically matched later).
|
|
911
|
+
tenant: Grantee tenant id for future matches.
|
|
912
|
+
shared_scope: Field-level exposure for future applies
|
|
913
|
+
(default ``"full"``).
|
|
914
|
+
remove: True = clear your subscription.
|
|
915
|
+
|
|
916
|
+
Returns:
|
|
917
|
+
Tool result.
|
|
918
|
+
"""
|
|
919
|
+
arguments: Dict[str, Any] = {}
|
|
920
|
+
if what is not None:
|
|
921
|
+
arguments["what"] = what
|
|
922
|
+
if tenant is not None:
|
|
923
|
+
arguments["tenant"] = tenant
|
|
924
|
+
if shared_scope is not None:
|
|
925
|
+
arguments["shared_scope"] = shared_scope
|
|
926
|
+
if remove is not None:
|
|
927
|
+
arguments["remove"] = remove
|
|
928
|
+
return await self.call_tool("update_share_subscription", arguments)
|
|
929
|
+
|
|
930
|
+
async def check_share_subscriptions(self) -> Any:
|
|
931
|
+
"""Lazily evaluate your standing share subscription via the
|
|
932
|
+
``check_share_subscriptions`` MCP tool.
|
|
933
|
+
|
|
934
|
+
Lists UNSHARED entries of yours that currently match, with
|
|
935
|
+
previews and sensitivity flags, plus the exact one-step confirm
|
|
936
|
+
command. Read-only — nothing is shared by checking.
|
|
937
|
+
|
|
938
|
+
Returns:
|
|
939
|
+
Tool result.
|
|
940
|
+
"""
|
|
941
|
+
return await self.call_tool("check_share_subscriptions", {})
|
|
942
|
+
|
|
943
|
+
async def get_memory_rules(
|
|
944
|
+
self, *, target: str = "all", lang: str = "en"
|
|
945
|
+
) -> Any:
|
|
946
|
+
"""Fetch the corrected, scope-guarded memory-protocol rule block
|
|
947
|
+
via the ``get_memory_rules`` MCP tool.
|
|
948
|
+
|
|
949
|
+
Returns the block for a mainstream agent tool together with the
|
|
950
|
+
exact local path to write it into; the calling agent shows the
|
|
951
|
+
block to the user and writes the file itself.
|
|
952
|
+
|
|
953
|
+
Args:
|
|
954
|
+
target: One of ``claude_code`` | ``cursor`` | ``workbuddy``
|
|
955
|
+
| ``all`` (default).
|
|
956
|
+
lang: Rule locale — ``en`` (default) or ``zh``.
|
|
957
|
+
|
|
958
|
+
Returns:
|
|
959
|
+
Tool result.
|
|
960
|
+
"""
|
|
961
|
+
return await self.call_tool(
|
|
962
|
+
"get_memory_rules", {"target": target, "lang": lang}
|
|
963
|
+
)
|
|
964
|
+
|
|
596
965
|
|
|
597
966
|
# ---------------------------------------------------------------------------
|
|
598
967
|
# Synchronous MCP Client
|
|
@@ -718,16 +1087,59 @@ class SyncMcpClient:
|
|
|
718
1087
|
response.raise_for_error()
|
|
719
1088
|
return response.result
|
|
720
1089
|
|
|
721
|
-
def store_memory(
|
|
722
|
-
|
|
1090
|
+
def store_memory(
|
|
1091
|
+
self,
|
|
1092
|
+
content: str,
|
|
1093
|
+
*,
|
|
1094
|
+
agent_id: str = "default",
|
|
1095
|
+
source: Optional[str] = "sdk",
|
|
1096
|
+
is_factual: bool = False,
|
|
1097
|
+
is_obsolete: Optional[bool] = None,
|
|
1098
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
1099
|
+
) -> Any:
|
|
1100
|
+
"""Store a memory via the ``store_memory`` MCP tool.
|
|
1101
|
+
|
|
1102
|
+
``is_obsolete=True`` strips any anchor so the memory re-enters
|
|
1103
|
+
normal LTSM decay; ``metadata`` is merged with the ``source``
|
|
1104
|
+
origin tag.
|
|
1105
|
+
"""
|
|
723
1106
|
arguments: Dict[str, Any] = {"agent_id": agent_id, "text": content, "is_factual": is_factual}
|
|
1107
|
+
if is_obsolete is not None:
|
|
1108
|
+
arguments["is_obsolete"] = is_obsolete
|
|
1109
|
+
merged_metadata = dict(metadata or {})
|
|
724
1110
|
if source:
|
|
725
|
-
|
|
1111
|
+
merged_metadata.setdefault("source", source)
|
|
1112
|
+
if merged_metadata:
|
|
1113
|
+
arguments["metadata"] = merged_metadata
|
|
726
1114
|
return self.call_tool("store_memory", arguments)
|
|
727
1115
|
|
|
728
|
-
def search_memory(
|
|
729
|
-
|
|
730
|
-
|
|
1116
|
+
def search_memory(
|
|
1117
|
+
self,
|
|
1118
|
+
query: str,
|
|
1119
|
+
*,
|
|
1120
|
+
agent_id: str = "default",
|
|
1121
|
+
top_k: int = 5,
|
|
1122
|
+
since_ts: Optional[int] = None,
|
|
1123
|
+
until_ts: Optional[int] = None,
|
|
1124
|
+
tags: Optional[List[str]] = None,
|
|
1125
|
+
keyword: Optional[str] = None,
|
|
1126
|
+
) -> Any:
|
|
1127
|
+
"""Search memories via the ``search_memory`` MCP tool.
|
|
1128
|
+
|
|
1129
|
+
Optional R3-4 structured filters: ``since_ts`` / ``until_ts``
|
|
1130
|
+
(epoch seconds), ``tags`` (any-of), ``keyword`` (substring,
|
|
1131
|
+
case-insensitive).
|
|
1132
|
+
"""
|
|
1133
|
+
arguments: Dict[str, Any] = {"agent_id": agent_id, "query": query, "top_k": top_k}
|
|
1134
|
+
if since_ts is not None:
|
|
1135
|
+
arguments["since_ts"] = since_ts
|
|
1136
|
+
if until_ts is not None:
|
|
1137
|
+
arguments["until_ts"] = until_ts
|
|
1138
|
+
if tags is not None:
|
|
1139
|
+
arguments["tags"] = tags
|
|
1140
|
+
if keyword is not None:
|
|
1141
|
+
arguments["keyword"] = keyword
|
|
1142
|
+
return self.call_tool("search_memory", arguments)
|
|
731
1143
|
|
|
732
1144
|
def store_media(
|
|
733
1145
|
self,
|
|
@@ -790,9 +1202,38 @@ class SyncMcpClient:
|
|
|
790
1202
|
{"clip_vector": list(clip_vector), "top_k": top_k, "min_score": min_score},
|
|
791
1203
|
)
|
|
792
1204
|
|
|
793
|
-
def list_memories(
|
|
794
|
-
|
|
795
|
-
|
|
1205
|
+
def list_memories(
|
|
1206
|
+
self,
|
|
1207
|
+
*,
|
|
1208
|
+
limit: int = 20,
|
|
1209
|
+
shared_with_me: Optional[bool] = None,
|
|
1210
|
+
since_hours: Optional[int] = None,
|
|
1211
|
+
since_ts: Optional[int] = None,
|
|
1212
|
+
until_ts: Optional[int] = None,
|
|
1213
|
+
tags: Optional[List[str]] = None,
|
|
1214
|
+
keyword: Optional[str] = None,
|
|
1215
|
+
) -> Any:
|
|
1216
|
+
"""List memories via the ``list_memories`` MCP tool.
|
|
1217
|
+
|
|
1218
|
+
``shared_with_me=True`` is the inbox view (only entries other
|
|
1219
|
+
tenants shared with you); optional R3-4 structured filters:
|
|
1220
|
+
``since_ts`` / ``until_ts`` (epoch seconds), ``tags`` (any-of),
|
|
1221
|
+
``keyword`` (substring, case-insensitive).
|
|
1222
|
+
"""
|
|
1223
|
+
arguments: Dict[str, Any] = {"limit": limit}
|
|
1224
|
+
if shared_with_me is not None:
|
|
1225
|
+
arguments["shared_with_me"] = shared_with_me
|
|
1226
|
+
if since_hours is not None:
|
|
1227
|
+
arguments["since_hours"] = since_hours
|
|
1228
|
+
if since_ts is not None:
|
|
1229
|
+
arguments["since_ts"] = since_ts
|
|
1230
|
+
if until_ts is not None:
|
|
1231
|
+
arguments["until_ts"] = until_ts
|
|
1232
|
+
if tags is not None:
|
|
1233
|
+
arguments["tags"] = tags
|
|
1234
|
+
if keyword is not None:
|
|
1235
|
+
arguments["keyword"] = keyword
|
|
1236
|
+
return self.call_tool("list_memories", arguments)
|
|
796
1237
|
|
|
797
1238
|
def get_memory(self, memory_id: str) -> Any:
|
|
798
1239
|
"""Fetch one memory by its vector ID via the ``get_memory`` MCP tool."""
|
|
@@ -829,3 +1270,155 @@ class SyncMcpClient:
|
|
|
829
1270
|
"""Remove a factuality template via the ``remove_factuality_template``
|
|
830
1271
|
MCP tool."""
|
|
831
1272
|
return self.call_tool("remove_factuality_template", {"text": text})
|
|
1273
|
+
|
|
1274
|
+
def update_memory(self, memory_id: str, text: str, *, is_factual: Optional[bool] = None) -> Any:
|
|
1275
|
+
"""Correct a memory in place via the ``update_memory`` MCP tool.
|
|
1276
|
+
|
|
1277
|
+
Same id and anchors; the corrected text is re-embedded and the
|
|
1278
|
+
previous text appended to a bounded history. ``is_factual``
|
|
1279
|
+
optionally re-grades the anchor; absent preserves the current
|
|
1280
|
+
grade. Author-only.
|
|
1281
|
+
"""
|
|
1282
|
+
arguments: Dict[str, Any] = {"id": memory_id, "text": text}
|
|
1283
|
+
if is_factual is not None:
|
|
1284
|
+
arguments["is_factual"] = is_factual
|
|
1285
|
+
return self.call_tool("update_memory", arguments)
|
|
1286
|
+
|
|
1287
|
+
def freeze_memory(self, memory_id: str, frozen: bool) -> Any:
|
|
1288
|
+
"""Freeze (or unfreeze) one of your memories via the
|
|
1289
|
+
``freeze_memory`` MCP tool: frozen entries are exempt from LTSM
|
|
1290
|
+
distillation and staleness scavenging. Author-only, reversible
|
|
1291
|
+
any time."""
|
|
1292
|
+
return self.call_tool("freeze_memory", {"id": memory_id, "frozen": frozen})
|
|
1293
|
+
|
|
1294
|
+
def export_memory(self, *, format: str = "json") -> Any:
|
|
1295
|
+
"""Export your memories via the ``export_memory`` MCP tool —
|
|
1296
|
+
author-scoped JSON (default) or Markdown."""
|
|
1297
|
+
return self.call_tool("export_memory", {"format": format})
|
|
1298
|
+
|
|
1299
|
+
def import_memories(self, memories: Sequence[Dict[str, Any]]) -> Any:
|
|
1300
|
+
"""Batch-import memories via the ``import_memories`` MCP tool.
|
|
1301
|
+
|
|
1302
|
+
Cold start, cap 200 entries per call; each entry dict needs
|
|
1303
|
+
``text`` and may carry ``is_factual`` / ``metadata``.
|
|
1304
|
+
"""
|
|
1305
|
+
return self.call_tool("import_memories", {"memories": list(memories)})
|
|
1306
|
+
|
|
1307
|
+
def update_memory_sharing(
|
|
1308
|
+
self,
|
|
1309
|
+
*,
|
|
1310
|
+
shared: bool,
|
|
1311
|
+
memory_id: Optional[str] = None,
|
|
1312
|
+
memory_ids: Optional[List[str]] = None,
|
|
1313
|
+
scope: Optional[str] = None,
|
|
1314
|
+
except_tag: Optional[str] = None,
|
|
1315
|
+
except_ids: Optional[List[str]] = None,
|
|
1316
|
+
shared_scope: Optional[str] = None,
|
|
1317
|
+
confirm: Optional[bool] = None,
|
|
1318
|
+
) -> Any:
|
|
1319
|
+
"""Flip the cross-tenant sharing flag via the
|
|
1320
|
+
``update_memory_sharing`` MCP tool — owner-side only.
|
|
1321
|
+
|
|
1322
|
+
Target a single id, an ids array, or a scope selector
|
|
1323
|
+
(``"all"`` | ``"tag:<name>"`` | ``"query:<text>"``). Batch
|
|
1324
|
+
exposure (>1 entry, shared=true) is two-phase: re-issue with
|
|
1325
|
+
``confirm=True`` after the dry-run summary.
|
|
1326
|
+
"""
|
|
1327
|
+
arguments: Dict[str, Any] = {"shared": shared}
|
|
1328
|
+
if memory_id is not None:
|
|
1329
|
+
arguments["id"] = memory_id
|
|
1330
|
+
if memory_ids is not None:
|
|
1331
|
+
arguments["ids"] = memory_ids
|
|
1332
|
+
if scope is not None:
|
|
1333
|
+
arguments["scope"] = scope
|
|
1334
|
+
if except_tag is not None:
|
|
1335
|
+
arguments["except_tag"] = except_tag
|
|
1336
|
+
if except_ids is not None:
|
|
1337
|
+
arguments["except_ids"] = except_ids
|
|
1338
|
+
if shared_scope is not None:
|
|
1339
|
+
arguments["shared_scope"] = shared_scope
|
|
1340
|
+
if confirm is not None:
|
|
1341
|
+
arguments["confirm"] = confirm
|
|
1342
|
+
return self.call_tool("update_memory_sharing", arguments)
|
|
1343
|
+
|
|
1344
|
+
def list_memory_tags(self) -> Any:
|
|
1345
|
+
"""List your distinct memory tags via the ``list_memory_tags``
|
|
1346
|
+
MCP tool: per-tag counts plus the number of untagged entries."""
|
|
1347
|
+
return self.call_tool("list_memory_tags", {})
|
|
1348
|
+
|
|
1349
|
+
def set_tenant_grant(
|
|
1350
|
+
self,
|
|
1351
|
+
tenant: str,
|
|
1352
|
+
*,
|
|
1353
|
+
collections: Optional[List[str]] = None,
|
|
1354
|
+
revoke: Optional[bool] = None,
|
|
1355
|
+
) -> Any:
|
|
1356
|
+
"""Grant (or revoke) another tenant read access via the
|
|
1357
|
+
``set_tenant_grant`` MCP tool — owner-side only, live
|
|
1358
|
+
immediately. Grantees still only see entries you marked shared."""
|
|
1359
|
+
arguments: Dict[str, Any] = {"tenant": tenant}
|
|
1360
|
+
if collections is not None:
|
|
1361
|
+
arguments["collections"] = collections
|
|
1362
|
+
if revoke is not None:
|
|
1363
|
+
arguments["revoke"] = revoke
|
|
1364
|
+
return self.call_tool("set_tenant_grant", arguments)
|
|
1365
|
+
|
|
1366
|
+
def list_tenant_grants(self) -> Any:
|
|
1367
|
+
"""List which tenants currently hold read access to your
|
|
1368
|
+
collection via the ``list_tenant_grants`` MCP tool — owner-side
|
|
1369
|
+
reverse lookup, read-only."""
|
|
1370
|
+
return self.call_tool("list_tenant_grants", {})
|
|
1371
|
+
|
|
1372
|
+
def share_with_tenant(
|
|
1373
|
+
self,
|
|
1374
|
+
tenant: str,
|
|
1375
|
+
what: str,
|
|
1376
|
+
*,
|
|
1377
|
+
shared_scope: Optional[str] = None,
|
|
1378
|
+
confirm: Optional[bool] = None,
|
|
1379
|
+
) -> Any:
|
|
1380
|
+
"""Guided one-shot share via the ``share_with_tenant`` MCP tool:
|
|
1381
|
+
grants read access and semantically selects matching entries,
|
|
1382
|
+
returning a dry-run; re-issue with ``confirm=True`` to apply."""
|
|
1383
|
+
arguments: Dict[str, Any] = {"tenant": tenant, "what": what}
|
|
1384
|
+
if shared_scope is not None:
|
|
1385
|
+
arguments["shared_scope"] = shared_scope
|
|
1386
|
+
if confirm is not None:
|
|
1387
|
+
arguments["confirm"] = confirm
|
|
1388
|
+
return self.call_tool("share_with_tenant", arguments)
|
|
1389
|
+
|
|
1390
|
+
def update_share_subscription(
|
|
1391
|
+
self,
|
|
1392
|
+
*,
|
|
1393
|
+
what: Optional[str] = None,
|
|
1394
|
+
tenant: Optional[str] = None,
|
|
1395
|
+
shared_scope: Optional[str] = None,
|
|
1396
|
+
remove: Optional[bool] = None,
|
|
1397
|
+
) -> Any:
|
|
1398
|
+
"""Manage your standing share rule via the
|
|
1399
|
+
``update_share_subscription`` MCP tool — pure storage, never
|
|
1400
|
+
shares by itself; pending matches surface via
|
|
1401
|
+
``check_share_subscriptions``. ``remove=True`` clears it."""
|
|
1402
|
+
arguments: Dict[str, Any] = {}
|
|
1403
|
+
if what is not None:
|
|
1404
|
+
arguments["what"] = what
|
|
1405
|
+
if tenant is not None:
|
|
1406
|
+
arguments["tenant"] = tenant
|
|
1407
|
+
if shared_scope is not None:
|
|
1408
|
+
arguments["shared_scope"] = shared_scope
|
|
1409
|
+
if remove is not None:
|
|
1410
|
+
arguments["remove"] = remove
|
|
1411
|
+
return self.call_tool("update_share_subscription", arguments)
|
|
1412
|
+
|
|
1413
|
+
def check_share_subscriptions(self) -> Any:
|
|
1414
|
+
"""Lazily evaluate your standing share subscription via the
|
|
1415
|
+
``check_share_subscriptions`` MCP tool — read-only, nothing is
|
|
1416
|
+
shared by checking."""
|
|
1417
|
+
return self.call_tool("check_share_subscriptions", {})
|
|
1418
|
+
|
|
1419
|
+
def get_memory_rules(self, *, target: str = "all", lang: str = "en") -> Any:
|
|
1420
|
+
"""Fetch the memory-protocol rule block via the
|
|
1421
|
+
``get_memory_rules`` MCP tool for claude_code | cursor |
|
|
1422
|
+
workbuddy | all (default), with the local path to write it
|
|
1423
|
+
into. ``lang`` is en (default) or zh."""
|
|
1424
|
+
return self.call_tool("get_memory_rules", {"target": target, "lang": lang})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|