sepia-mcp 0.10.7 → 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.
- package/dist/index.js +90 -137
- 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
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
"
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
0.
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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 —
|
|
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"))),
|
|
@@ -8816,6 +8743,12 @@ class SepiaClient {
|
|
|
8816
8743
|
getNamespace(idOrName) {
|
|
8817
8744
|
return this.request("GET", `/api/namespaces/${encodeURIComponent(idOrName)}`);
|
|
8818
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
|
+
}
|
|
8819
8752
|
deleteNamespace(idOrName) {
|
|
8820
8753
|
return this.request("DELETE", `/api/namespaces/${encodeURIComponent(idOrName)}`);
|
|
8821
8754
|
}
|
|
@@ -9005,7 +8938,7 @@ function registerNamespaceTools(server, client) {
|
|
|
9005
8938
|
server.tool({
|
|
9006
8939
|
name: "manage_namespace",
|
|
9007
8940
|
title: "Manage Namespaces",
|
|
9008
|
-
description: "Create, list, get, or delete namespaces —
|
|
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.",
|
|
9009
8942
|
icons: [SEPIA_ICON],
|
|
9010
8943
|
schema: NamespaceToolInput
|
|
9011
8944
|
}, safe(NamespaceToolInput, async (args) => {
|
|
@@ -9018,6 +8951,12 @@ function registerNamespaceTools(server, client) {
|
|
|
9018
8951
|
namespace: await client.createNamespace(args.name, args.description)
|
|
9019
8952
|
};
|
|
9020
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
|
+
}
|
|
9021
8960
|
case "list":
|
|
9022
8961
|
return {
|
|
9023
8962
|
action: "list",
|
|
@@ -9032,6 +8971,20 @@ function registerNamespaceTools(server, client) {
|
|
|
9032
8971
|
namespace: await client.getNamespace(idOrName)
|
|
9033
8972
|
};
|
|
9034
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
|
+
}
|
|
9035
8988
|
case "delete": {
|
|
9036
8989
|
const idOrName = args.id ?? args.name;
|
|
9037
8990
|
if (!idOrName)
|
|
@@ -9317,7 +9270,7 @@ function registerPruneMemoriesTools(server, client) {
|
|
|
9317
9270
|
// package.json
|
|
9318
9271
|
var package_default = {
|
|
9319
9272
|
name: "sepia-mcp",
|
|
9320
|
-
version: "0.10.
|
|
9273
|
+
version: "0.10.8",
|
|
9321
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.",
|
|
9322
9275
|
type: "module",
|
|
9323
9276
|
repository: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sepia-mcp",
|
|
3
|
-
"version": "0.10.
|
|
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": {
|