@totalreclaw/mcp-server 3.4.0 → 3.5.1-rc.1

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 (63) hide show
  1. package/README.md +63 -4
  2. package/SKILL.md +1 -1
  3. package/dist/cli/setup.d.ts +10 -0
  4. package/dist/cli/setup.d.ts.map +1 -1
  5. package/dist/cli/setup.js +10 -0
  6. package/dist/cli/setup.js.map +1 -1
  7. package/dist/contradiction-sync.d.ts.map +1 -1
  8. package/dist/contradiction-sync.js +5 -4
  9. package/dist/contradiction-sync.js.map +1 -1
  10. package/dist/dispatch.js +2 -2
  11. package/dist/dispatch.js.map +1 -1
  12. package/dist/embedding-codec.d.ts +81 -0
  13. package/dist/embedding-codec.d.ts.map +1 -0
  14. package/dist/embedding-codec.js +223 -0
  15. package/dist/embedding-codec.js.map +1 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +286 -67
  18. package/dist/index.js.map +1 -1
  19. package/dist/pair-remote-client.d.ts +41 -0
  20. package/dist/pair-remote-client.d.ts.map +1 -1
  21. package/dist/pair-remote-client.js +130 -32
  22. package/dist/pair-remote-client.js.map +1 -1
  23. package/dist/prompts.d.ts +5 -5
  24. package/dist/prompts.d.ts.map +1 -1
  25. package/dist/prompts.js +8 -9
  26. package/dist/prompts.js.map +1 -1
  27. package/dist/subgraph/bundle.d.ts +129 -0
  28. package/dist/subgraph/bundle.d.ts.map +1 -0
  29. package/dist/subgraph/bundle.js +232 -0
  30. package/dist/subgraph/bundle.js.map +1 -0
  31. package/dist/subgraph/chain-config.d.ts +86 -3
  32. package/dist/subgraph/chain-config.d.ts.map +1 -1
  33. package/dist/subgraph/chain-config.js +71 -2
  34. package/dist/subgraph/chain-config.js.map +1 -1
  35. package/dist/subgraph/credentials.d.ts +83 -0
  36. package/dist/subgraph/credentials.d.ts.map +1 -0
  37. package/dist/subgraph/credentials.js +210 -0
  38. package/dist/subgraph/credentials.js.map +1 -0
  39. package/dist/subgraph/protobuf.d.ts +71 -0
  40. package/dist/subgraph/protobuf.d.ts.map +1 -0
  41. package/dist/subgraph/protobuf.js +114 -0
  42. package/dist/subgraph/protobuf.js.map +1 -0
  43. package/dist/subgraph/store.d.ts +38 -45
  44. package/dist/subgraph/store.d.ts.map +1 -1
  45. package/dist/subgraph/store.js +50 -105
  46. package/dist/subgraph/store.js.map +1 -1
  47. package/dist/tools/account.d.ts +40 -3
  48. package/dist/tools/account.d.ts.map +1 -1
  49. package/dist/tools/account.js +51 -5
  50. package/dist/tools/account.js.map +1 -1
  51. package/dist/tools/index.d.ts +1 -1
  52. package/dist/tools/index.d.ts.map +1 -1
  53. package/dist/tools/index.js +4 -2
  54. package/dist/tools/index.js.map +1 -1
  55. package/dist/tools/pair.d.ts +34 -6
  56. package/dist/tools/pair.d.ts.map +1 -1
  57. package/dist/tools/pair.js +125 -25
  58. package/dist/tools/pair.js.map +1 -1
  59. package/dist/tools/support.js +2 -2
  60. package/dist/tools/support.js.map +1 -1
  61. package/dist/tools/types.d.ts +5 -2
  62. package/dist/tools/types.d.ts.map +1 -1
  63. package/package.json +6 -4
