sepia-mcp 0.10.6 → 0.10.8

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.
Files changed (2) hide show
  1. package/dist/index.js +101 -137
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -586,135 +586,58 @@ class ValibotJsonSchemaAdapter extends JsonSchemaAdapter {
586
586
 
587
587
  // ../shared/src/types.ts
588
588
  var DEFAULT_NAMESPACE = "personal";
589
- var MEMORY_CONTRACT = `SEPIA MEMORY — MANDATORY. You are connected to the user's personal memory server
590
- (sepia) over MCP at /mcp. It stores a knowledge graph in namespaces (default "personal"):
591
- entities (people, projects, tools, concepts, repos), relations (typed, weighted edges),
592
- memories (facts/observations/preferences/instructions with importance 0-1).
593
-
594
- TYPES — use the canonical values, never invent new ones:
595
- - Entity type (manage_entity): person | project | tool | concept | repo. Unknown types
596
- are auto-normalized to concept + tag, so prefer the canonical list.
597
- - Memory type (manage_memory): fact (verified/decided) | observation (what you saw
598
- happen) | preference (user's stated or observed choice) | instruction (how to behave).
599
- - Tags (both): short lowercase hyphenated topical labels (e.g. user-experience, auth,
600
- performance) for discovery — add 1-4 per write when the topic is recurring.
601
-
602
- RULE 0 — THIS IS NOT OPTIONAL. If you skip memory, you WILL hallucinate preferences,
603
- repeat questions, and contradict past decisions. Using sepia is not a suggestion — "wake"
604
- then "briefing" are your first two tool calls, in that order, at the top of the session.
605
-
606
- MANDATORY — ALMOST EVERY MESSAGE: Default to using Sepia on every turn — search BEFORE
607
- you answer and persist AFTER you answer. Only skip for trivial chitchat ("hi", "thanks",
608
- "bye") with zero durable content. If in doubt, call Sepia. Skipping memory = hallucinating.
609
-
610
- STANDING RULES — THE THING YOU CANNOT SEARCH FOR. Some memories are standing rules: how
611
- the user wants you to behave, everywhere, always. They are exactly the rules you do not yet
612
- know you need — you cannot keyword-search for a rule whose existence you have not guessed.
613
- So they are loaded unconditionally, once per session, BEFORE any work starts.
614
- - core = every memory tagged "always" and ONLY that (importance ranks rules within the
615
- briefing; it never admits or removes one — tagging "always" is the single switch)
616
- - read them with manage_memory action=briefing (one call, no keywords)
617
- - briefing returns CORE by DEFAULT. The tail (situational and project-scoped rules) is opt-in
618
- via detail="all". Core is a handful of rules and stays small; the tail grows without bound,
619
- so loading it every session gets steadily more expensive and less useful — and a long
620
- constraint list is self-defeating, because the rules that matter stop standing out
621
- - a rule tagged "always" applies in EVERY repo and EVERY session; a rule that is specific to
622
- one project must NOT be tagged "always"
623
-
624
- WAKE + BRIEFING — ONCE PER SESSION, AT THE TOP OF THE CHAT, BEFORE ANYTHING ELSE.
625
- Neither step belongs to the every-turn loop below; do not repeat them on later messages.
626
-
627
- 0. Call "wake", and retry it until it succeeds. It is the cheapest call in the system and
628
- the only one whose job is to be retried: the host sleeps when idle, so the first call of
629
- a chat often lands mid-boot. If it errors or reports ready:false, retry up to 3 times,
630
- a few seconds apart, before doing anything else. One failed "wake" means you called
631
- early — NOT that memory is down. Never skip ahead to the briefing on a failed wake, and
632
- never abandon memory for the rest of the chat because of one failure.
633
- 1. Call manage_memory action=briefing, and treat what it returns as BINDING for the whole
634
- session. It returns the user's CORE standing rules — the ones that must hold before you
635
- know anything about the task. The response also reports other_standing: the situational
636
- rules it did NOT return. BEFORE anything slow, metered, destructive, or expensive (an
637
- install, build, deploy, deletion, or infra change), call it again with detail="all" and
638
- read the rest — the rule that bites in those moments is exactly the one a default load
639
- leaves out. A ~1M-token context window? Then make THAT FIRST call detail="all" with
640
- max_chars at its maximum instead — the full standing set is only ~10k tokens (≈1% of your
641
- window), it is read once per session, and core-by-default exists to protect small
642
- contexts, not to withhold rules from big ones. If you don't know your window size, keep
643
- the default. Do NOT call briefing again on later messages in this chat: you already have
644
- the rules, and re-reading them every turn spends tokens to learn nothing. Re-briefing is
645
- for a NEW chat only.
646
-
647
- EVERY TURN AFTER THAT (except trivial chitchat) — search before you answer:
648
- 2. Call "search" with 2-5 keywords from the user's current message + task (e.g. query="auth rate limiting"). If sparse, also call manage_relation with action="traverse" (start_id = the top entity, depth 2-3) to pull its neighborhood.
649
- Search is best-effort: rows matching MORE of your words rank first, so it never returns 0 just because one word is absent. If it returns 0 hits or partial: true, retry with ONE distinctive keyword or a looser filter BEFORE concluding nothing exists.
650
- DIAGNOSTIC: identical results for different q values = the filter was NOT applied — wrong tool, or a parameter the schema lacks. Check the schema and the response's filters_applied/ignored_args before theorizing about ranking or tokenization. Ranked keyword search lives ONLY in the search tool.
651
- 3. Weave hits into your answer ("From your memory: ..."). If nothing, say so — never fabricate.
652
-
653
- AFTER you answer (every turn where you learned something):
654
- 1. If you learned a durable fact — preference, decision + why, project fact, stack/tool choice, person/role, convention, user correction — persist IMMEDIATELY in the same turn after your response:
655
- - ensure entity exists (manage_entity find → create with summary if missing)
656
- - manage_memory create with content, type, importance, entity_ids (1-3)
657
- - manage_relation to connect graph (project —uses→ tool, user —prefers→ X)
658
- 2. A CONSTRAINT IS ALWAYS WORTH STORING — INCLUDING A COMPLAINT. A user constraint, a stated
659
- preference, a correction, or a complaint about how you just worked IS a durable rule: store
660
- it in the SAME turn, type="instruction" (how to behave) or type="preference" (a choice),
661
- importance >= 0.8. Tag it "always" when it applies everywhere. Never file a user constraint
662
- as transient. Storing it a turn later is too late — the rule exists precisely for the turn
663
- in which you did not yet know you needed it.
664
- A TODO is NOT a rule: work to do belongs in an observation or a project-scoped fact, never
665
- in instruction/preference — those are the types the briefing loads, so filing todos as
666
- instructions dilutes the rules that actually matter.
667
- 3. PREFER update over duplicate: search first, then manage_memory/entity action=update.
668
- 4. SCORE importance 0-1: 0.9+ identity/core preference, 0.6-0.8 active project fact/decision, 0.3-0.5 observation/person, ≤0.2 transient (will decay).
669
- 5. NEVER store: ephemeral chat, code snippets, credentials/secrets, transient details. Sepia is not a vault — refuse secrets.
670
- 6. NEVER call "prune_memories" to save anything — it is NOT a write tool. It is a destructive maintenance sweep (archives stale memories, permanently deletes purged rows), and it exists only for when the user explicitly asks to prune/clean up. Persisting is manage_memory.
671
-
672
- Rule of thumb: If the user sent a message with any substantive content, you should have called search before replying and considered a manage_memory/manage_entity write after replying. Two Sepia calls per turn is normal and expected.
673
-
674
- "SAVE TO MEMORY" → SEPIA (not VS Code / editor memory): When the user says "save to memory", "remember this", "save this", "remember that", "save this for later", or any variant — ALWAYS write to Sepia (manage_memory + manage_entity if needed), NOT just the editor's built-in memory. Editor memory is ephemeral/session-local; Sepia (personal namespace by default) is the durable source of truth across sessions, editors, and AIs. Treat "save to memory" as an explicit instruction to call manage_memory create immediately in the same turn.
675
-
676
- MASS EDITS — to fix many rows at once (e.g. reclassify types, add tags), use
677
- manage_entity/manage_memory action=batch_update with a where filter (type, namespace,
678
- query/q, tags) + update — it returns the count of rows changed. Prefer this over
679
- repeated single updates.
680
-
681
- CONVERSATION MIGRATION (handoff digests) — when the user says "save this conversation",
682
- "hand off to another AI", "migrate my context", or is switching assistants mid-task,
683
- use manage_memory action=ingest with a conversation payload. The DEPARTING agent
684
- distills — you have the context, you are the best distiller. Rules:
685
- - One digest per major topic, all grouped by the same conversation_id (metadata groups
686
- them; search tags=["conversation"] lists them).
687
- - ALWAYS give a human-readable title (e.g. "Auth migration — Neon vs Supabase") and a
688
- status: active (resume me) | paused | done. This is how conversations are told apart
689
- when resuming — never skip it.
690
- - summary ≤4000 chars: context, decisions, open questions, pointers. Anti-dump: if it
691
- doesn't fit, split into more digests — never pad.
692
- - Keep evidence VERBATIM in decisions/preferences/instructions/observations: exact
693
- errors, paths, IDs, commands. Never soften them (summaries lose fidelity).
694
- - transcript is OPTIONAL — only include it if the raw log actually exists (online chat
695
- models may not expose one); source.ref (session path or share URL) is the primary
696
- fidelity pointer.
697
- - The server auto-tags digests with "conversation" and protects them from
698
- consolidation. Constituents are regular memories with metadata.conversation_id.
699
- - When the user says "load my context" / "continue from my last conversation" /
700
- "what did we do last session": search q="" tags=["conversation"] first, read the
701
- digest, then pull constituents via query tags or the digest's entity links.
702
- - RESUME FLOW: prefer the digest with status=active (or the most recent). When a
703
- conversation is finished, update its digest metadata.status to "done" (get the
704
- digest first, then update with the full metadata + new status — metadata REPLACES).
705
- When resuming a paused one, set it back to "active".
706
-
707
- TRIGGERS — at the top of a session, in this order and once each: "wake", then the briefing
708
- (steps 0-1 above). NEVER a second time on later messages in that chat. Then every turn,
709
- search when user says: "remember", "recall", "what do we know",
710
- "save this", "do you remember", prefers, decided, uses, chose, convention.
711
- ALSO ingest when user says: "save this conversation", "hand off", "migrate context",
712
- "switch to another AI", "continue this elsewhere".
713
-
714
- FAILURE MODE: if you answer without searching, you are guessing. If you start work without
715
- the briefing, you are guessing about how the user wants you to work — which is how you burn
716
- their bandwidth, their money, or their trust. Wake first, then briefing, then search: the
717
- first two once per session, the last one every turn.`;
589
+ var MEMORY_CONTRACT = `SEPIA MEMORY — MANDATORY. You are connected to Sepia, the user's memory
590
+ server, over MCP at /mcp. It stores a knowledge graph in **namespaces**: entities (people,
591
+ projects, tools, concepts, repos), relations (directed edges) and memories
592
+ (fact | observation | preference | instruction, each with importance 0-1).
593
+
594
+ ONCE PER SESSION, BEFORE ANY WORK
595
+ 1. wake — retry up to 3x a few seconds apart. The host sleeps when idle, so one failure means
596
+ you called during boot, not that memory is down.
597
+ 2. manage_memory action="briefing" — the user's standing rules. No keywords: a rule you have not
598
+ guessed cannot be found by search, which is why this read is unconditional. Treat what it
599
+ returns as binding. Before anything slow, metered, destructive or expensive (install, build,
600
+ deploy, delete, infra change), repeat it with detail="all".
601
+ Neither repeats on later messages in the same chat.
602
+
603
+ SCOPE EVERY CALL TO THE PROJECT
604
+ Namespaces are one per project, named by repo slug (kazoeru, ikoro, tomoshibi). "personal" is the
605
+ cross-project bucket and the only namespace the free plan has.
606
+ 1. manage_namespace action="ensure" name="<repo-slug>" once per session. It is get-or-create, so
607
+ "already exists" is never an error to recover from.
608
+ 2. Pass namespace="<repo-slug>" on EVERY memory, entity, relation, briefing and query call. A write
609
+ with no namespace lands in "personal" — the one mistake that rebuilds the noise scoping exists
610
+ to remove.
611
+ 3. Tag a rule "always" only when it applies in every repo and every session; those load in every
612
+ namespace. Anything project-specific stays in that project.
613
+ 4. plan_limit from ensure or create? Stay in "personal" and carry on. Do not retry, and do not ask
614
+ the user to upgrade mid-task.
615
+
616
+ EVERY TURN — RECALL
617
+ Call search with 2-5 keywords from the request BEFORE you answer. Skip only for trivial chitchat.
618
+ Zero hits, or partial:true, means retry with ONE distinctive word before concluding nothing exists
619
+ — then say so. Never fabricate a memory. Cite what came from memory when it matters.
620
+ identical results for different q values means the filter was NOT applied: check
621
+ filters_applied / ignored_args before blaming ranking.
622
+
623
+ EVERY TURN — PERSIST
624
+ After you answer, store anything durable in the SAME turn: a preference, a decision and its reason,
625
+ a project fact, a person's role, a convention, a stack choice, a correction. A correction or a
626
+ complaint about how you just worked is a rule — instruction for behaviour, preference for a choice,
627
+ importance >= 0.8. Search first, then action=update rather than writing a duplicate. Entity before
628
+ memory, 1-3 entity_ids, then manage_relation to wire the graph. Never store credentials, secrets,
629
+ ephemeral chat or code snippets.
630
+
631
+ "SAVE THIS" MEANS SEPIA
632
+ "save to memory", "remember this", "save this" — write to Sepia in that same turn, never the
633
+ editor's built-in memory. It is the durable source of truth across sessions, editors and AIs.
634
+
635
+ NEVER
636
+ prune_memories is the only destructive tool. Never call it to save anything, and never proactively —
637
+ only when the user explicitly asks to prune. Saving is manage_memory.
638
+
639
+ Full contract, tool reference and the scoping guide: the "sepia" Agent Skill.
640
+ `;
718
641
  var MEMORY_TYPES = [
719
642
  "fact",
720
643
  "observation",
@@ -786,7 +709,8 @@ var MemoryUpdateInput = v.object({
786
709
  metadata: v.optional(metadataSchema),
787
710
  archived: v.optional(v.boolean()),
788
711
  entity_ids: v.optional(v.pipe(v.array(uuidSchema), v.maxLength(MAX_ENTITY_LINKS))),
789
- tags: v.optional(tagsSchema)
712
+ tags: v.optional(tagsSchema),
713
+ namespace: v.optional(v.pipe(v.string(), v.description("Move to this namespace (repo slug). Pass with batch_update to refile many rows at once.")))
790
714
  });
791
715
  var EntityBatchInput = v.object({
792
716
  where: v.pipe(v.object({
@@ -834,7 +758,7 @@ var ConversationInput = v.object({
834
758
  });
835
759
  var SearchInput = v.looseObject({
836
760
  q: v.pipe(v.string(), v.maxLength(200), v.description("Search query (required; empty returns recent items). Multi-word = best-effort: rows matching MORE of your words rank first, so a result set is never emptied by one absent word. Verbatim phrases rank highest. Check `partial` in the result (+ each hit's `matched_terms`) before concluding nothing exists.")),
837
- namespace: v.optional(v.pipe(v.string(), v.description("Restrict to a namespace"))),
761
+ namespace: v.optional(v.pipe(v.string(), v.description("Restrict to a namespace (repo slug). Omit to search every namespace."))),
838
762
  type: v.optional(v.pipe(v.string(), v.maxLength(64), v.description("Memory type (fact/observation/preference/instruction) OR entity type (person/project/tool/concept/repo)"))),
839
763
  tags: v.optional(v.pipe(tagsSchema, v.description("Match memories/entities carrying ALL of these tags"))),
840
764
  limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(SEARCH_LIMIT_MAX), v.description("Max results (default 10, max 25)")), SEARCH_LIMIT_DEFAULT),
@@ -848,13 +772,16 @@ var TraverseInput = v.object({
848
772
  var NamespaceToolInput = v.looseObject({
849
773
  action: v.pipe(v.union([
850
774
  v.literal("create"),
775
+ v.literal("ensure"),
851
776
  v.literal("list"),
852
777
  v.literal("get"),
778
+ v.literal("update"),
853
779
  v.literal("delete")
854
- ]), v.description("create (name, description?) | list | get (id or name) | delete (id or name — cascades all contents)")),
855
- name: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("Namespace name (1-64 chars)"))),
780
+ ]), v.description("create (name, description?) | ensure (name — get-or-create, idempotent; the per-session call) | list (all namespaces + counts + plan) | get (id or name) | update (id or name + name?/description? — rename or describe) | delete (id or name — cascades all contents)")),
781
+ name: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("Namespace name (1-64 chars) — use the repo slug"))),
856
782
  id: v.optional(v.pipe(uuidSchema, v.description("Namespace UUID (or use name)"))),
857
- description: v.optional(v.pipe(v.string(), v.description("Optional description")), "")
783
+ description: v.optional(v.pipe(v.string(), v.description("Optional description")), ""),
784
+ new_name: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("update: rename to this (repo slug)")))
858
785
  });
