@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.
Files changed (80) hide show
  1. package/README.md +269 -0
  2. package/dist/assets/logo.svg +49 -0
  3. package/dist/engine/config.d.ts +9 -0
  4. package/dist/engine/config.d.ts.map +1 -0
  5. package/dist/engine/config.js +26 -0
  6. package/dist/engine/config.js.map +1 -0
  7. package/dist/engine/context.d.ts +7 -0
  8. package/dist/engine/context.d.ts.map +1 -0
  9. package/dist/engine/context.js +6 -0
  10. package/dist/engine/context.js.map +1 -0
  11. package/dist/engine/events.d.ts +51 -0
  12. package/dist/engine/events.d.ts.map +1 -0
  13. package/dist/engine/events.js +9 -0
  14. package/dist/engine/events.js.map +1 -0
  15. package/dist/engine/index.d.ts +6 -0
  16. package/dist/engine/index.d.ts.map +1 -0
  17. package/dist/engine/index.js +6 -0
  18. package/dist/engine/index.js.map +1 -0
  19. package/dist/engine/reasoner.d.ts +12 -0
  20. package/dist/engine/reasoner.d.ts.map +1 -0
  21. package/dist/engine/reasoner.js +208 -0
  22. package/dist/engine/reasoner.js.map +1 -0
  23. package/dist/engine/session-store.d.ts +17 -0
  24. package/dist/engine/session-store.d.ts.map +1 -0
  25. package/dist/engine/session-store.js +120 -0
  26. package/dist/engine/session-store.js.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +48 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/instructions.md +131 -0
  32. package/dist/lib/errors.d.ts +19 -0
  33. package/dist/lib/errors.d.ts.map +1 -0
  34. package/dist/lib/errors.js +41 -0
  35. package/dist/lib/errors.js.map +1 -0
  36. package/dist/lib/instructions.d.ts +5 -0
  37. package/dist/lib/instructions.d.ts.map +1 -0
  38. package/dist/lib/instructions.js +14 -0
  39. package/dist/lib/instructions.js.map +1 -0
  40. package/dist/lib/text.d.ts +20 -0
  41. package/dist/lib/text.d.ts.map +1 -0
  42. package/dist/lib/text.js +74 -0
  43. package/dist/lib/text.js.map +1 -0
  44. package/dist/lib/tool-response.d.ts +6 -0
  45. package/dist/lib/tool-response.d.ts.map +1 -0
  46. package/dist/lib/tool-response.js +13 -0
  47. package/dist/lib/tool-response.js.map +1 -0
  48. package/dist/lib/types.d.ts +27 -0
  49. package/dist/lib/types.d.ts.map +1 -0
  50. package/dist/lib/types.js +2 -0
  51. package/dist/lib/types.js.map +1 -0
  52. package/dist/prompts/index.d.ts +4 -0
  53. package/dist/prompts/index.d.ts.map +1 -0
  54. package/dist/prompts/index.js +156 -0
  55. package/dist/prompts/index.js.map +1 -0
  56. package/dist/resources/index.d.ts +4 -0
  57. package/dist/resources/index.d.ts.map +1 -0
  58. package/dist/resources/index.js +248 -0
  59. package/dist/resources/index.js.map +1 -0
  60. package/dist/schemas/inputs.d.ts +13 -0
  61. package/dist/schemas/inputs.d.ts.map +1 -0
  62. package/dist/schemas/inputs.js +39 -0
  63. package/dist/schemas/inputs.js.map +1 -0
  64. package/dist/schemas/outputs.d.ts +76 -0
  65. package/dist/schemas/outputs.d.ts.map +1 -0
  66. package/dist/schemas/outputs.js +59 -0
  67. package/dist/schemas/outputs.js.map +1 -0
  68. package/dist/server.d.ts +3 -0
  69. package/dist/server.d.ts.map +1 -0
  70. package/dist/server.js +169 -0
  71. package/dist/server.js.map +1 -0
  72. package/dist/tools/index.d.ts +7 -0
  73. package/dist/tools/index.d.ts.map +1 -0
  74. package/dist/tools/index.js +8 -0
  75. package/dist/tools/index.js.map +1 -0
  76. package/dist/tools/reasoning-think.d.ts +9 -0
  77. package/dist/tools/reasoning-think.d.ts.map +1 -0
  78. package/dist/tools/reasoning-think.js +298 -0
  79. package/dist/tools/reasoning-think.js.map +1 -0
  80. package/package.json +75 -0