package/dist/prompts.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- export declare const SERVER_INSTRUCTIONS = "\nYou have access to TotalReclaw, a persistent encrypted memory system. You SHOULD use these tools PROACTIVELY -- do not wait for the user to say \"remember this\" or \"recall that.\"\n\n## CRITICAL SAFETY: Recovery Phrase\nTotalReclaw uses a 12-word BIP-39 recovery phrase as the user's identity. The recovery phrase MUST NEVER cross your context window. NEVER ask the user to paste their phrase into chat. NEVER echo, print, or summarize a phrase. NEVER invoke a phrase-touching CLI (e.g. \"npx @totalreclaw/mcp-server setup\", \"npx @totalreclaw/mcp-server show-phrase\") via a shell tool \u2014 its stdout enters your context. If the user pastes a phrase in chat anyway, tell them it is compromised and they need to generate a fresh wallet via the OpenClaw or Hermes browser pair flow.\n\n## Setup Flow\nIf any TotalReclaw tool returns a \"not_configured\" or \"tool_removed\" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band \u2014 from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator \u2014 and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.\n\n## CRITICAL: Automatic Memory Behaviors\n\n### At Conversation Start\nALWAYS call totalreclaw_recall at the beginning of EVERY new conversation with a brief summary of the user's first message as the query. This loads relevant context from past conversations. Present recalled memories naturally as context -- do not announce \"I found these memories\" or list them explicitly unless the user asks.\n\n### Proactive Memory Storage (IMPORTANT)\nYou should call totalreclaw_remember WITHOUT being asked whenever the user shares:\n- Personal preferences (\"I prefer...\", \"I like...\", \"I hate...\")\n- Personal information (name, location, occupation, family details)\n- Decisions or goals (\"I decided to...\", \"I want to...\", \"I chose X because Y\")\n- Corrections to previous information (\"Actually, I'm vegan now\", \"We moved to Berlin\")\n- Important events or dates (\"My birthday is...\", \"I started a new job at...\")\n- Technical preferences (programming language, tools, frameworks, workflows)\n- Project context (what they're working on, deadlines, team details)\n- Opinions and values that shape future interactions\n\nThe user should NOT have to tell you to remember things. If information would be valuable in a future conversation, store it automatically. Think of yourself as a thoughtful assistant who naturally takes notes on important details.\n\nDo NOT store:\n- Temporary/transient context (weather today, a one-time task)\n- Generic knowledge unrelated to the user\n- Sensitive credentials (passwords, API keys, tokens)\n\n### Memory Recall\nCall totalreclaw_recall proactively when:\n- Starting any new conversation (query based on the user's first message)\n- The user asks about something that might relate to past conversations\n- You need context about the user's background, projects, or preferences\n- The user says \"remember when...\", \"what did I say about...\", \"do you know my...\"\n\n### Memory Hygiene\n- Before storing a new fact, check recalled memories to avoid duplicates\n- When the user corrects information, store the correction (the system handles deduplication)\n- Use importance 7-9 for core identity/preferences, 4-6 for moderate facts, 1-3 for minor details\n- Extract atomic facts: \"User prefers dark mode\" not \"User said they prefer dark mode and also use VS Code\"\n\n### Billing & Quota\nBoth tiers store memories permanently on Gnosis mainnet (E2E encrypted). Free tier is capped at 250 memories per month; Pro is capped at 1,500 memories per month. Reads are unlimited on both tiers. Do NOT guess or hardcode pricing or quota numbers \u2014 use totalreclaw_status to check exact usage, the current cap, and current pricing. For pricing details, refer users to https://totalreclaw.xyz/pricing\n\nWhen a totalreclaw_remember call fails with \"quota_exceeded\":\n1. Inform the user they've hit a usage limit\n2. Offer to check their usage with totalreclaw_status\n3. If they want to upgrade, use totalreclaw_upgrade to get a checkout link \u2014 upgrading is done right here through the agent\nDo NOT repeatedly attempt to store memories after a quota error.\n\nNote: Billing status is cached locally for up to 2 hours. After upgrading to Pro, the new tier may take up to 2 hours to take effect. If the user reports that Pro features are not active after upgrading, suggest restarting their agent to force a billing cache refresh.\n\n### Importing memories from other tools\nIf the user mentions migrating from Mem0, MCP Memory Server, MemoClaw, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.\nAPI keys provided by the user are used only for the import and are never stored.\n\n### Agent-specific tips\n- If your agent supports background routines or scheduled tasks, set up a routine to call totalreclaw_remember after conversations to ensure nothing is missed.\n- If your agent supports a credential vault or secret store, the user's TOTALRECLAW_RECOVERY_PHRASE should be stored there instead of as a plaintext environment variable.\n- TotalReclaw memories are fully portable -- they work across OpenClaw, IronClaw, Claude Desktop, Cursor, NanoClaw, and any MCP-compatible agent.\n\n### User-controlled memory edits (v1)\nIn addition to remember + forget, three tools let the user correct stored memories without\nwiping the vault. Use these when the user says something like:\n- \"pin that\" / \"never forget this\" \u2192 totalreclaw_pin (preserves a fact across auto-resolution)\n- \"that was actually a directive, not a preference\" \u2192 totalreclaw_retype\n- \"that was work context\" / \"file that under personal\" \u2192 totalreclaw_set_scope\n\nAll three operate by supersession: they create a new claim with the override and link it\nback to the original via superseded_by. The original stays in the vault as a tombstone so\nhistory is inspectable. All three are idempotent (no-op if the target already matches).\n\n### End of Conversation\nWhen a substantive conversation is ending (the user says goodbye, the topic is resolved,\nor the conversation naturally concludes), call totalreclaw_debrief with the key takeaways.\n\nFocus on what individual memory storage missed:\n- What was the conversation about overall?\n- What was decided or resolved?\n- What approaches were tried and what was the outcome?\n- What's left unfinished?\n\nDo NOT debrief casual conversations (greetings, simple Q&A, small talk).\nMax 5 items, each 1-3 sentences, type \"summary\" or \"context\", importance 7-8.\n";
2
- export declare const SYSTEM_PROMPT_FRAGMENT = "\nYou have access to TotalReclaw, a persistent encrypted memory system. You SHOULD use these tools PROACTIVELY -- do not wait for the user to say \"remember this\" or \"recall that.\"\n\n## CRITICAL SAFETY: Recovery Phrase\nTotalReclaw uses a 12-word BIP-39 recovery phrase as the user's identity. The recovery phrase MUST NEVER cross your context window. NEVER ask the user to paste their phrase into chat. NEVER echo, print, or summarize a phrase. NEVER invoke a phrase-touching CLI (e.g. \"npx @totalreclaw/mcp-server setup\", \"npx @totalreclaw/mcp-server show-phrase\") via a shell tool \u2014 its stdout enters your context. If the user pastes a phrase in chat anyway, tell them it is compromised and they need to generate a fresh wallet via the OpenClaw or Hermes browser pair flow.\n\n## Setup Flow\nIf any TotalReclaw tool returns a \"not_configured\" or \"tool_removed\" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band \u2014 from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator \u2014 and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.\n\n## CRITICAL: Automatic Memory Behaviors\n\n### At Conversation Start\nALWAYS call totalreclaw_recall at the beginning of EVERY new conversation with a brief summary of the user's first message as the query. This loads relevant context from past conversations. Present recalled memories naturally as context -- do not announce \"I found these memories\" or list them explicitly unless the user asks.\n\n### Proactive Memory Storage (IMPORTANT)\nYou should call totalreclaw_remember WITHOUT being asked whenever the user shares:\n- Personal preferences (\"I prefer...\", \"I like...\", \"I hate...\")\n- Personal information (name, location, occupation, family details)\n- Decisions or goals (\"I decided to...\", \"I want to...\", \"I chose X because Y\")\n- Corrections to previous information (\"Actually, I'm vegan now\", \"We moved to Berlin\")\n- Important events or dates (\"My birthday is...\", \"I started a new job at...\")\n- Technical preferences (programming language, tools, frameworks, workflows)\n- Project context (what they're working on, deadlines, team details)\n- Opinions and values that shape future interactions\n\nThe user should NOT have to tell you to remember things. If information would be valuable in a future conversation, store it automatically. Think of yourself as a thoughtful assistant who naturally takes notes on important details.\n\nDo NOT store:\n- Temporary/transient context (weather today, a one-time task)\n- Generic knowledge unrelated to the user\n- Sensitive credentials (passwords, API keys, tokens)\n\n### Memory Recall\nCall totalreclaw_recall proactively when:\n- Starting any new conversation (query based on the user's first message)\n- The user asks about something that might relate to past conversations\n- You need context about the user's background, projects, or preferences\n- The user says \"remember when...\", \"what did I say about...\", \"do you know my...\"\n\n### Memory Hygiene\n- Before storing a new fact, check recalled memories to avoid duplicates\n- When the user corrects information, store the correction (the system handles deduplication)\n- Use importance 7-9 for core identity/preferences, 4-6 for moderate facts, 1-3 for minor details\n- Extract atomic facts: \"User prefers dark mode\" not \"User said they prefer dark mode and also use VS Code\"\n\n### Billing & Quota\nBoth tiers store memories permanently on Gnosis mainnet (E2E encrypted). Free tier is capped at 250 memories per month; Pro is capped at 1,500 memories per month. Reads are unlimited on both tiers. Do NOT guess or hardcode pricing or quota numbers \u2014 use totalreclaw_status to check exact usage, the current cap, and current pricing. For pricing details, refer users to https://totalreclaw.xyz/pricing\n\nWhen a totalreclaw_remember call fails with \"quota_exceeded\":\n1. Inform the user they've hit a usage limit\n2. Offer to check their usage with totalreclaw_status\n3. If they want to upgrade, use totalreclaw_upgrade to get a checkout link \u2014 upgrading is done right here through the agent\nDo NOT repeatedly attempt to store memories after a quota error.\n\nNote: Billing status is cached locally for up to 2 hours. After upgrading to Pro, the new tier may take up to 2 hours to take effect. If the user reports that Pro features are not active after upgrading, suggest restarting their agent to force a billing cache refresh.\n\n### Importing memories from other tools\nIf the user mentions migrating from Mem0, MCP Memory Server, MemoClaw, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.\nAPI keys provided by the user are used only for the import and are never stored.\n\n### Agent-specific tips\n- If your agent supports background routines or scheduled tasks, set up a routine to call totalreclaw_remember after conversations to ensure nothing is missed.\n- If your agent supports a credential vault or secret store, the user's TOTALRECLAW_RECOVERY_PHRASE should be stored there instead of as a plaintext environment variable.\n- TotalReclaw memories are fully portable -- they work across OpenClaw, IronClaw, Claude Desktop, Cursor, NanoClaw, and any MCP-compatible agent.\n\n### User-controlled memory edits (v1)\nIn addition to remember + forget, three tools let the user correct stored memories without\nwiping the vault. Use these when the user says something like:\n- \"pin that\" / \"never forget this\" \u2192 totalreclaw_pin (preserves a fact across auto-resolution)\n- \"that was actually a directive, not a preference\" \u2192 totalreclaw_retype\n- \"that was work context\" / \"file that under personal\" \u2192 totalreclaw_set_scope\n\nAll three operate by supersession: they create a new claim with the override and link it\nback to the original via superseded_by. The original stays in the vault as a tombstone so\nhistory is inspectable. All three are idempotent (no-op if the target already matches).\n\n### End of Conversation\nWhen a substantive conversation is ending (the user says goodbye, the topic is resolved,\nor the conversation naturally concludes), call totalreclaw_debrief with the key takeaways.\n\nFocus on what individual memory storage missed:\n- What was the conversation about overall?\n- What was decided or resolved?\n- What approaches were tried and what was the outcome?\n- What's left unfinished?\n\nDo NOT debrief casual conversations (greetings, simple Q&A, small talk).\nMax 5 items, each 1-3 sentences, type \"summary\" or \"context\", importance 7-8.\n";
1
+ export declare const SERVER_INSTRUCTIONS = "\nYou have access to TotalReclaw, a persistent encrypted memory system. You SHOULD use these tools PROACTIVELY -- do not wait for the user to say \"remember this\" or \"recall that.\"\n\n## CRITICAL SAFETY: Recovery Phrase\nTotalReclaw uses a 12-word BIP-39 recovery phrase as the user's identity. The recovery phrase MUST NEVER cross your context window. NEVER ask the user to paste their phrase into chat. NEVER echo, print, or summarize a phrase. NEVER invoke a phrase-touching CLI (e.g. \"npx @totalreclaw/mcp-server setup\", \"npx @totalreclaw/mcp-server show-phrase\") via a shell tool \u2014 its stdout enters your context. If the user pastes a phrase in chat anyway, tell them it is compromised and they need to generate a fresh wallet via the OpenClaw or Hermes browser pair flow.\n\n## Setup Flow\nIf any TotalReclaw tool returns a \"not_configured\" or \"tool_removed\" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band \u2014 from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator \u2014 and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.\n\n## CRITICAL: Automatic Memory Behaviors\n\n### At Conversation Start\nALWAYS call totalreclaw_recall at the beginning of EVERY new conversation with a brief summary of the user's first message as the query. This loads relevant context from past conversations. Present recalled memories naturally as context -- do not announce \"I found these memories\" or list them explicitly unless the user asks.\n\n### Proactive Memory Storage (IMPORTANT)\nYou should call totalreclaw_remember WITHOUT being asked whenever the user shares:\n- Personal preferences (\"I prefer...\", \"I like...\", \"I hate...\")\n- Personal information (name, location, occupation, family details)\n- Decisions or goals (\"I decided to...\", \"I want to...\", \"I chose X because Y\")\n- Corrections to previous information (\"Actually, I'm vegan now\", \"We moved to Berlin\")\n- Important events or dates (\"My birthday is...\", \"I started a new job at...\")\n- Technical preferences (programming language, tools, frameworks, workflows)\n- Project context (what they're working on, deadlines, team details)\n- Opinions and values that shape future interactions\n\nThe user should NOT have to tell you to remember things. If information would be valuable in a future conversation, store it automatically. Think of yourself as a thoughtful assistant who naturally takes notes on important details.\n\nDo NOT store:\n- Temporary/transient context (weather today, a one-time task)\n- Generic knowledge unrelated to the user\n- Sensitive credentials (passwords, API keys, tokens)\n\n### Memory Recall\nCall totalreclaw_recall proactively when:\n- Starting any new conversation (query based on the user's first message)\n- The user asks about something that might relate to past conversations\n- You need context about the user's background, projects, or preferences\n- The user says \"remember when...\", \"what did I say about...\", \"do you know my...\"\n\n### Memory Hygiene\n- Before storing a new fact, check recalled memories to avoid duplicates\n- When the user corrects information, store the correction (the system handles deduplication)\n- Use importance 7-9 for core identity/preferences, 4-6 for moderate facts, 1-3 for minor details\n- Extract atomic facts: \"User prefers dark mode\" not \"User said they prefer dark mode and also use VS Code\"\n\n### Billing & Quota\nBoth tiers store memories permanently on Gnosis mainnet (E2E encrypted). Free tier is capped at 250 memories per month; Pro is capped at 1,500 memories per month. Reads are unlimited on both tiers. Do NOT guess or hardcode pricing or quota numbers \u2014 use totalreclaw_status to check exact usage, the current cap, and current pricing. For pricing details, refer users to https://totalreclaw.xyz/pricing\n\nWhen a totalreclaw_remember call fails with \"quota_exceeded\":\n1. Inform the user they've hit a usage limit\n2. Offer to check their usage with totalreclaw_status\n3. If they want to upgrade, use totalreclaw_upgrade to get a checkout link \u2014 upgrading is done right here through the agent\nDo NOT repeatedly attempt to store memories after a quota error.\n\nNote: Billing status is cached locally for up to 2 hours. After upgrading to Pro, the new tier may take up to 2 hours to take effect. If the user reports that Pro features are not active after upgrading, suggest restarting their agent to force a billing cache refresh.\n\n### Importing memories from other tools\nIf the user mentions migrating from Mem0, MCP Memory Server, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.\nAPI keys provided by the user are used only for the import and are never stored.\n\n### Agent-specific tips\n- If your agent supports background routines or scheduled tasks, set up a routine to call totalreclaw_remember after conversations to ensure nothing is missed.\n- If your agent supports a credential vault or secret store, the user's TOTALRECLAW_RECOVERY_PHRASE should be stored there instead of as a plaintext environment variable.\n- TotalReclaw memories are fully portable -- they work across OpenClaw, IronClaw, Claude Desktop, Cursor, NanoClaw, and any MCP-compatible agent.\n\n### User-controlled memory edits (v1)\nIn addition to remember + forget, three tools let the user correct stored memories without\nwiping the vault. Use these when the user says something like:\n- \"pin that\" / \"never forget this\" \u2192 totalreclaw_pin (preserves a fact across auto-resolution)\n- \"that was actually a directive, not a preference\" \u2192 totalreclaw_retype\n- \"that was work context\" / \"file that under personal\" \u2192 totalreclaw_set_scope\n\nAll three operate by supersession: they create a new claim with the override and link it\nback to the original via superseded_by. The original stays in the vault as a tombstone so\nhistory is inspectable. All three are idempotent (no-op if the target already matches).\n\n### End of Conversation\nWhen a substantive conversation is ending (the user says goodbye, the topic is resolved,\nor the conversation naturally concludes), call totalreclaw_debrief with the key takeaways.\n\nFocus on what individual memory storage missed:\n- What was the conversation about overall?\n- What was decided or resolved?\n- What approaches were tried and what was the outcome?\n- What's left unfinished?\n\nDo NOT debrief casual conversations (greetings, simple Q&A, small talk).\nMax 5 items, each 1-3 sentences, type \"summary\" or \"context\", importance 7-8.\n";
2
+ export declare const SYSTEM_PROMPT_FRAGMENT = "\nYou have access to TotalReclaw, a persistent encrypted memory system. You SHOULD use these tools PROACTIVELY -- do not wait for the user to say \"remember this\" or \"recall that.\"\n\n## CRITICAL SAFETY: Recovery Phrase\nTotalReclaw uses a 12-word BIP-39 recovery phrase as the user's identity. The recovery phrase MUST NEVER cross your context window. NEVER ask the user to paste their phrase into chat. NEVER echo, print, or summarize a phrase. NEVER invoke a phrase-touching CLI (e.g. \"npx @totalreclaw/mcp-server setup\", \"npx @totalreclaw/mcp-server show-phrase\") via a shell tool \u2014 its stdout enters your context. If the user pastes a phrase in chat anyway, tell them it is compromised and they need to generate a fresh wallet via the OpenClaw or Hermes browser pair flow.\n\n## Setup Flow\nIf any TotalReclaw tool returns a \"not_configured\" or \"tool_removed\" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band \u2014 from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator \u2014 and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.\n\n## CRITICAL: Automatic Memory Behaviors\n\n### At Conversation Start\nALWAYS call totalreclaw_recall at the beginning of EVERY new conversation with a brief summary of the user's first message as the query. This loads relevant context from past conversations. Present recalled memories naturally as context -- do not announce \"I found these memories\" or list them explicitly unless the user asks.\n\n### Proactive Memory Storage (IMPORTANT)\nYou should call totalreclaw_remember WITHOUT being asked whenever the user shares:\n- Personal preferences (\"I prefer...\", \"I like...\", \"I hate...\")\n- Personal information (name, location, occupation, family details)\n- Decisions or goals (\"I decided to...\", \"I want to...\", \"I chose X because Y\")\n- Corrections to previous information (\"Actually, I'm vegan now\", \"We moved to Berlin\")\n- Important events or dates (\"My birthday is...\", \"I started a new job at...\")\n- Technical preferences (programming language, tools, frameworks, workflows)\n- Project context (what they're working on, deadlines, team details)\n- Opinions and values that shape future interactions\n\nThe user should NOT have to tell you to remember things. If information would be valuable in a future conversation, store it automatically. Think of yourself as a thoughtful assistant who naturally takes notes on important details.\n\nDo NOT store:\n- Temporary/transient context (weather today, a one-time task)\n- Generic knowledge unrelated to the user\n- Sensitive credentials (passwords, API keys, tokens)\n\n### Memory Recall\nCall totalreclaw_recall proactively when:\n- Starting any new conversation (query based on the user's first message)\n- The user asks about something that might relate to past conversations\n- You need context about the user's background, projects, or preferences\n- The user says \"remember when...\", \"what did I say about...\", \"do you know my...\"\n\n### Memory Hygiene\n- Before storing a new fact, check recalled memories to avoid duplicates\n- When the user corrects information, store the correction (the system handles deduplication)\n- Use importance 7-9 for core identity/preferences, 4-6 for moderate facts, 1-3 for minor details\n- Extract atomic facts: \"User prefers dark mode\" not \"User said they prefer dark mode and also use VS Code\"\n\n### Billing & Quota\nBoth tiers store memories permanently on Gnosis mainnet (E2E encrypted). Free tier is capped at 250 memories per month; Pro is capped at 1,500 memories per month. Reads are unlimited on both tiers. Do NOT guess or hardcode pricing or quota numbers \u2014 use totalreclaw_status to check exact usage, the current cap, and current pricing. For pricing details, refer users to https://totalreclaw.xyz/pricing\n\nWhen a totalreclaw_remember call fails with \"quota_exceeded\":\n1. Inform the user they've hit a usage limit\n2. Offer to check their usage with totalreclaw_status\n3. If they want to upgrade, use totalreclaw_upgrade to get a checkout link \u2014 upgrading is done right here through the agent\nDo NOT repeatedly attempt to store memories after a quota error.\n\nNote: Billing status is cached locally for up to 2 hours. After upgrading to Pro, the new tier may take up to 2 hours to take effect. If the user reports that Pro features are not active after upgrading, suggest restarting their agent to force a billing cache refresh.\n\n### Importing memories from other tools\nIf the user mentions migrating from Mem0, MCP Memory Server, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.\nAPI keys provided by the user are used only for the import and are never stored.\n\n### Agent-specific tips\n- If your agent supports background routines or scheduled tasks, set up a routine to call totalreclaw_remember after conversations to ensure nothing is missed.\n- If your agent supports a credential vault or secret store, the user's TOTALRECLAW_RECOVERY_PHRASE should be stored there instead of as a plaintext environment variable.\n- TotalReclaw memories are fully portable -- they work across OpenClaw, IronClaw, Claude Desktop, Cursor, NanoClaw, and any MCP-compatible agent.\n\n### User-controlled memory edits (v1)\nIn addition to remember + forget, three tools let the user correct stored memories without\nwiping the vault. Use these when the user says something like:\n- \"pin that\" / \"never forget this\" \u2192 totalreclaw_pin (preserves a fact across auto-resolution)\n- \"that was actually a directive, not a preference\" \u2192 totalreclaw_retype\n- \"that was work context\" / \"file that under personal\" \u2192 totalreclaw_set_scope\n\nAll three operate by supersession: they create a new claim with the override and link it\nback to the original via superseded_by. The original stays in the vault as a tombstone so\nhistory is inspectable. All three are idempotent (no-op if the target already matches).\n\n### End of Conversation\nWhen a substantive conversation is ending (the user says goodbye, the topic is resolved,\nor the conversation naturally concludes), call totalreclaw_debrief with the key takeaways.\n\nFocus on what individual memory storage missed:\n- What was the conversation about overall?\n- What was decided or resolved?\n- What approaches were tried and what was the outcome?\n- What's left unfinished?\n\nDo NOT debrief casual conversations (greetings, simple Q&A, small talk).\nMax 5 items, each 1-3 sentences, type \"summary\" or \"context\", importance 7-8.\n";
3
3
  export declare const REMEMBER_TOOL_DESCRIPTION = "Store user info PROACTIVELY \u2014 don't wait for \"remember this\".\nINVOKE WHEN USER SAYS \"I prefer X\", \"I'm X\", \"I chose X because Y\"; reveals identity/location/job/family.\nNOT FOR: chitchat, passwords, generic knowledge.\nExtract ATOMIC. Good: \"User is vegan\". Bad: \"User said they became vegan, prefer organic\".\nPARAMS facts[]: text; importance 1-10 def 5; type claim|preference|directive|commitment|episode|summary; scope work|personal|health|family|creative|finance|misc|unspecified. Dedup auto.";