859
786
  var EntityToolInput = v.looseObject({
860
787
  action: v.pipe(v.union([
@@ -906,7 +833,7 @@ var MemoryToolInput = v.looseObject({
906
833
  v.literal("briefing"),
907
834
  v.literal("batch_update"),
908
835
  v.literal("ingest")
909
- ]), v.description("briefing (call ONCE at the start of a session — takes no other args) | create (memory) | get (id) | update (id + update) | delete (id) | query (filters: type|namespace|importance_min|archived|tags|q|offset|limit — `q` is a keyword filter; for ranked search use the `search` tool) | batch_update (where + update — updates ALL matching, returns count) | ingest (conversation — handoff digest)")),
836
+ ]), v.description("briefing (call ONCE at the start of a session; optional `namespace` scopes the TAIL — core rules tagged `always` load from every namespace) | create (memory) | get (id) | update (id + update) | delete (id) | query (filters: type|namespace|importance_min|archived|tags|q|offset|limit — `q` is a keyword filter; for ranked search use the `search` tool) | batch_update (where + update — updates ALL matching, returns count) | ingest (conversation — handoff digest)")),
910
837
  id: v.optional(v.pipe(uuidSchema, v.description("Memory UUID"))),
911
838
  memory: v.optional(v.pipe(MemoryInput, v.description("Memory to create: {content, type? fact|observation|preference|instruction, importance? 0-1, namespace?, entity_ids? [0-3], metadata?, tags?} — source auto-set to client name"))),
912
839
  update: v.optional(v.pipe(MemoryUpdateInput, v.description("Any subset of content/type/importance/metadata/archived/tags — entity_ids REPLACES the link set, tags REPLACES the tag set"))),
@@ -3810,6 +3737,14 @@ var telemetryEvents = pgTable("telemetry_events", {
3810
3737
  name: "telemetry_events_owner_id_fkey"
3811
3738
  }).onDelete("cascade")
3812
3739
  ]);
