@j0hanz/cortex-mcp 0.1.2
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/README.md +269 -0
- package/dist/assets/logo.svg +49 -0
- package/dist/engine/config.d.ts +9 -0
- package/dist/engine/config.d.ts.map +1 -0
- package/dist/engine/config.js +26 -0
- package/dist/engine/config.js.map +1 -0
- package/dist/engine/context.d.ts +7 -0
- package/dist/engine/context.d.ts.map +1 -0
- package/dist/engine/context.js +6 -0
- package/dist/engine/context.js.map +1 -0
- package/dist/engine/events.d.ts +51 -0
- package/dist/engine/events.d.ts.map +1 -0
- package/dist/engine/events.js +9 -0
- package/dist/engine/events.js.map +1 -0
- package/dist/engine/index.d.ts +6 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +6 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/reasoner.d.ts +12 -0
- package/dist/engine/reasoner.d.ts.map +1 -0
- package/dist/engine/reasoner.js +208 -0
- package/dist/engine/reasoner.js.map +1 -0
- package/dist/engine/session-store.d.ts +17 -0
- package/dist/engine/session-store.d.ts.map +1 -0
- package/dist/engine/session-store.js +120 -0
- package/dist/engine/session-store.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions.md +131 -0
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +41 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/instructions.d.ts +5 -0
- package/dist/lib/instructions.d.ts.map +1 -0
- package/dist/lib/instructions.js +14 -0
- package/dist/lib/instructions.js.map +1 -0
- package/dist/lib/text.d.ts +20 -0
- package/dist/lib/text.d.ts.map +1 -0
- package/dist/lib/text.js +74 -0
- package/dist/lib/text.js.map +1 -0
- package/dist/lib/tool-response.d.ts +6 -0
- package/dist/lib/tool-response.d.ts.map +1 -0
- package/dist/lib/tool-response.js +13 -0
- package/dist/lib/tool-response.js.map +1 -0
- package/dist/lib/types.d.ts +27 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +156 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +4 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +248 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/schemas/inputs.d.ts +13 -0
- package/dist/schemas/inputs.d.ts.map +1 -0
- package/dist/schemas/inputs.js +39 -0
- package/dist/schemas/inputs.js.map +1 -0
- package/dist/schemas/outputs.d.ts +76 -0
- package/dist/schemas/outputs.d.ts.map +1 -0
- package/dist/schemas/outputs.js +59 -0
- package/dist/schemas/outputs.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +169 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/reasoning-think.d.ts +9 -0
- package/dist/tools/reasoning-think.d.ts.map +1 -0
- package/dist/tools/reasoning-think.js +298 -0
- package/dist/tools/reasoning-think.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { createSegmenter, truncate } from '../lib/text.js';
|
|
3
|
+
import { assertTargetThoughtsInRange, LEVEL_CONFIGS } from './config.js';
|
|
4
|
+
import { runWithContext } from './context.js';
|
|
5
|
+
import { engineEvents } from './events.js';
|
|
6
|
+
import { SessionStore } from './session-store.js';
|
|
7
|
+
const sessionStore = new SessionStore();
|
|
8
|
+
const graphemeSegmenter = createSegmenter('grapheme');
|
|
9
|
+
const sentenceSegmenter = createSegmenter('sentence');
|
|
10
|
+
const sessionLocks = new Map();
|
|
11
|
+
export { sessionStore };
|
|
12
|
+
export async function reason(query, level, options) {
|
|
13
|
+
const { sessionId, targetThoughts, abortSignal, onProgress } = options ?? {};
|
|
14
|
+
const config = LEVEL_CONFIGS[level];
|
|
15
|
+
const session = resolveSession(level, sessionId, query, config, targetThoughts);
|
|
16
|
+
const { totalThoughts } = session;
|
|
17
|
+
return runWithContext({ sessionId: session.id, ...(abortSignal ? { abortSignal } : {}) }, () => withSessionLock(session.id, async () => {
|
|
18
|
+
throwIfReasoningAborted(abortSignal);
|
|
19
|
+
const current = getSessionOrThrow(session.id);
|
|
20
|
+
if (current.tokensUsed >= config.tokenBudget) {
|
|
21
|
+
emitBudgetExhausted({
|
|
22
|
+
sessionId: session.id,
|
|
23
|
+
tokensUsed: current.tokensUsed,
|
|
24
|
+
tokenBudget: config.tokenBudget,
|
|
25
|
+
generatedThoughts: 0,
|
|
26
|
+
requestedThoughts: totalThoughts,
|
|
27
|
+
});
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
const nextIndex = current.thoughts.length;
|
|
31
|
+
if (nextIndex >= totalThoughts) {
|
|
32
|
+
return current;
|
|
33
|
+
}
|
|
34
|
+
const stepContent = generateReasoningStep(query, nextIndex, totalThoughts);
|
|
35
|
+
if (!stepContent) {
|
|
36
|
+
throw new Error(`Step content missing at index ${String(nextIndex)}/${String(totalThoughts)}`);
|
|
37
|
+
}
|
|
38
|
+
const thought = sessionStore.addThought(session.id, stepContent);
|
|
39
|
+
engineEvents.emit('thought:added', {
|
|
40
|
+
sessionId: session.id,
|
|
41
|
+
index: thought.index,
|
|
42
|
+
content: thought.content,
|
|
43
|
+
});
|
|
44
|
+
const updated = getSessionOrThrow(session.id);
|
|
45
|
+
if (updated.tokensUsed >= config.tokenBudget) {
|
|
46
|
+
emitBudgetExhausted({
|
|
47
|
+
sessionId: session.id,
|
|
48
|
+
tokensUsed: updated.tokensUsed,
|
|
49
|
+
tokenBudget: config.tokenBudget,
|
|
50
|
+
generatedThoughts: thought.index + 1,
|
|
51
|
+
requestedThoughts: totalThoughts,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (onProgress) {
|
|
55
|
+
await onProgress(thought.index + 1, totalThoughts);
|
|
56
|
+
throwIfReasoningAborted(abortSignal);
|
|
57
|
+
}
|
|
58
|
+
return getSessionOrThrow(session.id);
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
async function withSessionLock(sessionId, fn) {
|
|
62
|
+
const previous = sessionLocks.get(sessionId) ?? Promise.resolve();
|
|
63
|
+
let release;
|
|
64
|
+
const next = new Promise((resolve) => {
|
|
65
|
+
release = resolve;
|
|
66
|
+
});
|
|
67
|
+
const currentTail = previous.then(() => next);
|
|
68
|
+
sessionLocks.set(sessionId, currentTail);
|
|
69
|
+
await previous;
|
|
70
|
+
try {
|
|
71
|
+
return await fn();
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
release?.();
|
|
75
|
+
if (sessionLocks.get(sessionId) === currentTail) {
|
|
76
|
+
sessionLocks.delete(sessionId);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function getSessionOrThrow(sessionId) {
|
|
81
|
+
const session = sessionStore.get(sessionId);
|
|
82
|
+
if (!session) {
|
|
83
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
84
|
+
}
|
|
85
|
+
return session;
|
|
86
|
+
}
|
|
87
|
+
function emitBudgetExhausted(data) {
|
|
88
|
+
engineEvents.emit('thought:budget-exhausted', data);
|
|
89
|
+
}
|
|
90
|
+
function resolveSession(level, sessionId, query, config, targetThoughts) {
|
|
91
|
+
if (sessionId) {
|
|
92
|
+
const existing = sessionStore.get(sessionId);
|
|
93
|
+
if (!existing) {
|
|
94
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
95
|
+
}
|
|
96
|
+
if (existing.level !== level) {
|
|
97
|
+
throw new Error(`Session level mismatch: requested ${level}, existing ${existing.level}`);
|
|
98
|
+
}
|
|
99
|
+
if (targetThoughts !== undefined &&
|
|
100
|
+
targetThoughts !== existing.totalThoughts) {
|
|
101
|
+
throw new Error(`targetThoughts must be ${String(existing.totalThoughts)} for the existing session`);
|
|
102
|
+
}
|
|
103
|
+
return existing;
|
|
104
|
+
}
|
|
105
|
+
const totalThoughts = resolveThoughtCount(level, query, config, targetThoughts);
|
|
106
|
+
const session = sessionStore.create(level, totalThoughts);
|
|
107
|
+
engineEvents.emit('session:created', {
|
|
108
|
+
sessionId: session.id,
|
|
109
|
+
level,
|
|
110
|
+
});
|
|
111
|
+
return session;
|
|
112
|
+
}
|
|
113
|
+
function resolveThoughtCount(level, query, config, targetThoughts) {
|
|
114
|
+
if (targetThoughts !== undefined) {
|
|
115
|
+
assertTargetThoughtsInRange(level, targetThoughts);
|
|
116
|
+
return targetThoughts;
|
|
117
|
+
}
|
|
118
|
+
if (config.minThoughts === config.maxThoughts) {
|
|
119
|
+
return config.minThoughts;
|
|
120
|
+
}
|
|
121
|
+
const queryText = query.trim();
|
|
122
|
+
const span = config.maxThoughts - config.minThoughts;
|
|
123
|
+
const queryByteLength = Buffer.byteLength(queryText, 'utf8');
|
|
124
|
+
const lengthScore = Math.min(1, queryByteLength / 400);
|
|
125
|
+
const structureScore = Math.min(0.4, getStructureDensityScore(queryText));
|
|
126
|
+
const keywordScore = /\b(compare|analy[sz]e|trade[- ]?off|design|plan)\b/i.test(queryText)
|
|
127
|
+
? 0.15
|
|
128
|
+
: 0;
|
|
129
|
+
const score = Math.min(1, lengthScore + structureScore + keywordScore);
|
|
130
|
+
return config.minThoughts + Math.round(span * score);
|
|
131
|
+
}
|
|
132
|
+
function countSentences(queryText) {
|
|
133
|
+
if (!sentenceSegmenter) {
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
let count = 0;
|
|
137
|
+
for (const sentence of sentenceSegmenter.segment(queryText)) {
|
|
138
|
+
if (sentence.segment.trim().length > 0) {
|
|
139
|
+
count++;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return count;
|
|
143
|
+
}
|
|
144
|
+
function getStructureDensityScore(queryText) {
|
|
145
|
+
const sentenceCount = countSentences(queryText);
|
|
146
|
+
if (sentenceCount > 1) {
|
|
147
|
+
return (sentenceCount - 1) * 0.08;
|
|
148
|
+
}
|
|
149
|
+
const markerMatches = queryText.match(/[?:;,\n]/g)?.length ?? 0;
|
|
150
|
+
return markerMatches * 0.05;
|
|
151
|
+
}
|
|
152
|
+
function throwIfReasoningAborted(signal) {
|
|
153
|
+
if (!signal) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
signal.throwIfAborted();
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
throw new Error('Reasoning aborted');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const OPENING_TEMPLATE = 'Parsing the query and identifying the core problem';
|
|
164
|
+
const MIDDLE_TEMPLATES = [
|
|
165
|
+
'Identifying key components and constraints',
|
|
166
|
+
'Breaking down the problem into sub-problems',
|
|
167
|
+
'Mapping relationships between identified components',
|
|
168
|
+
'Considering edge cases and boundary conditions',
|
|
169
|
+
'Surveying the problem space for hidden assumptions',
|
|
170
|
+
'Clarifying ambiguous terms and scoping the question',
|
|
171
|
+
'Evaluating potential approaches and methodologies',
|
|
172
|
+
'Selecting the most promising approach based on trade-offs',
|
|
173
|
+
'Developing the solution framework step by step',
|
|
174
|
+
'Checking logical consistency of intermediate conclusions',
|
|
175
|
+
'Exploring alternative perspectives on the problem',
|
|
176
|
+
'Assessing confidence levels in preliminary findings',
|
|
177
|
+
'Identifying assumptions that require verification',
|
|
178
|
+
'Weighing trade-offs between competing solutions',
|
|
179
|
+
'Testing preliminary results against known constraints',
|
|
180
|
+
'Examining second-order effects and implications',
|
|
181
|
+
'Synthesizing findings from multiple angles of analysis',
|
|
182
|
+
'Cross-referencing conclusions with initial premises',
|
|
183
|
+
'Refining the analysis with additional considerations',
|
|
184
|
+
'Validating the complete reasoning chain for coherence',
|
|
185
|
+
'Optimizing the reasoning path for gaps or redundancies',
|
|
186
|
+
'Reviewing the logical flow from premises to conclusion',
|
|
187
|
+
'Documenting key insights and decision points',
|
|
188
|
+
];
|
|
189
|
+
const CONCLUSION_TEMPLATE = 'Consolidating the final answer with supporting evidence';
|
|
190
|
+
function generateReasoningStep(query, index, total) {
|
|
191
|
+
if (total <= 0) {
|
|
192
|
+
return '';
|
|
193
|
+
}
|
|
194
|
+
const step = index + 1;
|
|
195
|
+
if (step === 1) {
|
|
196
|
+
const truncatedQuery = truncate(query, 200, graphemeSegmenter);
|
|
197
|
+
return formatStep(step, total, `${OPENING_TEMPLATE}: "${truncatedQuery}"`);
|
|
198
|
+
}
|
|
199
|
+
if (step === total) {
|
|
200
|
+
return formatStep(step, total, CONCLUSION_TEMPLATE);
|
|
201
|
+
}
|
|
202
|
+
const template = MIDDLE_TEMPLATES[(step - 2) % MIDDLE_TEMPLATES.length] ?? '';
|
|
203
|
+
return formatStep(step, total, template);
|
|
204
|
+
}
|
|
205
|
+
function formatStep(step, total, description) {
|
|
206
|
+
return `Step ${String(step)}/${String(total)}: ${description}`;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=reasoner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoner.js","sourceRoot":"","sources":["../../src/engine/reasoner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CA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,EAAE,KAAK,EAAE,GAAG,gBAAgB,MAAM,cAAc,GAAG,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9E,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAAa,EAAE,WAAmB;IAClE,OAAO,QAAQ,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReasoningLevel, Session, Thought } from '../lib/types.js';
|
|
2
|
+
export declare class SessionStore {
|
|
3
|
+
private readonly sessions;
|
|
4
|
+
private readonly cleanupInterval;
|
|
5
|
+
private readonly ttlMs;
|
|
6
|
+
constructor(ttlMs?: number);
|
|
7
|
+
create(level: ReasoningLevel, totalThoughts: number): Session;
|
|
8
|
+
get(id: string): Readonly<Session> | undefined;
|
|
9
|
+
list(): Session[];
|
|
10
|
+
getTtlMs(): number;
|
|
11
|
+
getExpiresAt(sessionId: string): number | undefined;
|
|
12
|
+
delete(id: string): boolean;
|
|
13
|
+
addThought(sessionId: string, content: string): Thought;
|
|
14
|
+
reviseThought(sessionId: string, thoughtIndex: number, content: string): Thought;
|
|
15
|
+
private sweep;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../src/engine/session-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,cAAc,EACd,OAAO,EACP,OAAO,EACR,MAAM,iBAAiB,CAAC;AAYzB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,KAAK,GAAE,MAAuB;IAS1C,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO;IAkB7D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS;IAI9C,IAAI,IAAI,OAAO,EAAE;IAMjB,QAAQ,IAAI,MAAM;IAIlB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQnD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAS3B,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAmBvD,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,OAAO;IA2BV,OAAO,CAAC,KAAK;CAcd"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { LEVEL_CONFIGS } from './config.js';
|
|
4
|
+
import { engineEvents } from './events.js';
|
|
5
|
+
const DEFAULT_TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
6
|
+
function estimateTokens(text) {
|
|
7
|
+
const byteLength = Buffer.byteLength(text, 'utf8');
|
|
8
|
+
return Math.max(1, Math.ceil(byteLength / 4));
|
|
9
|
+
}
|
|
10
|
+
export class SessionStore {
|
|
11
|
+
sessions = new Map();
|
|
12
|
+
cleanupInterval;
|
|
13
|
+
ttlMs;
|
|
14
|
+
constructor(ttlMs = DEFAULT_TTL_MS) {
|
|
15
|
+
this.ttlMs = ttlMs;
|
|
16
|
+
const sweepInterval = Math.max(10, Math.min(60_000, ttlMs));
|
|
17
|
+
this.cleanupInterval = setInterval(() => {
|
|
18
|
+
this.sweep();
|
|
19
|
+
}, sweepInterval);
|
|
20
|
+
this.cleanupInterval.unref();
|
|
21
|
+
}
|
|
22
|
+
create(level, totalThoughts) {
|
|
23
|
+
const config = LEVEL_CONFIGS[level];
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
const session = {
|
|
26
|
+
id: randomUUID(),
|
|
27
|
+
level,
|
|
28
|
+
thoughts: [],
|
|
29
|
+
totalThoughts,
|
|
30
|
+
tokenBudget: config.tokenBudget,
|
|
31
|
+
tokensUsed: 0,
|
|
32
|
+
createdAt: now,
|
|
33
|
+
updatedAt: now,
|
|
34
|
+
};
|
|
35
|
+
this.sessions.set(session.id, session);
|
|
36
|
+
engineEvents.emit('resources:changed', { uri: 'reasoning://sessions' });
|
|
37
|
+
return session;
|
|
38
|
+
}
|
|
39
|
+
get(id) {
|
|
40
|
+
return this.sessions.get(id);
|
|
41
|
+
}
|
|
42
|
+
list() {
|
|
43
|
+
return [...this.sessions.values()].sort((a, b) => b.updatedAt - a.updatedAt);
|
|
44
|
+
}
|
|
45
|
+
getTtlMs() {
|
|
46
|
+
return this.ttlMs;
|
|
47
|
+
}
|
|
48
|
+
getExpiresAt(sessionId) {
|
|
49
|
+
const session = this.sessions.get(sessionId);
|
|
50
|
+
if (!session) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return session.updatedAt + this.ttlMs;
|
|
54
|
+
}
|
|
55
|
+
delete(id) {
|
|
56
|
+
const deleted = this.sessions.delete(id);
|
|
57
|
+
if (deleted) {
|
|
58
|
+
engineEvents.emit('session:deleted', { sessionId: id });
|
|
59
|
+
engineEvents.emit('resources:changed', { uri: 'reasoning://sessions' });
|
|
60
|
+
}
|
|
61
|
+
return deleted;
|
|
62
|
+
}
|
|
63
|
+
addThought(sessionId, content) {
|
|
64
|
+
const session = this.sessions.get(sessionId);
|
|
65
|
+
if (!session) {
|
|
66
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
67
|
+
}
|
|
68
|
+
const thought = {
|
|
69
|
+
index: session.thoughts.length,
|
|
70
|
+
content,
|
|
71
|
+
revision: 0,
|
|
72
|
+
};
|
|
73
|
+
session.thoughts.push(thought);
|
|
74
|
+
session.tokensUsed += estimateTokens(content);
|
|
75
|
+
session.updatedAt = Date.now();
|
|
76
|
+
engineEvents.emit('resource:updated', {
|
|
77
|
+
uri: `reasoning://sessions/${sessionId}`,
|
|
78
|
+
});
|
|
79
|
+
return thought;
|
|
80
|
+
}
|
|
81
|
+
reviseThought(sessionId, thoughtIndex, content) {
|
|
82
|
+
const session = this.sessions.get(sessionId);
|
|
83
|
+
if (!session) {
|
|
84
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
85
|
+
}
|
|
86
|
+
const existing = session.thoughts[thoughtIndex];
|
|
87
|
+
if (!existing) {
|
|
88
|
+
throw new Error(`Thought index ${String(thoughtIndex)} not found in session ${sessionId}`);
|
|
89
|
+
}
|
|
90
|
+
const oldTokens = estimateTokens(existing.content);
|
|
91
|
+
const revised = {
|
|
92
|
+
index: thoughtIndex,
|
|
93
|
+
content,
|
|
94
|
+
revision: existing.revision + 1,
|
|
95
|
+
};
|
|
96
|
+
session.thoughts[thoughtIndex] = revised;
|
|
97
|
+
session.tokensUsed =
|
|
98
|
+
session.tokensUsed - oldTokens + estimateTokens(content);
|
|
99
|
+
session.updatedAt = Date.now();
|
|
100
|
+
engineEvents.emit('resource:updated', {
|
|
101
|
+
uri: `reasoning://sessions/${sessionId}`,
|
|
102
|
+
});
|
|
103
|
+
return revised;
|
|
104
|
+
}
|
|
105
|
+
sweep() {
|
|
106
|
+
const now = Date.now();
|
|
107
|
+
let changed = false;
|
|
108
|
+
for (const session of this.sessions.values()) {
|
|
109
|
+
if (session.updatedAt + this.ttlMs < now) {
|
|
110
|
+
this.sessions.delete(session.id);
|
|
111
|
+
engineEvents.emit('session:expired', { sessionId: session.id });
|
|
112
|
+
changed = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (changed) {
|
|
116
|
+
engineEvents.emit('resources:changed', { uri: 'reasoning://sessions' });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=session-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.js","sourceRoot":"","sources":["../../src/engine/session-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAEpD,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,OAAO,YAAY;IACN,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IACtC,eAAe,CAAiB;IAChC,KAAK,CAAS;IAE/B,YAAY,QAAgB,cAAc;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACtC,IAAI,CAAC,KAA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EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;gBAChE,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;QACH,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,GAAG,EAAE,sBAAsB,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { isMainThread, threadId } from 'node:worker_threads';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { createServer } from './server.js';
|
|
5
|
+
let activeServer;
|
|
6
|
+
let shutdownPromise;
|
|
7
|
+
function assertMainThread() {
|
|
8
|
+
if (isMainThread) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`cortex-mcp must run on the main thread (received worker thread ${String(threadId)}).`);
|
|
12
|
+
}
|
|
13
|
+
async function main() {
|
|
14
|
+
assertMainThread();
|
|
15
|
+
activeServer = createServer();
|
|
16
|
+
const transport = new StdioServerTransport();
|
|
17
|
+
await activeServer.connect(transport);
|
|
18
|
+
}
|
|
19
|
+
async function shutdown(exitCode, reason) {
|
|
20
|
+
if (shutdownPromise) {
|
|
21
|
+
return shutdownPromise;
|
|
22
|
+
}
|
|
23
|
+
shutdownPromise = (async () => {
|
|
24
|
+
let resolvedCode = exitCode;
|
|
25
|
+
try {
|
|
26
|
+
await activeServer?.close();
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
resolvedCode = 1;
|
|
30
|
+
console.error(`Shutdown failure (${reason}):`, err);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
process.exit(resolvedCode);
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
return shutdownPromise;
|
|
37
|
+
}
|
|
38
|
+
main().catch((err) => {
|
|
39
|
+
console.error('Fatal error:', err);
|
|
40
|
+
void shutdown(1, 'fatal error');
|
|
41
|
+
});
|
|
42
|
+
process.once('SIGTERM', () => {
|
|
43
|
+
void shutdown(0, 'SIGTERM');
|
|
44
|
+
});
|
|
45
|
+
process.once('SIGINT', () => {
|
|
46
|
+
void shutdown(0, 'SIGINT');
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,IAAI,YAAyD,CAAC;AAC9D,IAAI,eAA0C,CAAC;AAE/C,SAAS,gBAAgB;IACvB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,IAAI,KAAK,CACb,kEAAkE,MAAM,CAAC,QAAQ,CAAC,IAAI,CACvF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,gBAAgB,EAAE,CAAC;IACnB,YAAY,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,MAAc;IACtD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,eAAe,GAAG,CAAC,KAAK,IAAI,EAAE;QAC5B,IAAI,YAAY,GAAG,QAAQ,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,YAAY,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAY,GAAG,CAAC,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,qBAAqB,MAAM,IAAI,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,KAAK,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IAC3B,KAAK,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;IAC1B,KAAK,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# CORTEX-MCP INSTRUCTIONS
|
|
2
|
+
|
|
3
|
+
These instructions are available as a resource (internal://instructions) or prompt (get-help). Load them when unsure about tool usage.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## CORE CAPABILITY
|
|
8
|
+
|
|
9
|
+
- Domain: Multi-level reasoning engine that decomposes queries into structured thought chains at configurable depth levels (basic, normal, high).
|
|
10
|
+
- Primary Resources: Reasoning sessions (in-memory, 30-minute TTL), thought chains, progress notifications.
|
|
11
|
+
- Tools: `reasoning.think` (WRITE — creates/extends sessions with generated thoughts).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## PROMPTS
|
|
16
|
+
|
|
17
|
+
- `get-help`: Returns these instructions for quick recall.
|
|
18
|
+
- `reasoning.basic`: Prepare a basic-depth reasoning request (3–5 thoughts).
|
|
19
|
+
- `reasoning.normal`: Prepare a normal-depth reasoning request (6–10 thoughts).
|
|
20
|
+
- `reasoning.high`: Prepare a high-depth reasoning request (15–25 thoughts).
|
|
21
|
+
- `reasoning.continue`: Continue an existing reasoning session with a follow-up query.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## RESOURCES & RESOURCE LINKS
|
|
26
|
+
|
|
27
|
+
- `internal://instructions`: This document.
|
|
28
|
+
- `reasoning://sessions`: List all active reasoning sessions with metadata (JSON).
|
|
29
|
+
- `reasoning://sessions/{sessionId}`: Inspect a specific session's thoughts and metadata (JSON). Supports auto-completion on `sessionId`.
|
|
30
|
+
|
|
31
|
+
### Resource Subscriptions
|
|
32
|
+
|
|
33
|
+
- The server supports `resources/subscribe` for real-time change notifications on individual resources.
|
|
34
|
+
- Subscribe to `reasoning://sessions/{sessionId}` to receive `notifications/resources/updated` when thoughts are added or revised.
|
|
35
|
+
- Use subscriptions to monitor session progress without polling.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## PROGRESS & TASKS
|
|
40
|
+
|
|
41
|
+
- Include `_meta.progressToken` in requests to receive `notifications/progress` updates during reasoning.
|
|
42
|
+
- Task-augmented tool calls are supported for `reasoning.think`:
|
|
43
|
+
- `execution.taskSupport: "optional"` — invoke normally or as a task.
|
|
44
|
+
- Send `tools/call` with `task` to get a task id.
|
|
45
|
+
- Poll `tasks/get` and fetch results via `tasks/result`.
|
|
46
|
+
- Use `tasks/cancel` to abort a running task.
|
|
47
|
+
- For `high` level, progress is emitted every 2 steps to reduce noise; `basic` and `normal` emit after every step.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## THE "GOLDEN PATH" WORKFLOWS (CRITICAL)
|
|
52
|
+
|
|
53
|
+
### WORKFLOW A: Sequential Reasoning
|
|
54
|
+
|
|
55
|
+
1. Call `reasoning.think` with `{ query: "...", level: "basic" | "normal" | "high" }`.
|
|
56
|
+
2. Read `result.thoughts` for the accumulated reasoning chain (each call appends at most one new thought).
|
|
57
|
+
3. Repeat calls with the same `sessionId` until `result.totalThoughts` is reached.
|
|
58
|
+
NOTE: Choose level based on query complexity — `basic` for straightforward questions, `high` for multi-faceted analysis.
|
|
59
|
+
|
|
60
|
+
### WORKFLOW B: Multi-Turn Reasoning (Session Continuation)
|
|
61
|
+
|
|
62
|
+
1. Call `reasoning.think` with `{ query: "initial question", level: "normal" }` — note the returned `sessionId`.
|
|
63
|
+
2. Call `reasoning.think` with `{ query: "follow-up", level: "normal", sessionId: "<id>" }` to append the next thought.
|
|
64
|
+
3. Repeat until `result.totalThoughts` is reached, then read `reasoning://sessions/{sessionId}` for the full chain.
|
|
65
|
+
NOTE: The `level` MUST match the original session level. Mismatches return `E_SESSION_LEVEL_MISMATCH`.
|
|
66
|
+
|
|
67
|
+
### WORKFLOW C: Controlled Depth Reasoning
|
|
68
|
+
|
|
69
|
+
1. Call `reasoning.think` with `{ query: "...", level: "normal", targetThoughts: 8 }` to set the session's planned step count.
|
|
70
|
+
2. Repeat calls with the returned `sessionId` until `result.totalThoughts` is reached.
|
|
71
|
+
NOTE: `targetThoughts` must fall within the level range (basic: 3–5, normal: 6–10, high: 15–25). Out-of-range values return `E_INVALID_THOUGHT_COUNT`.
|
|
72
|
+
|
|
73
|
+
### WORKFLOW D: Async Task Execution
|
|
74
|
+
|
|
75
|
+
1. Call `reasoning.think` as a task (send `tools/call` with `task` field) for long-running `high`-level reasoning.
|
|
76
|
+
2. Poll `tasks/get` until status is `completed` or `failed`.
|
|
77
|
+
3. Retrieve the result via `tasks/result`.
|
|
78
|
+
4. Use `tasks/cancel` to abort if needed.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## TOOL NUANCES & GOTCHAS
|
|
83
|
+
|
|
84
|
+
`reasoning.think`
|
|
85
|
+
|
|
86
|
+
- Purpose: Generate a multi-step reasoning chain for a given query at a specified depth level.
|
|
87
|
+
- Input:
|
|
88
|
+
- `query` (string, 1–10,000 chars): The question or problem to reason about.
|
|
89
|
+
- `level` (enum: `basic` | `normal` | `high`): Controls reasoning depth and token budget.
|
|
90
|
+
- `targetThoughts` (int, 1–25, optional): Override automatic step count. Must fit within the level range.
|
|
91
|
+
- `sessionId` (string, 1–128 chars, optional): Continue an existing session. Level must match.
|
|
92
|
+
- Output: `{ ok, result: { sessionId, level, thoughts[], generatedThoughts, requestedThoughts, totalThoughts, tokenBudget, tokensUsed, ttlMs, expiresAt, createdAt, updatedAt, summary } }`
|
|
93
|
+
- Side effects: Creates or modifies an in-memory session. Sessions expire after 30 minutes of inactivity.
|
|
94
|
+
- Gotcha: Each call appends at most one thought. When continuing a session, `generatedThoughts` reflects only the newly added thought (0 or 1), not the cumulative total.
|
|
95
|
+
- Gotcha: `requestedThoughts` is the effective requested count for this run: it equals `targetThoughts` when provided, otherwise `totalThoughts`.
|
|
96
|
+
- Gotcha: Token counting is approximate (UTF-8 byte length ÷ 4), not true tokenization.
|
|
97
|
+
- Gotcha: Without `targetThoughts`, the planned step count (`totalThoughts`) is determined by a heuristic based on query length and structural complexity (punctuation markers, keywords like "compare", "analyse", "trade-off").
|
|
98
|
+
- Limits: Level ranges — basic: 3–5 thoughts (2K token budget), normal: 6–10 (8K), high: 15–25 (32K).
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## CROSS-FEATURE RELATIONSHIPS
|
|
103
|
+
|
|
104
|
+
- Use `reasoning.basic` / `reasoning.normal` / `reasoning.high` prompts to construct a correctly parameterized `reasoning.think` call.
|
|
105
|
+
- Use `reasoning.continue` prompt to construct a session-continuation call — it enforces `sessionId` and `level` pairing.
|
|
106
|
+
- After calling `reasoning.think`, read `reasoning://sessions/{sessionId}` to retrieve the full session state including all accumulated thoughts.
|
|
107
|
+
- Use `reasoning://sessions` to discover active sessions before attempting continuation — avoids `E_SESSION_NOT_FOUND`.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## CONSTRAINTS & LIMITATIONS
|
|
112
|
+
|
|
113
|
+
- Sessions are in-memory — all data is lost on process restart.
|
|
114
|
+
- Session TTL: 30 minutes from last update. Expired sessions cannot be recovered.
|
|
115
|
+
- Maximum query length: 10,000 characters.
|
|
116
|
+
- Token budget enforcement is approximate (character-based proxy, not true tokenization).
|
|
117
|
+
- stdio transport only — no HTTP endpoint available.
|
|
118
|
+
- Reasoning steps are structural decompositions, not LLM-generated content.
|
|
119
|
+
- `targetThoughts` must be an integer within the level's min/max range.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## ERROR HANDLING STRATEGY
|
|
124
|
+
|
|
125
|
+
- `E_SESSION_NOT_FOUND`: Session expired or never existed. Call `reasoning://sessions` to list active sessions, or start a new session without `sessionId`.
|
|
126
|
+
- `E_SESSION_LEVEL_MISMATCH`: Requested level differs from the existing session. Use the same level as the original session, or start a new session.
|
|
127
|
+
- `E_INVALID_THOUGHT_COUNT`: `targetThoughts` is outside the level range. Check ranges: basic (3–5), normal (6–10), high (15–25).
|
|
128
|
+
- `E_ABORTED`: Reasoning was cancelled via abort signal or task cancellation. Retry with a new request if needed.
|
|
129
|
+
- `E_REASONING`: Unexpected engine error. Check the error `message` field for details and retry.
|
|
130
|
+
|
|
131
|
+
---
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ErrorResponse {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
content: {
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
structuredContent: {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: {
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
isError: true;
|
|
15
|
+
}
|
|
16
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
17
|
+
export declare function createErrorResponse(code: string, message: string): ErrorResponse;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAOA,UAAU,aAAa;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,iBAAiB,EAAE;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC3E,OAAO,EAAE,IAAI,CAAC;CACf;AAWD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBtD;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,aAAa,CAOf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
const INSPECT_OPTIONS = {
|
|
3
|
+
depth: 3,
|
|
4
|
+
breakLength: 120,
|
|
5
|
+
};
|
|
6
|
+
function stringifyUnknown(value) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.stringify(value);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
// Fall through to inspect-based serialization.
|
|
12
|
+
}
|
|
13
|
+
return inspect(value, INSPECT_OPTIONS);
|
|
14
|
+
}
|
|
15
|
+
export function getErrorMessage(error) {
|
|
16
|
+
if (typeof error === 'string') {
|
|
17
|
+
return error;
|
|
18
|
+
}
|
|
19
|
+
if (error instanceof Error) {
|
|
20
|
+
return error.message;
|
|
21
|
+
}
|
|
22
|
+
if (error === null || error === undefined) {
|
|
23
|
+
return 'Unknown error';
|
|
24
|
+
}
|
|
25
|
+
if (typeof error === 'object') {
|
|
26
|
+
const maybeError = error;
|
|
27
|
+
if (typeof maybeError.message === 'string') {
|
|
28
|
+
return maybeError.message;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return stringifyUnknown(error);
|
|
32
|
+
}
|
|
33
|
+
export function createErrorResponse(code, message) {
|
|
34
|
+
const structured = { ok: false, error: { code, message } };
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: JSON.stringify(structured) }],
|
|
37
|
+
structuredContent: structured,
|
|
38
|
+
isError: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,GAAG;CACR,CAAC;AASX,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,+CAA+C;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAA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