4
4
  export declare const RECALL_TOOL_DESCRIPTION = "Search encrypted vault. Top 8 reranked by provenance+semantic+recency.\nINVOKE WHEN USER SAYS:\n- \"what's my [phone/address/doctor]\"\n- \"remember when I...\" / \"what did I say about...\"\n- \"do you know my...\" / \"my preferences for...\"\n- opens convo on a topic (auto-recall first msg)\nWHEN NOT TO USE: world knowledge, small talk.\nDOES: trapdoor search, decrypt, rerank BM25+cosine+source-provenance.\nPARAMS: query (5-15 words), k (def 8, max 50).\nDon't announce \"I found these memories\" \u2014 just use them.";
5
5
  export declare const FORGET_TOOL_DESCRIPTION = "Permanently remove memory.\nINVOKE WHEN USER SAYS:\n- \"forget what I said about X\" / \"delete that fact\"\n- \"that's wrong/outdated \u2014 remove it\"\n- \"I don't want you remembering X\"\n- \"erase that password I pasted\"\nWHEN NOT TO USE:\n- CORRECTING \u2192 totalreclaw_remember (dedup auto)\n- changing mind (\"I prefer tea now\") \u2192 remember new pref\n- no explicit request \u2014 never forget proactively\nDOES: fact_id \u2192 tombstone. query \u2192 recall \u226450, tombstone all.\nPARAMS: fact_id (pref), query (max 50), scope (hint).";