3740
+ // ../shared/src/db/errors.ts
3741
+ var PRE_SEND_NETWORK_CODES = new Set([
3742
+ "EAI_AGAIN",
3743
+ "EAI_NODATA",
3744
+ "ENOTFOUND",
3745
+ "ECONNREFUSED",
3746
+ "UND_ERR_CONNECT_TIMEOUT"
3747
+ ]);
3813
3748
  // ../../node_modules/.bun/@neondatabase+serverless@1.1.0/node_modules/@neondatabase/serverless/index.mjs
3814
3749
  var So = Object.create;
3815
3750
  var Ie = Object.defineProperty;
@@ -8713,6 +8648,9 @@ buffer/index.js:
8713
8648
  * @license MIT
8714
8649
  *)
8715
8650
  */
8651
+
8652
+ // ../shared/src/db/retry.ts
8653
+ var RETRY_MARKER = Symbol.for("sepia.db.retryingFetch");
8716
8654
  // ../shared/src/db/lib/list-columns.ts
8717
8655
  var ENTITY_LIST_COLUMNS = {
8718
8656
  id: entities.id,
@@ -8805,6 +8743,12 @@ class SepiaClient {
8805
8743
  getNamespace(idOrName) {
8806
8744
  return this.request("GET", `/api/namespaces/${encodeURIComponent(idOrName)}`);
8807
8745
  }
8746
+ ensureNamespace(name, description) {
8747
+ return this.request("POST", "/api/namespaces", { name, description, ensure: true });
8748
+ }
8749
+ updateNamespace(idOrName, changes) {
8750
+ return this.request("PATCH", `/api/namespaces/${encodeURIComponent(idOrName)}`, changes);
8751
+ }
8808
8752
  deleteNamespace(idOrName) {
8809
8753
  return this.request("DELETE", `/api/namespaces/${encodeURIComponent(idOrName)}`);
8810
8754
  }
@@ -8994,7 +8938,7 @@ function registerNamespaceTools(server, client) {
8994
8938
  server.tool({
8995
8939
  name: "manage_namespace",
8996
8940
  title: "Manage Namespaces",
8997
- description: "Create, list, get, or delete namespaces — isolated memory containers.",
8941
+ description: "Create, list, get, update or delete namespaces — one per project, named by repo slug. Use action=ensure once per session to scope yourself, then pass that name on every read and write.",
8998
8942
  icons: [SEPIA_ICON],
8999
8943
  schema: NamespaceToolInput
9000
8944
  }, safe(NamespaceToolInput, async (args) => {
@@ -9007,6 +8951,12 @@ function registerNamespaceTools(server, client) {
9007
8951
  namespace: await client.createNamespace(args.name, args.description)
9008
8952
  };
9009
8953
  }
8954
+ case "ensure": {
8955
+ if (!args.name)
8956
+ throw new Error("action=ensure requires name");
8957
+ const res = await client.ensureNamespace(args.name, args.description);
8958
+ return { action: "ensure", ...res };
8959
+ }
9010
8960
  case "list":
9011
8961
  return {
9012
8962
  action: "list",
@@ -9021,6 +8971,20 @@ function registerNamespaceTools(server, client) {
9021
8971
  namespace: await client.getNamespace(idOrName)
9022
8972
  };
9023
8973
  }
8974
+ case "update": {
8975
+ const idOrName = args.id ?? args.name;
8976
+ if (!idOrName)
8977
+ throw new Error("action=update requires id or name");
8978
+ if (args.new_name === undefined && !args.description)
8979
+ throw new Error("action=update requires new_name or description");
8980
+ return {
8981
+ action: "update",
8982
+ namespace: await client.updateNamespace(idOrName, {
8983
+ name: args.new_name,
8984
+ description: args.description
8985
+ })
8986
+ };
8987
+ }
9024
8988
  case "delete": {
9025
8989
  const idOrName = args.id ?? args.name;
9026
8990
  if (!idOrName)
@@ -9306,7 +9270,7 @@ function registerPruneMemoriesTools(server, client) {
9306
9270
  // package.json
9307
9271
  var package_default = {
9308
9272
  name: "sepia-mcp",
9309
- version: "0.10.6",
9273
+ version: "0.10.8",
9310
9274
  description: "Self-contained MCP server for Sepia — a personal knowledge-graph memory server. Talks to the Sepia REST API (SEPIA_URL + SEPIA_API_KEY); stdio or HTTP transport.",
9311
9275
  type: "module",
9312
9276
  repository: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sepia-mcp",
3
- "version": "0.10.6",
3
+ "version": "0.10.8",
4
4
  "description": "Self-contained MCP server for Sepia — a personal knowledge-graph memory server. Talks to the Sepia REST API (SEPIA_URL + SEPIA_API_KEY); stdio or HTTP transport.",
5
5
  "type": "module",
6
6
  "repository": {