package/README.md ADDED
@@ -0,0 +1,269 @@
1
+ # Cortex MCP
2
+
3
+ [![npm version](https://img.shields.io/npm/v/cortex-mcp?style=flat-square)](https://www.npmjs.com/package/cortex-mcp) [![Generic badge](https://img.shields.io/badge/Node.js->=24-3c873a?style=flat-square)](https://nodejs.org) [![Generic badge](https://img.shields.io/badge/TypeScript-5.9+-3178c6?style=flat-square)](https://www.typescriptlang.org) [![Generic badge](https://img.shields.io/badge/MCP_SDK-1.26+-ff6600?style=flat-square)](https://modelcontextprotocol.io) [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
4
+
5
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](vscode:mcp/install?config=%7B%22name%22%3A%22cortex-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cortex-mcp%40latest%22%5D%7D) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](vscode-insiders:mcp/install?config=%7B%22name%22%3A%22cortex-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cortex-mcp%40latest%22%5D%7D) [![Install in Cursor](https://img.shields.io/badge/Cursor-Install-000000?style=flat-square&logo=cursor&logoColor=white)](https://cursor.com/install-mcp?name=cortex-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNvcnRleC1tY3BAbGF0ZXN0Il19)
6
+
7
+ Multi-level reasoning MCP server with configurable depth levels.
8
+
9
+ ## Overview
10
+
11
+ Cortex MCP is a reasoning engine that exposes a `reasoning.think` tool to perform multi-step analysis on complex queries. It supports three configurable depth levels (Basic, Normal, High), maintains session state for follow-up questions, and offers asynchronous task execution for long-running reasoning processes. All reasoning happens locally in-memory.
12
+
13
+ ## Key Features
14
+
15
+ - **Multi-Level Reasoning**: Three distinct depth levels (`basic`, `normal`, `high`) with varying token budgets and thought counts.
16
+ - **Session Continuity**: Resume reasoning sessions by ID to maintain context across multiple turns.
17
+ - **Async Task Support**: Execute long-running reasoning as a background task with progress notifications.
18
+ - **Event-Driven Architecture**: Internal event emitter orchestrates session lifecycle and resource updates.
19
+ - **Real-time Resources**: Inspect active sessions and individual thought traces via MCP resources.
20
+ - **Strict Validation**: Zod-based schemas ensure type safety for all inputs and outputs.
21
+
22
+ ## Tech Stack
23
+
24
+ - **Runtime**: Node.js >= 24
25
+ - **Language**: TypeScript 5.9+
26
+ - **MCP SDK**: `@modelcontextprotocol/sdk` ^1.26.0
27
+ - **Validation**: `zod` ^4.3.6
28
+ - **Testing**: `node:test` (Native)
29
+ - **Package Manager**: npm
30
+
31
+ ## Architecture
32
+
33
+ 1. **Transport**: Receives JSON-RPC messages via `stdio`.
34
+ 2. **Tool Handler**: `reasoning.think` validates input and initiates the reasoning planner.
35
+ 3. **Engine**: The `reasoner` orchestrates thoughts based on the selected `level` configuration.
36
+ 4. **State**: Sessions are stored in an in-memory `SessionStore` (LRU/TTL based).
37
+ 5. **Resources**: Dynamic resource endpoints expose session data and markdown traces.
38
+
39
+ ## Repository Structure
40
+
41
+ ```
42
+ cortex-mcp/
43
+ ├── src/
44
+ │ ├── index.ts # CLI entry point (stdio transport)
45
+ │ ├── server.ts # Server factory & setup
46
+ │ ├── engine/ # Reasoning logic and session store
47
+ │ ├── tools/ # Tool implementations (reasoning.think)
48
+ │ ├── resources/ # Resource endpoints
49
+ │ ├── prompts/ # Prompt templates
50
+ │ ├── schemas/ # Zod schemas (inputs/outputs)
51
+ │ └── lib/ # Utilities and types
52
+ ├── scripts/ # Build and task runners
53
+ ├── package.json
54
+ └── tsconfig.json
55
+ ```
56
+
57
+ ## Requirements
58
+
59
+ - **Node.js**: >= 24
60
+
61
+ ## Quickstart
62
+
63
+ Use `npx` to run the server directly without installation:
64
+
65
+ ```bash
66
+ npx -y cortex-mcp@latest
67
+ ```
68
+
69
+ ## Installation
70
+
71
+ ### NPX (Recommended)
72
+
73
+ ```bash
74
+ npx -y cortex-mcp@latest
75
+ ```
76
+
77
+ ### From Source
78
+
79
+ ```bash
80
+ git clone https://github.com/j0hanz/cortex-mcp.git
81
+ cd cortex-mcp
82
+ npm install
83
+ npm run build
84
+ node dist/index.js
85
+ ```
86
+
87
+ ## Configuration
88
+
89
+ ### Environment Variables
90
+
91
+ No environment variables are strictly required for basic operation.
92
+
93
+ ### Runtime Levels
94
+
95
+ The server is configured with the following reasoning levels (defined in `src/engine/config.ts`):
96
+
97
+ | Level | Token Budget | Thoughts Range |
98
+ | :------- | :----------- | :------------- |
99
+ | `basic` | 2,048 | 3–5 |
100
+ | `normal` | 8,192 | 6–10 |
101
+ | `high` | 32,768 | 15–25 |
102
+
103
+ ## Usage
104
+
105
+ Configure your MCP client to start the server via stdio.
106
+
107
+ ### Stdio Transport
108
+
109
+ Run the server process directly. Messages are sent over `stdin` and `stdout`.
110
+
111
+ ## MCP Surface
112
+
113
+ ### Tools
114
+
115
+ #### `reasoning.think`
116
+
117
+ Perform multi-level reasoning on a query.
118
+
119
+ | Parameter | Type | Required | Default | Description |
120
+ | :--------------- | :----- | :------- | :------ | :---------------------------------------------------------- |
121
+ | `query` | string | Yes | - | The question or problem to reason about (max 10,000 chars). |
122
+ | `level` | enum | Yes | - | Depth level: `basic`, `normal`, `high`. |
123
+ | `targetThoughts` | number | No | - | Optional exact step count (max 25). |
124
+ | `sessionId` | string | No | - | Session ID to continue a previous reasoning session. |
125
+
126
+ **Output Example**:
127
+
128
+ ```json
129
+ {
130
+ "ok": true,
131
+ "result": {
132
+ "sessionId": "uuid-v4...",
133
+ "level": "normal",
134
+ "thoughts": [{ "index": 0, "content": "...", "revision": 0 }],
135
+ "generatedThoughts": 1,
136
+ "totalThoughts": 1,
137
+ "tokenBudget": 8192
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### Resources
143
+
144
+ | URI Pattern | Description | MIME Type |
145
+ | :----------------------------------------------------- | :------------------------------------------------- | :----------------- |
146
+ | `internal://instructions` | Usage instructions for the MCP server. | `text/markdown` |
147
+ | `reasoning://sessions` | List of active reasoning sessions. | `application/json` |
148
+ | `reasoning://sessions/{sessionId}` | Detailed view of a reasoning session. | `application/json` |
149
+ | `file:///cortex/sessions/{sessionId}/trace.md` | Full Markdown trace of a session. | `text/markdown` |
150
+ | `file:///cortex/sessions/{sessionId}/{thoughtName}.md` | Content of a single thought (e.g. `Thought-1.md`). | `text/markdown` |
151
+
152
+ ### Prompts
153
+
154
+ | Name | Arguments | Description |
155
+ | :------------------- | :--------------------------------- | :-------------------------------------------- |
156
+ | `reasoning.basic` | `query`, `targetThoughts` | Prepare a basic-depth reasoning request. |
157
+ | `reasoning.normal` | `query`, `targetThoughts` | Prepare a normal-depth reasoning request. |
158
+ | `reasoning.high` | `query`, `targetThoughts` | Prepare a high-depth reasoning request. |
159
+ | `reasoning.retry` | `query`, `level`, `targetThoughts` | Retry a failed task with modified parameters. |
160
+ | `reasoning.continue` | `sessionId`, `query`, `level`, ... | Continue an existing session. |
161
+ | `get-help` | - | Return server usage instructions. |
162
+
163
+ ### Tasks
164
+
165
+ This server supports **async task execution** for `reasoning.think`.
166
+
167
+ - **Capability**: `execution: { taskSupport: 'optional' }`
168
+ - **Usage**: Clients can invoke the tool as a background task.
169
+ - **Monitoring**: Progress is reported via `notifications/progress` (on 'high' level, typically every 2 steps).
170
+
171
+ ## Client Configuration Examples
172
+
173
+ <details>
174
+ <summary><strong>VS Code</strong></summary>
175
+
176
+ Add to your `settings.json`:
177
+
178
+ ```json
179
+ {
180
+ "mcp": {
181
+ "servers": {
182
+ "cortex-mcp": {
183
+ "command": "npx",
184
+ "args": ["-y", "cortex-mcp@latest"]
185
+ }
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ </details>
192
+
193
+ <details>
194
+ <summary><strong>Claude Desktop</strong></summary>
195
+
196
+ Add to your `claude_desktop_config.json`:
197
+
198
+ ```json
199
+ {
200
+ "mcpServers": {
201
+ "cortex-mcp": {
202
+ "command": "npx",
203
+ "args": ["-y", "cortex-mcp@latest"]
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ </details>
210
+
211
+ <details>
212
+ <summary><strong>Cursor</strong></summary>
213
+
214
+ Add to your Cursor MCP settings:
215
+
216
+ ```json
217
+ {
218
+ "mcpServers": {
219
+ "cortex-mcp": {
220
+ "command": "npx",
221
+ "args": ["-y", "cortex-mcp@latest"]
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ </details>
228
+
229
+ ## Security
230
+
231
+ - **Stdio Isolation**: The server writes all logs to `stderr` to avoid corrupting the JSON-RPC stream on `stdout`.
232
+ - **Input Validation**: All tool inputs conform to strict Zod schemas with character limits (`max(10000)` for queries).
233
+ - **Filesystem**: No actual filesystem writes occur; "files" are exposed virtually via resources.
234
+
235
+ ## Development Workflow
236
+
237
+ 1. **Install dependencies**:
238
+
239
+ ```bash
240
+ npm install
241
+ ```
242
+
243
+ 2. **Scripts**:
244
+
245
+ | Script | Command | Purpose |
246
+ | :---------- | :----------------------------- | :------------------------------- |
247
+ | `build` | `node scripts/tasks.mjs build` | Clean, compile, and copy assets. |
248
+ | `dev` | `tsc --watch ...` | Watch mode compilation. |
249
+ | `dev:run` | `node --watch dist/index.js` | Run server with auto-restart. |
250
+ | `test` | `node scripts/tasks.mjs test` | Build and run tests. |
251
+ | `lint` | `eslint .` | Lint source files. |
252
+ | `inspector` | `npm run build && ...` | Launch MCP Inspector. |
253
+
254
+ ## Build and Release
255
+
256
+ The project uses a custom task runner (`scripts/tasks.mjs`) for build orchestration.
257
+
258
+ - **Build**: `npm run build` generates artifacts in `dist/`.
259
+ - **Publish**: `npm run prepublishOnly` ensures linting, type-checking, and building before publish.
260
+
261
+ ## Troubleshooting
262
+
263
+ - **No output**: The server uses `stdio`. Ensure your client is capturing `stdout` correctly. Check `stderr` for logs.
264
+ - **Inspector**: Run `npm run inspector` to debug tools and resources interactively.
265
+ - **Session not found**: Sessions are in-memory and expire locally (default TTL: 30 minutes).
266
+
267
+ ## License
268
+
269
+ MIT
@@ -0,0 +1,49 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="1.2" stroke-linecap="round"
2
+ stroke-linejoin="round" role="img" aria-label="brain">
3
+ <style>
4
+ path,
5
+ circle,
6
+ rect,
7
+ line,
8
+ polyline,
9
+ polygon {
10
+ stroke: #000000;
11
+ }
12
+
13
+ @media (prefers-color-scheme: dark) {
14
+
15
+ path,
16
+ circle,
17
+ rect,
18
+ line,
19
+ polyline,
20
+ polygon {
21
+ stroke: #FFFFFF;
22
+ }
23
+ }
24
+ </style>
25
+
26
+ <g>
27
+ <!-- Outer silhouette -->
28
+ <path d="M9 4.2c-2.2 0-4 1.7-4 4v1.1c-1 .6-1.7 1.7-1.7 3 0 1.6 1 2.9 2.4 3.3v.9c0 2.2 1.8 4 4 4h2.3" />
29
+ <path d="M15 4.2c2.2 0 4 1.7 4 4v1.1c1 .6 1.7 1.7 1.7 3 0 1.6-1 2.9-2.4 3.3v.9c0 2.2-1.8 4-4 4H12" />
30
+
31
+ ```
32
+ <!-- Midline split (subtle) -->
33
+ <path d="M12 5.1v15.1" />
34
+
35
+ <!-- Left hemisphere folds -->
36
+ <path d="M8.8 7c-1.2.1-2.2 1.1-2.2 2.4" />
37
+ <path d="M9.3 10.1c-1.4 0-2.6 1.1-2.6 2.6" />
38
+ <path d="M9.6 13.4c-1.2.2-2.1 1.2-2.1 2.5" />
39
+ <path d="M10.3 16.4c-1.1 0-2 .7-2.4 1.7" />
40
+
41
+ <!-- Right hemisphere folds -->
42
+ <path d="M15.2 7c1.2.1 2.2 1.1 2.2 2.4" />
43
+ <path d="M14.7 10.1c1.4 0 2.6 1.1 2.6 2.6" />
44
+ <path d="M14.4 13.4c1.2.2 2.1 1.2 2.1 2.5" />
45
+ <path d="M13.7 16.4c1.1 0 2 .7 2.4 1.7" />
46
+ ```
47
+
48
+ </g>
49
+ </svg>
@@ -0,0 +1,9 @@
1
+ import type { LevelConfig, ReasoningLevel } from '../lib/types.js';
2
+ export declare const LEVEL_CONFIGS: Record<ReasoningLevel, LevelConfig>;
3
+ export declare function getThoughtBounds(level: ReasoningLevel): {
4
+ minThoughts: number;
5
+ maxThoughts: number;
6
+ };
7
+ export declare function getTargetThoughtsError(level: ReasoningLevel, targetThoughts: number): string | undefined;
8
+ export declare function assertTargetThoughtsInRange(level: ReasoningLevel, targetThoughts: number): void;
9
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/engine/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,WAAW,CAI7D,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAGA;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,MAAM,GACrB,MAAM,GAAG,SAAS,CAWpB;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,MAAM,GACrB,IAAI,CAKN"}
@@ -0,0 +1,26 @@
1
+ export const LEVEL_CONFIGS = {
2
+ basic: { minThoughts: 3, maxThoughts: 5, tokenBudget: 2048 },
3
+ normal: { minThoughts: 6, maxThoughts: 10, tokenBudget: 8192 },
4
+ high: { minThoughts: 15, maxThoughts: 25, tokenBudget: 32768 },
5
+ };
6
+ export function getThoughtBounds(level) {
7
+ const { minThoughts, maxThoughts } = LEVEL_CONFIGS[level];
8
+ return { minThoughts, maxThoughts };
9
+ }
10
+ export function getTargetThoughtsError(level, targetThoughts) {
11
+ if (!Number.isInteger(targetThoughts)) {
12
+ return 'targetThoughts must be an integer';
13
+ }
14
+ const { minThoughts, maxThoughts } = getThoughtBounds(level);
15
+ if (targetThoughts < minThoughts || targetThoughts > maxThoughts) {
16
+ return `targetThoughts must be between ${String(minThoughts)} and ${String(maxThoughts)} for the selected level`;
17
+ }
18
+ return undefined;
19
+ }
20
+ export function assertTargetThoughtsInRange(level, targetThoughts) {
21
+ const error = getTargetThoughtsError(level, targetThoughts);
22
+ if (error) {
23
+ throw new Error(error);
24
+ }
25
+ }
26
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/engine/config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAwC;IAChE,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE;IAC5D,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IAC9D,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;CAC/D,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IAIpD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAqB,EACrB,cAAsB;IAEtB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;QACtC,OAAO,mCAAmC,CAAC;IAC7C,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,cAAc,GAAG,WAAW,IAAI,cAAc,GAAG,WAAW,EAAE,CAAC;QACjE,OAAO,kCAAkC,MAAM,CAAC,WAAW,CAAC,QAAQ,MAAM,CAAC,WAAW,CAAC,yBAAyB,CAAC;IACnH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,KAAqB,EACrB,cAAsB;IAEtB,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC5D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface EngineContext {
2
+ sessionId: string;
3
+ abortSignal?: AbortSignal;
4
+ }
5
+ export declare function runWithContext<T>(ctx: EngineContext, fn: () => T): T;
6
+ export {};
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/engine/context.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAID,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEpE"}
@@ -0,0 +1,6 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ const storage = new AsyncLocalStorage();
3
+ export function runWithContext(ctx, fn) {
4
+ return storage.run(ctx, fn);
5
+ }
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/engine/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAiB,CAAC;AAEvD,MAAM,UAAU,cAAc,CAAI,GAAkB,EAAE,EAAW;IAC/D,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import type { ReasoningLevel } from '../lib/types.js';
3
+ interface EngineEvents {
4
+ 'thought:added': [{
5
+ sessionId: string;
6
+ index: number;
7
+ content: string;
8
+ }];
9
+ 'thought:revised': [
10
+ {
11
+ sessionId: string;
12
+ index: number;
13
+ content: string;
14
+ revision: number;
15
+ }
16
+ ];
17
+ 'thought:budget-exhausted': [
18
+ {
19
+ sessionId: string;
20
+ tokensUsed: number;
21
+ tokenBudget: number;
22
+ generatedThoughts: number;
23
+ requestedThoughts: number;
24
+ }
25
+ ];
26
+ 'session:created': [{
27
+ sessionId: string;
28
+ level: ReasoningLevel;
29
+ }];
30
+ 'session:expired': [{
31
+ sessionId: string;
32
+ }];
33
+ 'session:deleted': [{
34
+ sessionId: string;
35
+ }];
36
+ 'resources:changed': [{
37
+ uri: string;
38
+ }];
39
+ 'resource:updated': [{
40
+ uri: string;
41
+ }];
42
+ error: [unknown];
43
+ }
44
+ interface TypedEmitter<T> extends Omit<EventEmitter, 'on' | 'off' | 'emit'> {
45
+ on<K extends keyof T>(event: K, listener: (...args: T[K] extends unknown[] ? T[K] : never) => void): this;
46
+ off<K extends keyof T>(event: K, listener: (...args: T[K] extends unknown[] ? T[K] : never) => void): this;
47
+ emit<K extends keyof T>(event: K, ...args: T[K] extends unknown[] ? T[K] : never): boolean;
48
+ }
49
+ export declare const engineEvents: TypedEmitter<EngineEvents>;
50
+ export {};
51
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,UAAU,YAAY;IACpB,eAAe,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzE,iBAAiB,EAAE;QACjB;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE;KACxE,CAAC;IACF,0BAA0B,EAAE;QAC1B;YACE,SAAS,EAAE,MAAM,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC;YAC1B,iBAAiB,EAAE,MAAM,CAAC;SAC3B;KACF,CAAC;IACF,iBAAiB,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;IAClE,iBAAiB,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C,iBAAiB,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C,mBAAmB,EAAE,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvC,kBAAkB,EAAE,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;CAClB;AAED,UAAU,YAAY,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IACzE,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAClB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,IAAI,GACjE,IAAI,CAAC;IACR,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EACnB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,IAAI,GACjE,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EACpB,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAC7C,OAAO,CAAC;CACZ;AAED,eAAO,MAAM,YAAY,EAEnB,YAAY,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { getErrorMessage } from '../lib/errors.js';
3
+ export const engineEvents = new EventEmitter({
4
+ captureRejections: true,
5
+ });
6
+ engineEvents.on('error', (err) => {
7
+ process.stderr.write(`[engine] ${getErrorMessage(err)}\n`);
8
+ });
9
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAwCnD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;IAC3C,iBAAiB,EAAE,IAAI;CACxB,CAA+B,CAAC;AAEjC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;IAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { LEVEL_CONFIGS } from './config.js';
2
+ export { runWithContext } from './context.js';
3
+ export { engineEvents } from './events.js';
4
+ export { reason, sessionStore } from './reasoner.js';
5
+ export { SessionStore } from './session-store.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { LEVEL_CONFIGS } from './config.js';
2
+ export { runWithContext } from './context.js';
3
+ export { engineEvents } from './events.js';
4
+ export { reason, sessionStore } from './reasoner.js';
5
+ export { SessionStore } from './session-store.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ReasoningLevel, Session } from '../lib/types.js';
2
+ import { SessionStore } from './session-store.js';
3
+ declare const sessionStore: SessionStore;
4
+ export { sessionStore };
5
+ interface ReasonOptions {
6
+ sessionId?: string;
7
+ targetThoughts?: number;
8
+ abortSignal?: AbortSignal;
9
+ onProgress?: (progress: number, total: number) => void | Promise<void>;
10
+ }
11
+ export declare function reason(query: string, level: ReasoningLevel, options?: ReasonOptions): Promise<Readonly<Session>>;
12
+ //# sourceMappingURL=reasoner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoner.d.ts","sourceRoot":"","sources":["../../src/engine/reasoner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,QAAA,MAAM,YAAY,cAAqB,CAAC;AAMxC,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAQD,wBAAsB,MAAM,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CA2E5B"}