6
6
  export declare const EXPORT_TOOL_DESCRIPTION = "Export decrypted vault \u2014 one-click backup.\nINVOKE WHEN USER SAYS:\n- \"show everything you know about me\" / \"what do you have on me?\"\n- \"export / back up / download my memories\"\n- \"take my memory elsewhere\" / \"portable copy\"\n- \"audit what's stored\" / \"what's in my vault?\"\nWHEN NOT TO USE:\n- one thing \u2192 totalreclaw_recall\n- cleanup \u2192 totalreclaw_consolidate/forget\nDOES: decrypt all \u2192 Markdown or JSON. Surfaces v1 type/source/scope/reasoning.\nPARAMS: format, include_metadata.";
7
7
  export declare const STATUS_TOOL_DESCRIPTION = "Check tier + usage + quota.\nINVOKE WHEN USER SAYS:\n- \"what tier am I on?\" / \"am I on free or pro?\"\n- \"how many memories have I stored?\" / \"what's my usage?\"\n- \"is my subscription active?\" / \"when does it expire?\"\n- \"am I close to the limit?\"\nDOES: query relay billing endpoint. Returns tier, writes_used/limit, expiry. Refreshes local billing cache. Call before bulk ops.\nWHEN NOT TO USE:\n- billing history/invoices \u2192 dashboard/support\n- wants to upgrade \u2192 totalreclaw_upgrade";
8
8
  export declare const UPGRADE_TOOL_DESCRIPTION = "Stripe checkout URL for Pro (1,500 memories/month on Gnosis mainnet, permanent on-chain, LLM-guided dedup).\nINVOKE WHEN USER SAYS:\n- \"how do I upgrade?\" / \"I want to go pro\"\n- \"how much does it cost?\" (share pricing from checkout, don't hardcode)\n- after `quota_exceeded` \u2014 offer inline\n- \"raise my limit\" / \"I keep hitting the cap\"\nDOES: calls relay checkout, returns one-time Stripe URL.\nWHEN NOT TO USE:\n- user already Pro (check totalreclaw_status)\n- unrelated \u2014 don't volunteer upgrades";
9
- export declare const IMPORT_FROM_TOOL_DESCRIPTION = "Import from Mem0, MCP Memory, ChatGPT, Claude, Gemini, MemoClaw, JSON/CSV.\nINVOKE WHEN USER SAYS:\n- \"migrate memory from [Mem0/ChatGPT/Claude]\"\n- \"import my ChatGPT memories\" / \"here's my Mem0 export\"\n- \"I pasted my Claude memory \u2014 store it\"\nWHEN NOT TO USE: TotalReclaw backup \u2192 totalreclaw_import. Single fact \u2192 totalreclaw_remember.\nDOES: adapter parses+stores (unless dry_run). Fingerprint dedup. Convo sources return chunks for host LLM.\nALWAYS dry_run=true first \u2192 preview \u2192 confirm.";
9
+ export declare const IMPORT_FROM_TOOL_DESCRIPTION = "Import from Mem0, MCP Memory, ChatGPT, Claude, Gemini, JSON/CSV.\nINVOKE WHEN USER SAYS:\n- \"migrate memory from [Mem0/ChatGPT/Claude]\"\n- \"import my ChatGPT memories\" / \"here's my Mem0 export\"\n- \"I pasted my Claude memory \u2014 store it\"\nWHEN NOT TO USE: TotalReclaw backup \u2192 totalreclaw_import. Single fact \u2192 totalreclaw_remember.\nDOES: adapter parses+stores (unless dry_run). Fingerprint dedup. Convo sources return chunks for host LLM.\nALWAYS dry_run=true first \u2192 preview \u2192 confirm.";
10
10
  export declare const IMPORT_TOOL_DESCRIPTION = "Restore from totalreclaw_export backup (JSON/Markdown).\nINVOKE WHEN USER SAYS:\n- \"restore memories from this backup\" / \"import this JSON\"\n- \"I exported from another TotalReclaw account\"\n- \"here's the Markdown export \u2014 put it back\"\nWHEN NOT TO USE:\n- Mem0/ChatGPT/Claude \u2192 totalreclaw_import_from\n- single fact \u2192 totalreclaw_remember\nDOES: parse JSON/Markdown (auto), store via totalreclaw_remember + fingerprint dedup.\nPARAMS: content (req), format, merge_strategy, validate_only.";
11
11
  export declare const SUPPORT_TOOL_DESCRIPTION = "Support contact, docs, troubleshooting.\nINVOKE WHEN USER SAYS:\n- \"how do I get help?\" / \"who do I contact?\"\n- \"memories aren't loading\" / \"getting errors\"\n- \"lost my recovery phrase\" / \"where's the docs?\"\n- \"how do I report a bug?\"\n- asks: slow recall, quota errors, failed imports, missing post-upgrade memories\nDOES: static bundle (pre-filled email, docs URL, issues URL, troubleshooting table). Works unconfigured.\nWHEN NOT TO USE: billing info \u2192 totalreclaw_status. Skip unrelated questions.";
