@cerefox/memory 0.10.3 → 0.11.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.
@@ -568,6 +568,11 @@ You have access to a personal knowledge base via the searchKnowledgeBase action.
568
568
  When the user asks a question, always search the knowledge base first using a
569
569
  relevant query. Present results by document title, citing the source for every claim.
570
570
  Use ingestNote to save any new information the user asks you to remember.
571
+ When UPDATING an existing document, first call getDocument and note its
572
+ content_hash, then pass it as expected_content_hash on ingestNote. If you get a
573
+ 409 conflict, the document changed underneath you: call getDocument again, merge
574
+ your changes into the latest content, and retry with the new hash — never
575
+ overwrite blindly.
571
576
  ```
572
577
 
573
578
  ### Path B verification
@@ -604,7 +609,7 @@ In the action editor, paste this schema (replace `<your-project-ref>`):
604
609
  openapi: 3.1.0
605
610
  info:
606
611
  title: Cerefox Knowledge Base
607
- version: 1.8.0
612
+ version: 2.0.0
608
613
  servers:
609
614
  - url: https://<your-project-ref>.supabase.co/functions/v1
610
615
  paths:
@@ -731,6 +736,23 @@ paths:
731
736
  instead of creating a new one. The previous content is archived
732
737
  as a version. If content is unchanged, the document is skipped
733
738
  (no re-indexing). Ignored when document_id is provided.
739
+ expected_content_hash:
740
+ type: string
741
+ description: >
742
+ REQUIRED on content updates (optimistic concurrency, v2.0.0):
743
+ the content_hash of the version this edit was based on, as
744
+ returned by getDocument / searchKnowledgeBase / metadataSearch.
745
+ If the document changed since it was read, the update fails
746
+ with HTTP 409 — re-read the document, merge your changes,
747
+ retry with the new hash. Not needed when creating.
748
+ last_write_wins:
749
+ type: boolean
750
+ default: false
751
+ description: >
752
+ Explicitly skip the concurrency check and overwrite regardless
753
+ of concurrent changes. Use ONLY when an external source of
754
+ truth makes conflicts meaningless. Recorded in the audit log.
755
+ Never use it to silence a 409 conflict.
734
756
  author:
735
757
  type: string
736
758
  description: >
@@ -753,8 +775,19 @@ paths:
753
775
  project_id?, project_name?, # set when a project was assigned on create
754
776
  skipped?, # true when identical content was deduplicated
755
777
  updated?, # true when an existing doc was updated
778
+ content_hash?, # the NEW hash after an update (the next edit's token)
756
779
  message?, # human note on dedup/skip/update
757
780
  note? } # note when a flag (e.g. update_if_exists) was overridden
781
+ '400':
782
+ description: >
783
+ Missing expected_content_hash on a content update (and
784
+ last_write_wins not set). Read the document first, then retry
785
+ with its content_hash.
786
+ '409':
787
+ description: >
788
+ Conflict — the document changed since it was read. Call getDocument
789
+ for the latest content + content_hash, merge your changes, and
790
+ retry with the new hash. Do not overwrite blindly.
758
791
  /cerefox-metadata:
759
792
  post:
760
793
  operationId: listMetadataKeys
@@ -802,7 +835,9 @@ paths:
802
835
  description: >
803
836
  Document content and metadata:
804
837
  { document_id, doc_title, full_content, chunk_count, total_chars,
805
- is_archived, version_id }
838
+ is_archived, version_id, content_hash }.
839
+ content_hash is the document's CURRENT hash — pass it back as
840
+ expected_content_hash when updating via ingestNote.
806
841
  '404':
807
842
  description: Document not found
808
843
  /cerefox-list-versions:
@@ -895,15 +930,17 @@ paths:
895
930
  post:
896
931
  operationId: metadataSearch
897
932
  summary: >
898
- Find documents by metadata key-value criteria without a text search term.
899
- Use to discover documents tagged with specific attributes or browse by taxonomy.
933
+ Find or list documents by metadata key-value criteria without a text
934
+ search term. Use to discover documents tagged with specific attributes,
935
+ browse by taxonomy, or list a project's documents (pass project_id alone).
936
+ At least one of metadata_filter, project_id, updated_since, or
937
+ created_since must be supplied.
900
938
  requestBody:
901
939
  required: true
902
940
  content:
903
941
  application/json:
904
942
  schema:
905
943
  type: object
906
- required: [metadata_filter]
907
944
  properties:
908
945
  metadata_filter:
909
946
  type: object
@@ -912,10 +949,14 @@ paths:
912
949
  description: >
913
950
  Key-value pairs; ALL must match (AND semantics).
914
951
  Example: {"type": "decision", "status": "active"}.
952
+ Optional — omit (or pass {}) to list by project_id / time
953
+ range alone. At least one filter (metadata_filter, project_id,
954
+ updated_since, or created_since) is required.
915
955
  project_id:
916
956
  type: string
917
957
  description: >
918
- Filter by project UUID (optional). NOTE: this is the project
958
+ Filter by project UUID (optional). Sufficient on its own to
959
+ list that project's documents. NOTE: this is the project
919
960
  UUID, not its name — unlike searchKnowledgeBase / ingestNote
920
961
  which take project_name. Get UUIDs from listProjects.
921
962
  updated_since:
@@ -946,7 +987,9 @@ paths:
946
987
  Array of matching documents:
947
988
  [{ document_id, title, doc_metadata, review_status, source, created_at,
948
989
  updated_at, total_chars, chunk_count, project_ids, project_names,
949
- version_count, content }]
990
+ version_count, content_hash, content }].
991
+ content_hash is the concurrency token — pass it back as
992
+ expected_content_hash when updating via ingestNote.
950
993
  ```
951
994
 
952
995
  **Step 3 — Configure authentication**
@@ -1148,6 +1191,7 @@ The agent docs are written around MCP tool names. **CLI flag names match MCP par
1148
1191
  | `cerefox_get_document` | `cerefox document get <document-id> --version-id <vid> --requestor <name>` |
1149
1192
  | `cerefox_list_versions` | `cerefox document version list <document-id> --requestor <name>` |
1150
1193
  | `cerefox_list_projects` | `cerefox project list --requestor <name>` |
1194
+ | `cerefox_set_document_projects` | `cerefox document set-projects <document-id> <name...> --author <a> --author-type user\|agent` (or `--clear`) |
1151
1195
  | `cerefox_list_metadata_keys` | `cerefox metadata keys` |
1152
1196
  | `cerefox_metadata_search` | `cerefox metadata search --metadata-filter '<json>' --project-name <n> --requestor <name>` |
1153
1197
  | `cerefox_get_audit_log` | `cerefox audit list --document-id <id> --author <a> --operation <op> --since <iso> --until <iso> --limit N --json --requestor <name>` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerefox/memory",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "description": "Cerefox — user-owned shared memory for AI agents. The local TypeScript runtime: stdio MCP server in v0.4; CLI binary added in v0.5; in-process web server in v0.6; ingestion pipeline in v0.7.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/fstamatelopoulos/cerefox",