@torqon/mcp 0.2.2 → 0.2.4
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 +51 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,37 +76,67 @@ function hasSignal(text) {
|
|
|
76
76
|
return words.length >= 3;
|
|
77
77
|
}
|
|
78
78
|
// ── MCP Server ───────────────────────────────────────────────────────────────
|
|
79
|
-
const server = new McpServer({
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const server = new McpServer({ name: 'torqon', version: '0.2.4' }, {
|
|
80
|
+
instructions: `Torqon persistent memory is active for this conversation.
|
|
81
|
+
|
|
82
|
+
RULE: Call auto_process with the full user message BEFORE you respond to anything — every message, no exceptions, including greetings and one-word replies. It runs in under 200ms and simultaneously stores new facts AND retrieves relevant memory.
|
|
83
|
+
|
|
84
|
+
After auto_process returns:
|
|
85
|
+
- If it returns "[Torqon memory]" facts, treat them as ground truth. Use exact stored values (names, decisions, stack choices, numbers).
|
|
86
|
+
- If it returns "No relevant memory found", answer normally.
|
|
87
|
+
|
|
88
|
+
Also call store_memory explicitly whenever the user shares their name, a project name, a key decision, a tech stack choice, a deadline, a constraint, or a preference. auto_process stores automatically but store_memory is for high-value facts you want confirmed saved.
|
|
89
|
+
|
|
90
|
+
Session ID: ${SESSION_ID}`,
|
|
82
91
|
});
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
92
|
+
// Live memory loader — user runs /torqon_context once at conversation start.
|
|
93
|
+
// Fetches all stored facts from the API and injects them directly into the prompt.
|
|
94
|
+
// This is more reliable than auto_process-per-message because it's a deliberate
|
|
95
|
+
// one-time action, not a tool Claude has to remember to call before every message.
|
|
96
|
+
server.prompt('torqon_context', 'Load your Torqon memory into this conversation (run once at the start)', {}, async () => {
|
|
97
|
+
if (!API_KEY) {
|
|
98
|
+
return {
|
|
99
|
+
messages: [{
|
|
100
|
+
role: 'user',
|
|
101
|
+
content: { type: 'text', text: '[Torqon] No API key configured. Run: npx -y @torqon/mcp@latest add claude --api-key <your-key>' },
|
|
102
|
+
}],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Fetch all current facts for this user
|
|
106
|
+
let facts = [];
|
|
107
|
+
try {
|
|
108
|
+
const res = await fetch(`${API_URL}/api/v1/memory`, { headers });
|
|
109
|
+
if (res.ok) {
|
|
110
|
+
const data = await res.json();
|
|
111
|
+
facts = data?.results ?? [];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { /* network error — start with empty facts */ }
|
|
115
|
+
const factLines = facts
|
|
116
|
+
.map((f) => f.metadata?.type ? `${f.metadata.type}: ${f.content}` : f.content)
|
|
117
|
+
.join('\n');
|
|
118
|
+
const memoryBlock = factLines
|
|
119
|
+
? `[TORQON MEMORY — treat as ground truth]\n${factLines}`
|
|
120
|
+
: '[TORQON MEMORY — no facts stored yet]';
|
|
86
121
|
return {
|
|
87
122
|
messages: [
|
|
88
123
|
{
|
|
89
124
|
role: 'user',
|
|
90
125
|
content: {
|
|
91
126
|
type: 'text',
|
|
92
|
-
text:
|
|
93
|
-
TORQON PERSISTENT MEMORY IS ACTIVE. These are non-negotiable behavioral rules:
|
|
127
|
+
text: `${memoryBlock}
|
|
94
128
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Why: auto_process runs in under 200ms. It simultaneously stores new facts AND retrieves relevant memory. Skipping it means the user loses context they paid for.
|
|
98
|
-
|
|
99
|
-
After auto_process returns:
|
|
100
|
-
- If it returns facts tagged [Torqon memory], treat them as ground truth. Names, decisions, stack choices, numbers — use the exact stored values, not your training data.
|
|
101
|
-
- If it returns "No relevant memory found", answer normally.
|
|
129
|
+
These are verified facts stored across all your previous sessions. Use them exactly as written — do not infer, expand, or contradict them.
|
|
102
130
|
|
|
103
|
-
|
|
131
|
+
From this point:
|
|
132
|
+
- When the user shares new facts (name, project, stack, decision, deadline, preference), call store_memory to save them.
|
|
133
|
+
- When the user asks about something that might be in memory, call retrieve_context.
|
|
134
|
+
- You do NOT need to call auto_process on every message — just store and retrieve deliberately.
|
|
104
135
|
|
|
105
|
-
Session: ${SESSION_ID}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
]
|
|
136
|
+
Session: ${SESSION_ID}`,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
110
140
|
};
|
|
111
141
|
});
|
|
112
142
|
// ── auto_process ─────────────────────────────────────────────────────────────
|