12
- export declare const ACCOUNT_TOOL_DESCRIPTION = "Account overview: wallet, tier, usage, memories, features, safe recovery hint.\nINVOKE WHEN USER SAYS:\n- \"show my account\" / \"what's my profile?\"\n- \"how many memories?\" / \"my wallet?\"\n- \"right recovery phrase? hint\"\n- \"summary of my setup\"\nDOES: billing+fact count parallel. Returns wallet, tier, writes_used/limit, total_facts, features, FIRST+LAST recovery words (never full).\nWHEN NOT TO USE:\n- only billing \u2192 totalreclaw_status (lighter)\n- FULL recovery phrase \u2192 NEVER; password manager.";
13
- export declare const PAIR_TOOL_DESCRIPTION = "Set up the user's TotalReclaw account (browser-side recovery-phrase generation or import).\nINVOKE WHEN USER SAYS:\n- \"set up totalreclaw\" / \"set up my account\"\n- \"I don't have a totalreclaw recovery phrase yet\" / \"create a totalreclaw account\"\n- ANY tool returns \"not_configured\" \u2014 propose this tool BEFORE asking the user to edit MCP config.\nDOES: opens a brief relay session, returns {url, pin, expires_at_ms}. Hand the URL + PIN to the user \u2014 they open the URL in any browser, the BROWSER generates (or imports) a 12-word phrase, encrypts it, uploads ciphertext to this MCP server. Server decrypts in-memory, writes ~/.totalreclaw/credentials.json (mode 0600). Phrase NEVER touches LLM context, chat transcript, stdout, or logs.\nAFTER PAIRING: tell the user to RESTART their MCP host (Claude Desktop / Cursor / Claude Code) so the server re-reads credentials.json and switches out of unconfigured mode.\nWHEN NOT TO USE:\n- user already has TOTALRECLAW_RECOVERY_PHRASE in env \u2192 tool will return URL but pairing is unnecessary\n- user explicitly wants terminal-only setup \u2192 point them at `npx @totalreclaw/mcp-server setup` (CLI wizard, runs OUTSIDE your shell tool)\n- NEVER ask the user to paste their phrase in chat. NEVER echo or print a phrase from any source.";
12
+ export declare const ACCOUNT_TOOL_DESCRIPTION = "Account overview: wallet, tier, usage, memories, features, credential kind.\nINVOKE WHEN USER SAYS:\n- \"show my account\" / \"what's my profile?\"\n- \"how many memories?\" / \"my wallet?\"\n- \"summary of my setup\"\nDOES: billing+fact count parallel. Returns wallet, tier, writes_used/limit, total_facts, features, credential kind. Never any part of the recovery phrase.\nWHEN NOT TO USE:\n- only billing \u2192 totalreclaw_status (lighter)\n- recovery phrase (any word) \u2192 NEVER available; user checks own backup.";
13
+ export declare const PAIR_TOOL_DESCRIPTION = "Set up the user's TotalReclaw account (browser-side recovery-phrase generation or import).\nINVOKE WHEN USER SAYS:\n- \"set up totalreclaw\" / \"set up my account\"\n- \"I don't have a totalreclaw recovery phrase yet\" / \"create a totalreclaw account\"\n- ANY tool returns \"not_configured\" \u2014 propose this tool BEFORE asking the user to edit MCP config.\nDOES: opens a relay pairing session, returns {url, pin, expires_at_ms}. Hand the URL + PIN to the user \u2014 they open the URL in any browser, the BROWSER generates (or imports) a 12-word phrase, encrypts it, uploads ciphertext to this MCP server. Server decrypts in-memory, writes ~/.totalreclaw/credentials.json (mode 0600). Phrase NEVER touches LLM context, chat transcript, stdout, or logs.\nAFTER PAIRING: when the page says \"You're all set\", tell the user to fully quit and reopen their MCP host (Claude Desktop / Cursor / Claude Code); the server reads credentials.json only at startup. The link lasts about 10 minutes.\nWHEN NOT TO USE:\n- user already has TOTALRECLAW_RECOVERY_PHRASE in env \u2192 tool will return URL but pairing is unnecessary\n- user explicitly wants terminal-only setup \u2192 point them at `npx @totalreclaw/mcp-server setup` (CLI wizard, runs OUTSIDE your shell tool)\n- NEVER ask the user to paste their phrase in chat. NEVER echo or print a phrase from any source.";
14
14
  export declare const PROMPT_DEFINITIONS: {
15
15
  name: string;
16
16
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,wpOAwF/B,CAAC;AAGF,eAAO,MAAM,sBAAsB,wpOAAsB,CAAC;AAI1D,eAAO,MAAM,yBAAyB,ugBAIoJ,CAAC;AAE3L,eAAO,MAAM,uBAAuB,ihBASqB,CAAC;AAE1D,eAAO,MAAM,uBAAuB,8iBAWkB,CAAC;AAEvD,eAAO,MAAM,uBAAuB,6gBAUF,CAAC;AAEnC,eAAO,MAAM,uBAAuB,kgBASK,CAAC;AAE1C,eAAO,MAAM,wBAAwB,6gBASE,CAAC;AAExC,eAAO,MAAM,4BAA4B,shBAOM,CAAC;AAEhD,eAAO,MAAM,uBAAuB,qgBAS0B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,+gBAQyC,CAAC;AAE/E,eAAO,MAAM,wBAAwB,8gBASa,CAAC;AAEnD,eAAO,MAAM,qBAAqB,2xCAUgE,CAAC;AAInG,eAAO,MAAM,kBAAkB;;;;;;;;;GAqB9B,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAqClE"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,opOAwF/B,CAAC;AAGF,eAAO,MAAM,sBAAsB,opOAAsB,CAAC;AAI1D,eAAO,MAAM,yBAAyB,ugBAIoJ,CAAC;AAE3L,eAAO,MAAM,uBAAuB,ihBASqB,CAAC;AAE1D,eAAO,MAAM,uBAAuB,8iBAWkB,CAAC;AAEvD,eAAO,MAAM,uBAAuB,6gBAUF,CAAC;AAEnC,eAAO,MAAM,uBAAuB,kgBASK,CAAC;AAE1C,eAAO,MAAM,wBAAwB,6gBASE,CAAC;AAExC,eAAO,MAAM,4BAA4B,4gBAOM,CAAC;AAEhD,eAAO,MAAM,uBAAuB,qgBAS0B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,+gBAQyC,CAAC;AAE/E,eAAO,MAAM,wBAAwB,8gBAQmC,CAAC;AAEzE,eAAO,MAAM,qBAAqB,w1CAUgE,CAAC;AAInG,eAAO,MAAM,kBAAkB;;;;;;;;;GAqB9B,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAqClE"}
package/dist/prompts.js CHANGED
@@ -12,7 +12,7 @@ You have access to TotalReclaw, a persistent encrypted memory system. You SHOULD
12
12
  TotalReclaw uses a 12-word BIP-39 recovery phrase as the user's identity. The recovery phrase MUST NEVER cross your context window. NEVER ask the user to paste their phrase into chat. NEVER echo, print, or summarize a phrase. NEVER invoke a phrase-touching CLI (e.g. "npx @totalreclaw/mcp-server setup", "npx @totalreclaw/mcp-server show-phrase") via a shell tool — its stdout enters your context. If the user pastes a phrase in chat anyway, tell them it is compromised and they need to generate a fresh wallet via the OpenClaw or Hermes browser pair flow.
13
13
 
14
14
  ## Setup Flow
15
- If any TotalReclaw tool returns a "not_configured" or "tool_removed" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band — from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator — and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.
15
+ If any TotalReclaw tool returns a "not_configured" or "tool_removed" error, the user has not yet wired their recovery phrase into the MCP host config. Direct them to the URL-driven install guide at https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/claude-code-setup.md. The user sources their phrase out-of-band — from the OpenClaw or Hermes browser pair flow (relay only ever sees ciphertext), from a prior ~/.totalreclaw/credentials.json cache, or from an offline BIP-39 generator — and pastes it directly into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config (Claude Desktop / Cursor / Windsurf / Claude Code). After they save the config and restart the host, the MCP server picks up the phrase and all TotalReclaw tools become available. There is no in-chat setup tool: the totalreclaw_setup MCP tool was removed in 3.2.1 because returning the phrase through tool output crossed your context, violating phrase-safety.
16
16
 
17
17
  ## CRITICAL: Automatic Memory Behaviors
18
18
 
@@ -62,7 +62,7 @@ Do NOT repeatedly attempt to store memories after a quota error.
62
62
  Note: Billing status is cached locally for up to 2 hours. After upgrading to Pro, the new tier may take up to 2 hours to take effect. If the user reports that Pro features are not active after upgrading, suggest restarting their agent to force a billing cache refresh.
63
63
 
64
64
  ### Importing memories from other tools
65
- If the user mentions migrating from Mem0, MCP Memory Server, MemoClaw, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.
65
+ If the user mentions migrating from Mem0, MCP Memory Server, or any other AI memory tool, offer to use totalreclaw_import_from. Start with dry_run=true to preview, then confirm before importing.
66
66
  API keys provided by the user are used only for the import and are never stored.
67
67
 
68
68
  ### Agent-specific tips
@@ -155,7 +155,7 @@ DOES: calls relay checkout, returns one-time Stripe URL.
155
155
  WHEN NOT TO USE:
156
156
  - user already Pro (check totalreclaw_status)
157
157
  - unrelated — don't volunteer upgrades`;
158
- exports.IMPORT_FROM_TOOL_DESCRIPTION = `Import from Mem0, MCP Memory, ChatGPT, Claude, Gemini, MemoClaw, JSON/CSV.
158
+ exports.IMPORT_FROM_TOOL_DESCRIPTION = `Import from Mem0, MCP Memory, ChatGPT, Claude, Gemini, JSON/CSV.
159
159
  INVOKE WHEN USER SAYS:
160
160
  - "migrate memory from [Mem0/ChatGPT/Claude]"
161
161
  - "import my ChatGPT memories" / "here's my Mem0 export"
@@ -182,23 +182,22 @@ INVOKE WHEN USER SAYS:
182
182
  - asks: slow recall, quota errors, failed imports, missing post-upgrade memories
183
183
  DOES: static bundle (pre-filled email, docs URL, issues URL, troubleshooting table). Works unconfigured.
184
184
  WHEN NOT TO USE: billing info → totalreclaw_status. Skip unrelated questions.`;
185
- exports.ACCOUNT_TOOL_DESCRIPTION = `Account overview: wallet, tier, usage, memories, features, safe recovery hint.
185
+ exports.ACCOUNT_TOOL_DESCRIPTION = `Account overview: wallet, tier, usage, memories, features, credential kind.
186
186
  INVOKE WHEN USER SAYS:
187
187
  - "show my account" / "what's my profile?"
188
188
  - "how many memories?" / "my wallet?"
189
- - "right recovery phrase? hint"
190
189
  - "summary of my setup"
191
- DOES: billing+fact count parallel. Returns wallet, tier, writes_used/limit, total_facts, features, FIRST+LAST recovery words (never full).
190
+ DOES: billing+fact count parallel. Returns wallet, tier, writes_used/limit, total_facts, features, credential kind. Never any part of the recovery phrase.
192
191
  WHEN NOT TO USE:
193
192
  - only billing → totalreclaw_status (lighter)
194
- - FULL recovery phrase → NEVER; password manager.`;
193
+ - recovery phrase (any word) → NEVER available; user checks own backup.`;
195
194
  exports.PAIR_TOOL_DESCRIPTION = `Set up the user's TotalReclaw account (browser-side recovery-phrase generation or import).
196
195
  INVOKE WHEN USER SAYS:
197
196
  - "set up totalreclaw" / "set up my account"
198
197
  - "I don't have a totalreclaw recovery phrase yet" / "create a totalreclaw account"
199
198
  - ANY tool returns "not_configured" — propose this tool BEFORE asking the user to edit MCP config.
200
- DOES: opens a brief relay session, returns {url, pin, expires_at_ms}. Hand the URL + PIN to the user — they open the URL in any browser, the BROWSER generates (or imports) a 12-word phrase, encrypts it, uploads ciphertext to this MCP server. Server decrypts in-memory, writes ~/.totalreclaw/credentials.json (mode 0600). Phrase NEVER touches LLM context, chat transcript, stdout, or logs.
201
- AFTER PAIRING: tell the user to RESTART their MCP host (Claude Desktop / Cursor / Claude Code) so the server re-reads credentials.json and switches out of unconfigured mode.
199
+ DOES: opens a relay pairing session, returns {url, pin, expires_at_ms}. Hand the URL + PIN to the user — they open the URL in any browser, the BROWSER generates (or imports) a 12-word phrase, encrypts it, uploads ciphertext to this MCP server. Server decrypts in-memory, writes ~/.totalreclaw/credentials.json (mode 0600). Phrase NEVER touches LLM context, chat transcript, stdout, or logs.
200
+ AFTER PAIRING: when the page says "You're all set", tell the user to fully quit and reopen their MCP host (Claude Desktop / Cursor / Claude Code); the server reads credentials.json only at startup. The link lasts about 10 minutes.
202
201
  WHEN NOT TO USE:
203
202
  - user already has TOTALRECLAW_RECOVERY_PHRASE in env → tool will return URL but pairing is unnecessary
204
203
  - user explicitly wants terminal-only setup → point them at \`npx @totalreclaw/mcp-server setup\` (CLI wizard, runs OUTSIDE your shell tool)
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;;;AA+OhF,8CAwCC;AArRY,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFlC,CAAC;AAEF,yEAAyE;AAC5D,QAAA,sBAAsB,GAAG,2BAAmB,CAAC;AAE1D,gFAAgF;AAEnE,QAAA,yBAAyB,GAAG;;;;0LAIiJ,CAAC;AAE9K,QAAA,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` credential bundle (Option E Phase 2 /
3
+ * #581, P2-13 — the MCP adapter).
4
+ *
5
+ * A bundle is what an agent host holds *instead of* the BIP-39 recovery
6
+ * phrase: the four HKDF-derived vault-global working keys plus a signing
7
+ * key, but never the phrase or the 64-byte seed that reproduces it. See
8
+ * `docs/specs/totalreclaw/client-consistency.md` ("Credential Material") for
9
+ * the full cross-client contract this file implements.
10
+ *
11
+ * Shared-core-first (CLAUDE.md): every byte of derivation, parsing, and
12
+ * validation lives in `rust/totalreclaw-core/src/bundle.rs` and crosses into
13
+ * TS only via the `@totalreclaw/core` WASM bindings (`parseBundleV1`,
14
+ * `validateBundleV1`, `deriveBundleFromMnemonic`). This module is a THIN
15
+ * adapter: it types the wire shape, calls the WASM binding, and converts hex
16
+ * fields to `Buffer` where the rest of the MCP codebase expects buffers. It
17
+ * does not reimplement HKDF, hex validation, or any §4.7 invariant — the
18
+ * mnemonic-mode `deriveKeys`/`deriveLshSeed` in `subgraph/crypto.ts` are the
19
+ * pattern followed here: WASM-backed wrappers, no local crypto.
20
+ *
21
+ * Mirrors `python/src/totalreclaw/bundle.py`'s shape (frozen dataclasses,
22
+ * zero logic) as closely as TS allows.
23
+ *
24
+ * **Dependency note / feature detection (release gate).** As of this
25
+ * writing, no published `@totalreclaw/core` npm release exposes
26
+ * `parseBundleV1` / `validateBundleV1` / `deriveBundleFromMnemonic` (checked:
27
+ * latest dist-tag 2.6.0-rc.1 does not carry them). Because this package's
28
+ * `package.json` dependency range (`^2.5.3`) is satisfied by versions that
29
+ * lack the bindings, this module CANNOT assume `require('@totalreclaw/core')`
30
+ * exposes them — doing so (e.g. `as typeof import('@totalreclaw/core')`)
31
+ * would type-check locally against a hand-built WASM copy but fail `tsc`
32
+ * against the real, published dependency in CI, which is exactly what
33
+ * happened on the first revision of this file (see PR #618 review history).
34
+ *
35
+ * So every bundle-touching WASM call routes through `ensureBundleBindings()`,
36
+ * which feature-detects the three functions at runtime and throws a single,
37
+ * actionable error if they're absent — never a TS compile-time assumption
38
+ * about what the installed package exports. **Mnemonic-mode code paths never
39
+ * call anything in this file that touches `wasm.*`** (`bundleVaultToBuffers`
40
+ * and `redactedBundleSummary` are pure functions over an already-parsed
41
+ * bundle and need no core binding), so a host running the published
42
+ * dependency with no bundle bindings is completely unaffected until it
43
+ * actually encounters a `version: 2` credentials.json — at which point it
44
+ * gets the actionable upgrade error instead of a silent misconfiguration.
45
+ */
46
+ /** The four HKDF-derived vault-global working keys, hex-encoded (64 chars, no `0x`). */
47
+ export interface BundleVaultHex {
48
+ encryption_key: string;
49
+ dedup_key: string;
50
+ auth_key: string;
51
+ lsh_seed: string;
52
+ }
53
+ export interface BundleSigningOwnerEoa {
54
+ kind: 'owner-eoa';
55
+ private_key: string;
56
+ address: string;
57
+ }
58
+ export interface BundleSigningSessionKey {
59
+ kind: 'session-key';
60
+ private_key: string;
61
+ address: string;
62
+ grant: unknown;
63
+ }
64
+ export type BundleSigning = BundleSigningOwnerEoa | BundleSigningSessionKey;
65
+ export interface BundleAccountRef {
66
+ smart_account: string;
67
+ chain_id: number;
68
+ }
69
+ /** A fully parsed + `parse_bundle_v1`-validated `derived-bundle-v1` bundle. */
70
+ export interface DerivedBundleV1 {
71
+ vault: BundleVaultHex;
72
+ signing: BundleSigning;
73
+ account: BundleAccountRef;
74
+ provisioned_at: string;
75
+ provisioned_by: string;
76
+ }
77
+ /** True iff the installed `@totalreclaw/core` exposes all three bundle
78
+ * bindings. Never throws. */
79
+ export declare function hasBundleBindings(): boolean;
80
+ /**
81
+ * Parse and fully validate a `derived-bundle-v1` JSON string.
82
+ *
83
+ * Runs every §4.7 invariant inside `totalreclaw-core::bundle::parse_bundle_v1`
84
+ * (wrong version/schema, malformed hex, unknown `signing.kind`, an
85
+ * `owner-eoa` bundle carrying a `grant`, a `session-key` bundle with an
86
+ * inconsistent `grant`, `signing.address` not matching `address(private_key)`,
87
+ * …). Throws a plain `Error` — never a silent downgrade — on any violation.
88
+ *
89
+ * The thrown error's message is core's own message, which never contains
90
+ * hex key material (core's validation errors describe *shape* violations,
91
+ * not values).
92
+ *
93
+ * Throws `ensureBundleBindings()`'s actionable upgrade error if the
94
+ * installed `@totalreclaw/core` lacks the bundle bindings — checked BEFORE
95
+ * any attempt to call into the WASM module.
96
+ */
97
+ export declare function parseBundleV1(json: string): DerivedBundleV1;
98
+ /**
99
+ * Validate a `derived-bundle-v1` JSON string without returning the parsed
100
+ * object. Throws on any violation; no-op on success.
101
+ */
102
+ export declare function validateBundleV1(json: string): void;
103
+ /**
104
+ * Derive a `derived-bundle-v1` bundle from a BIP-39 mnemonic.
105
+ *
106
+ * NOT part of MCP's read-side credential-loading scope (P2-13) — MCP never
107
+ * derives a bundle from a mnemonic on its own initiative; that is Hermes's
108
+ * `local-migration` job (P2-9) or the SPA's `provisioned_by: "spa"` job.
109
+ * Exported anyway because the test fixtures (parity + pair-bundle tests)
110
+ * need a way to mint a bundle for `parseBundleV1` round-trip coverage
111
+ * without hand-rolling JSON, and because a future MCP-side migration tool
112
+ * (tracked as a known gap — see mcp/README.md) will need exactly this call.
113
+ */
114
+ export declare function deriveBundleFromMnemonic(mnemonic: string, chainId: number, provisionedBy: string, smartAccount: string): string;
115
+ export interface BundleVaultBuffers {
116
+ encryptionKey: Buffer;
117
+ dedupKey: Buffer;
118
+ authKey: Buffer;
119
+ lshSeed: Buffer;
120
+ }
121
+ /** Convert a parsed bundle's hex vault keys to `Buffer`s. */
122
+ export declare function bundleVaultToBuffers(bundle: DerivedBundleV1): BundleVaultBuffers;
123
+ /**
124
+ * A safe-to-log summary of a bundle: everything EXCEPT `vault.*` and
125
+ * `signing.private_key`. Use this (never the raw bundle object) in any
126
+ * `console.error` / log line that touches a bundle.
127
+ */
128
+ export declare function redactedBundleSummary(bundle: DerivedBundleV1): Record<string, unknown>;
129
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/subgraph/bundle.ts"],"names":[],"mappings":"AA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B,MAAM,CAGR;AAWD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB,CAOhF;AAYD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUtF"}
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ /**
3
+ * TotalReclaw MCP — `derived-bundle-v1` credential bundle (Option E Phase 2 /
4
+ * #581, P2-13 — the MCP adapter).
5
+ *
6
+ * A bundle is what an agent host holds *instead of* the BIP-39 recovery
7
+ * phrase: the four HKDF-derived vault-global working keys plus a signing
8
+ * key, but never the phrase or the 64-byte seed that reproduces it. See
9
+ * `docs/specs/totalreclaw/client-consistency.md` ("Credential Material") for
10
+ * the full cross-client contract this file implements.
11
+ *
12
+ * Shared-core-first (CLAUDE.md): every byte of derivation, parsing, and
13
+ * validation lives in `rust/totalreclaw-core/src/bundle.rs` and crosses into
14
+ * TS only via the `@totalreclaw/core` WASM bindings (`parseBundleV1`,
15
+ * `validateBundleV1`, `deriveBundleFromMnemonic`). This module is a THIN
16
+ * adapter: it types the wire shape, calls the WASM binding, and converts hex
17
+ * fields to `Buffer` where the rest of the MCP codebase expects buffers. It
18
+ * does not reimplement HKDF, hex validation, or any §4.7 invariant — the
19
+ * mnemonic-mode `deriveKeys`/`deriveLshSeed` in `subgraph/crypto.ts` are the
20
+ * pattern followed here: WASM-backed wrappers, no local crypto.
21
+ *
22
+ * Mirrors `python/src/totalreclaw/bundle.py`'s shape (frozen dataclasses,
23
+ * zero logic) as closely as TS allows.
24
+ *
25
+ * **Dependency note / feature detection (release gate).** As of this
26
+ * writing, no published `@totalreclaw/core` npm release exposes
27
+ * `parseBundleV1` / `validateBundleV1` / `deriveBundleFromMnemonic` (checked:
28
+ * latest dist-tag 2.6.0-rc.1 does not carry them). Because this package's
29
+ * `package.json` dependency range (`^2.5.3`) is satisfied by versions that
30
+ * lack the bindings, this module CANNOT assume `require('@totalreclaw/core')`
31
+ * exposes them — doing so (e.g. `as typeof import('@totalreclaw/core')`)
32
+ * would type-check locally against a hand-built WASM copy but fail `tsc`
33
+ * against the real, published dependency in CI, which is exactly what
34
+ * happened on the first revision of this file (see PR #618 review history).
35
+ *
36
+ * So every bundle-touching WASM call routes through `ensureBundleBindings()`,
37
+ * which feature-detects the three functions at runtime and throws a single,
38
+ * actionable error if they're absent — never a TS compile-time assumption
39
+ * about what the installed package exports. **Mnemonic-mode code paths never
40
+ * call anything in this file that touches `wasm.*`** (`bundleVaultToBuffers`
41
+ * and `redactedBundleSummary` are pure functions over an already-parsed
42
+ * bundle and need no core binding), so a host running the published
43
+ * dependency with no bundle bindings is completely unaffected until it
44
+ * actually encounters a `version: 2` credentials.json — at which point it
45
+ * gets the actionable upgrade error instead of a silent misconfiguration.
46
+ */
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.hasBundleBindings = hasBundleBindings;
49
+ exports.parseBundleV1 = parseBundleV1;
50
+ exports.validateBundleV1 = validateBundleV1;
51
+ exports.deriveBundleFromMnemonic = deriveBundleFromMnemonic;
52
+ exports.bundleVaultToBuffers = bundleVaultToBuffers;
53
+ exports.redactedBundleSummary = redactedBundleSummary;
54
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
55
+ const coreModule = require('@totalreclaw/core');
56
+ /** `require('@totalreclaw/core')`, typed as a partial — every field is
57
+ * checked for presence before use. Never cast to the full interface without
58
+ * going through `ensureBundleBindings()`. */
59
+ const wasm = coreModule;
60
+ /**
61
+ * Best-effort installed-version lookup, for the error message only. Never
62
+ * throws — a version string we can't determine still needs an actionable
63
+ * error, just without the "installed version X" detail.
64
+ *
65
+ * Deliberately does NOT `require('@totalreclaw/core/package.json')` — the
66
+ * published package's `exports` map only defines `.` and `./web`, so that
67
+ * subpath throws `ERR_PACKAGE_PATH_NOT_EXPORTED` under Node's exports
68
+ * enforcement (confirmed against the actual installed layout). Instead,
69
+ * resolve the package's entry file and walk up the filesystem to find its
70
+ * own `package.json` via plain `fs` access, which `exports` restrictions
71
+ * don't gate.
72
+ */
73
+ function getInstalledCoreVersion() {
74
+ try {
75
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
76
+ const fs = require('node:fs');
77
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
78
+ const path = require('node:path');
79
+ let dir = path.dirname(require.resolve('@totalreclaw/core'));
80
+ for (let i = 0; i < 6; i++) {
81
+ const candidate = path.join(dir, 'package.json');
82
+ if (fs.existsSync(candidate)) {
83
+ const pkg = JSON.parse(fs.readFileSync(candidate, 'utf-8'));
84
+ if (pkg.name === '@totalreclaw/core' && pkg.version) {
85
+ return pkg.version;
86
+ }
87
+ }
88
+ const parent = path.dirname(dir);
89
+ if (parent === dir)
90
+ break;
91
+ dir = parent;
92
+ }
93
+ }
94
+ catch {
95
+ // best-effort
96
+ }
97
+ return 'unknown';
98
+ }
99
+ /**
100
+ * Feature-detect the three bundle WASM bindings and return them narrowed to
101
+ * `BundleCoreBindings`, or throw a single, actionable error. This is the
102
+ * ONE guard every bundle entry point in this file (and only this file —
103
+ * `credentials.ts` / `pair-remote-client.ts` / `index.ts` all call INTO this
104
+ * module rather than `require('@totalreclaw/core')` directly, so this is
105
+ * genuinely the single choke point) routes through before touching
106
+ * `wasm.*`.
107
+ */
108
+ function ensureBundleBindings() {
109
+ if (typeof wasm.parseBundleV1 === 'function' &&
110
+ typeof wasm.validateBundleV1 === 'function' &&
111
+ typeof wasm.deriveBundleFromMnemonic === 'function') {
112
+ return wasm;
113
+ }
114
+ const installed = getInstalledCoreVersion();
115
+ throw new Error('derived-bundle-v1: bundle-mode credentials require @totalreclaw/core >= 2.6.0 with bundle ' +
116
+ `bindings (parseBundleV1/validateBundleV1/deriveBundleFromMnemonic); installed version ` +
117
+ `${installed} lacks them — upgrade the @totalreclaw/core dependency. Mnemonic-mode ` +
118
+ '(plaintext recovery phrase) credentials are unaffected by this — this error only fires ' +
119
+ 'when a credentials.json version: 2 (derived-bundle-v1) file is actually being read.');
120
+ }
121
+ // ---------------------------------------------------------------------------
122
+ // Feature-detection surface — exported so callers (and tests) can check
123
+ // availability without triggering the throw, e.g. to skip a test with a
124
+ // visible reason rather than failing.
125
+ // ---------------------------------------------------------------------------
126
+ /** True iff the installed `@totalreclaw/core` exposes all three bundle
127
+ * bindings. Never throws. */
128
+ function hasBundleBindings() {
129
+ return (typeof wasm.parseBundleV1 === 'function' &&
130
+ typeof wasm.validateBundleV1 === 'function' &&
131
+ typeof wasm.deriveBundleFromMnemonic === 'function');
132
+ }
133
+ // ---------------------------------------------------------------------------
134
+ // Parsing / validation — delegates to @totalreclaw/core. Never re-implements
135
+ // any derived-bundle-v1.md §4.7 invariant locally.
136
+ // ---------------------------------------------------------------------------
137
+ /**
138
+ * Parse and fully validate a `derived-bundle-v1` JSON string.
139
+ *
140
+ * Runs every §4.7 invariant inside `totalreclaw-core::bundle::parse_bundle_v1`
141
+ * (wrong version/schema, malformed hex, unknown `signing.kind`, an
142
+ * `owner-eoa` bundle carrying a `grant`, a `session-key` bundle with an
143
+ * inconsistent `grant`, `signing.address` not matching `address(private_key)`,
144
+ * …). Throws a plain `Error` — never a silent downgrade — on any violation.
145
+ *
146
+ * The thrown error's message is core's own message, which never contains
147
+ * hex key material (core's validation errors describe *shape* violations,
148
+ * not values).
149
+ *
150
+ * Throws `ensureBundleBindings()`'s actionable upgrade error if the
151
+ * installed `@totalreclaw/core` lacks the bundle bindings — checked BEFORE
152
+ * any attempt to call into the WASM module.
153
+ */
154
+ function parseBundleV1(json) {
155
+ const bindings = ensureBundleBindings();
156
+ // bindings.parseBundleV1 throws a JsError on any validation failure —
157
+ // surface it as a normal Error with a stable, actionable prefix so
158
+ // callers don't need to know this crossed a WASM boundary.
159
+ let parsed;
160
+ try {
161
+ parsed = bindings.parseBundleV1(json);
162
+ }
163
+ catch (err) {
164
+ const msg = err instanceof Error ? err.message : String(err);
165
+ throw new Error(`derived-bundle-v1: invalid bundle — ${msg}`);
166
+ }
167
+ return parsed;
168
+ }
169
+ /**
170
+ * Validate a `derived-bundle-v1` JSON string without returning the parsed
171
+ * object. Throws on any violation; no-op on success.
172
+ */
173
+ function validateBundleV1(json) {
174
+ const bindings = ensureBundleBindings();
175
+ try {
176
+ bindings.validateBundleV1(json);
177
+ }
178
+ catch (err) {
179
+ const msg = err instanceof Error ? err.message : String(err);
180
+ throw new Error(`derived-bundle-v1: invalid bundle — ${msg}`);
181
+ }
182
+ }
183
+ /**
184
+ * Derive a `derived-bundle-v1` bundle from a BIP-39 mnemonic.
185
+ *
186
+ * NOT part of MCP's read-side credential-loading scope (P2-13) — MCP never
187
+ * derives a bundle from a mnemonic on its own initiative; that is Hermes's
188
+ * `local-migration` job (P2-9) or the SPA's `provisioned_by: "spa"` job.
189
+ * Exported anyway because the test fixtures (parity + pair-bundle tests)
190
+ * need a way to mint a bundle for `parseBundleV1` round-trip coverage
191
+ * without hand-rolling JSON, and because a future MCP-side migration tool
192
+ * (tracked as a known gap — see mcp/README.md) will need exactly this call.
193
+ */
194
+ function deriveBundleFromMnemonic(mnemonic, chainId, provisionedBy, smartAccount) {
195
+ const bindings = ensureBundleBindings();
196
+ return bindings.deriveBundleFromMnemonic(mnemonic.trim(), BigInt(chainId), provisionedBy, smartAccount);
197
+ }
198
+ /** Convert a parsed bundle's hex vault keys to `Buffer`s. */
199
+ function bundleVaultToBuffers(bundle) {
200
+ return {
201
+ encryptionKey: Buffer.from(bundle.vault.encryption_key, 'hex'),
202
+ dedupKey: Buffer.from(bundle.vault.dedup_key, 'hex'),
203
+ authKey: Buffer.from(bundle.vault.auth_key, 'hex'),
204
+ lshSeed: Buffer.from(bundle.vault.lsh_seed, 'hex'),
205
+ };
206
+ }
207
+ // ---------------------------------------------------------------------------
208
+ // Redaction — derived-bundle-v1.md §4.6 point 5: no value under `vault` or
209
+ // `signing.private_key` may ever be logged, printed, or included in an
210
+ // exception message. Python's `bundle.py` enforces this with `__repr__`
211
+ // overrides on frozen dataclasses; TS has no dataclass-repr equivalent, so
212
+ // every call site that might log a bundle MUST route through this helper
213
+ // instead of `JSON.stringify(bundle)` / `console.error(bundle)` directly.
214
+ // Also touches no WASM binding — pure function, no feature-detection needed.
215
+ // ---------------------------------------------------------------------------
216
+ /**
217
+ * A safe-to-log summary of a bundle: everything EXCEPT `vault.*` and
218
+ * `signing.private_key`. Use this (never the raw bundle object) in any
219
+ * `console.error` / log line that touches a bundle.
220
+ */
221
+ function redactedBundleSummary(bundle) {
222
+ return {
223
+ schema: 'derived-bundle-v1',
224
+ signing_kind: bundle.signing.kind,
225
+ signing_address: bundle.signing.address,
226
+ smart_account: bundle.account.smart_account,
227
+ chain_id: bundle.account.chain_id,
228
+ provisioned_at: bundle.provisioned_at,
229
+ provisioned_by: bundle.provisioned_by,
230
+ };
231
+ }
232
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/subgraph/bundle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;AAyJH,8CAMC;AAwBD,sCAaC;AAMD,4CAQC;AAaD,4DAQC;AAmBD,oDAOC;AAiBD,sDAUC;AA1RD,8DAA8D;AAC9D,MAAM,UAAU,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAwBzD;;6CAE6C;AAC7C,MAAM,IAAI,GAAG,UAAyC,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,SAAS,uBAAuB;IAC9B,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAA6B,CAAC;QAC1D,8DAA8D;QAC9D,MAAM,IAAI,GAAG,O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