@j0hanz/cortex-mcp 1.3.0 → 1.5.0
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/engine/config.d.ts +5 -5
- package/dist/engine/config.js +14 -5
- package/dist/engine/context.d.ts +0 -2
- package/dist/engine/context.js +0 -4
- package/dist/engine/events.d.ts +1 -2
- package/dist/engine/events.js +2 -4
- package/dist/engine/heuristics.d.ts +4 -0
- package/dist/engine/heuristics.js +65 -0
- package/dist/engine/reasoner.d.ts +7 -2
- package/dist/engine/reasoner.js +41 -103
- package/dist/engine/session-store.d.ts +6 -2
- package/dist/engine/session-store.js +78 -27
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/concurrency.d.ts +5 -0
- package/dist/lib/concurrency.js +17 -0
- package/dist/lib/errors.d.ts +23 -8
- package/dist/lib/errors.js +47 -6
- package/dist/lib/formatting.d.ts +13 -1
- package/dist/lib/formatting.js +18 -1
- package/dist/lib/prompt-contracts.d.ts +6 -0
- package/dist/lib/prompt-contracts.js +35 -0
- package/dist/lib/text.d.ts +0 -1
- package/dist/lib/text.js +0 -1
- package/dist/lib/tool-contracts.d.ts +15 -0
- package/dist/lib/tool-contracts.js +93 -0
- package/dist/lib/tool-response.d.ts +4 -1
- package/dist/lib/tool-response.js +3 -1
- package/dist/lib/types.d.ts +18 -1
- package/dist/lib/types.js +8 -2
- package/dist/lib/validators.d.ts +7 -2
- package/dist/lib/validators.js +30 -8
- package/dist/prompts/index.d.ts +0 -1
- package/dist/prompts/index.js +171 -74
- package/dist/prompts/templates.d.ts +2 -0
- package/dist/prompts/templates.js +106 -0
- package/dist/resources/index.d.ts +0 -1
- package/dist/resources/index.js +40 -63
- package/dist/resources/instructions.d.ts +1 -0
- package/dist/resources/instructions.js +103 -0
- package/dist/resources/tool-catalog.d.ts +1 -0
- package/dist/resources/tool-catalog.js +20 -0
- package/dist/resources/tool-info.d.ts +2 -0
- package/dist/resources/tool-info.js +35 -0
- package/dist/resources/workflows.d.ts +1 -0
- package/dist/resources/workflows.js +61 -0
- package/dist/schemas/inputs.d.ts +7 -2
- package/dist/schemas/inputs.js +39 -4
- package/dist/schemas/outputs.d.ts +32 -26
- package/dist/schemas/outputs.js +17 -14
- package/dist/server.d.ts +0 -1
- package/dist/server.js +1 -4
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/tools/reasoning-think.d.ts +0 -1
- package/dist/tools/reasoning-think.js +211 -118
- package/package.json +9 -10
- package/dist/engine/config.d.ts.map +0 -1
- package/dist/engine/config.js.map +0 -1
- package/dist/engine/context.d.ts.map +0 -1
- package/dist/engine/context.js.map +0 -1
- package/dist/engine/events.d.ts.map +0 -1
- package/dist/engine/events.js.map +0 -1
- package/dist/engine/reasoner.d.ts.map +0 -1
- package/dist/engine/reasoner.js.map +0 -1
- package/dist/engine/session-store.d.ts.map +0 -1
- package/dist/engine/session-store.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/instructions.md +0 -148
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/formatting.d.ts.map +0 -1
- package/dist/lib/formatting.js.map +0 -1
- package/dist/lib/instructions.d.ts +0 -5
- package/dist/lib/instructions.d.ts.map +0 -1
- package/dist/lib/instructions.js +0 -30
- package/dist/lib/instructions.js.map +0 -1
- package/dist/lib/text.d.ts.map +0 -1
- package/dist/lib/text.js.map +0 -1
- package/dist/lib/tool-response.d.ts.map +0 -1
- package/dist/lib/tool-response.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/validators.d.ts.map +0 -1
- package/dist/lib/validators.js.map +0 -1
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js.map +0 -1
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/index.js.map +0 -1
- package/dist/schemas/inputs.d.ts.map +0 -1
- package/dist/schemas/inputs.js.map +0 -1
- package/dist/schemas/outputs.d.ts.map +0 -1
- package/dist/schemas/outputs.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/reasoning-think.d.ts.map +0 -1
- package/dist/tools/reasoning-think.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function createTaskLimiter(maxActiveTasks) {
|
|
2
|
+
let activeTasks = 0;
|
|
3
|
+
return {
|
|
4
|
+
tryAcquire() {
|
|
5
|
+
if (activeTasks >= maxActiveTasks) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
activeTasks += 1;
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
release() {
|
|
12
|
+
if (activeTasks > 0) {
|
|
13
|
+
activeTasks -= 1;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -4,16 +4,31 @@ interface ErrorResponse {
|
|
|
4
4
|
type: 'text';
|
|
5
5
|
text: string;
|
|
6
6
|
}[];
|
|
7
|
-
structuredContent: {
|
|
8
|
-
ok: false;
|
|
9
|
-
error: {
|
|
10
|
-
code: string;
|
|
11
|
-
message: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
7
|
isError: true;
|
|
15
8
|
}
|
|
9
|
+
export declare class ReasoningError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
constructor(code: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class SessionNotFoundError extends ReasoningError {
|
|
14
|
+
constructor(sessionId: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidThoughtCountError extends ReasoningError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class InsufficientThoughtsError extends ReasoningError {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class InvalidRunModeArgsError extends ReasoningError {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class ReasoningAbortedError extends ReasoningError {
|
|
26
|
+
constructor(message?: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class ServerBusyError extends ReasoningError {
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
export declare function isObjectRecord(value: unknown): value is Record<string, unknown>;
|
|
16
32
|
export declare function getErrorMessage(error: unknown): string;
|
|
17
33
|
export declare function createErrorResponse(code: string, message: string): ErrorResponse;
|
|
18
34
|
export {};
|
|
19
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/lib/errors.js
CHANGED
|
@@ -4,7 +4,51 @@ const INSPECT_OPTIONS = {
|
|
|
4
4
|
breakLength: 120,
|
|
5
5
|
};
|
|
6
6
|
const UNKNOWN_ERROR_MESSAGE = 'Unknown error';
|
|
7
|
-
|
|
7
|
+
export class ReasoningError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.name = 'ReasoningError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class SessionNotFoundError extends ReasoningError {
|
|
16
|
+
constructor(sessionId) {
|
|
17
|
+
super('E_SESSION_NOT_FOUND', `Session not found or expired: ${sessionId}`);
|
|
18
|
+
this.name = 'SessionNotFoundError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class InvalidThoughtCountError extends ReasoningError {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super('E_INVALID_THOUGHT_COUNT', message);
|
|
24
|
+
this.name = 'InvalidThoughtCountError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class InsufficientThoughtsError extends ReasoningError {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super('E_INSUFFICIENT_THOUGHTS', message);
|
|
30
|
+
this.name = 'InsufficientThoughtsError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class InvalidRunModeArgsError extends ReasoningError {
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super('E_INVALID_RUN_MODE_ARGS', message);
|
|
36
|
+
this.name = 'InvalidRunModeArgsError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class ReasoningAbortedError extends ReasoningError {
|
|
40
|
+
constructor(message = 'Reasoning aborted') {
|
|
41
|
+
super('E_ABORTED', message);
|
|
42
|
+
this.name = 'ReasoningAbortedError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ServerBusyError extends ReasoningError {
|
|
46
|
+
constructor(message = 'Server busy — too many concurrent reasoning tasks. Retry shortly.') {
|
|
47
|
+
super('E_SERVER_BUSY', message);
|
|
48
|
+
this.name = 'ServerBusyError';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function isObjectRecord(value) {
|
|
8
52
|
return typeof value === 'object' && value !== null;
|
|
9
53
|
}
|
|
10
54
|
function stringifyUnknown(value) {
|
|
@@ -17,7 +61,7 @@ function stringifyUnknown(value) {
|
|
|
17
61
|
return inspect(value, INSPECT_OPTIONS);
|
|
18
62
|
}
|
|
19
63
|
function getMessageFromErrorLike(value) {
|
|
20
|
-
if (!
|
|
64
|
+
if (!isObjectRecord(value)) {
|
|
21
65
|
return undefined;
|
|
22
66
|
}
|
|
23
67
|
return typeof value.message === 'string' ? value.message : undefined;
|
|
@@ -39,12 +83,9 @@ export function getErrorMessage(error) {
|
|
|
39
83
|
return stringifyUnknown(error);
|
|
40
84
|
}
|
|
41
85
|
export function createErrorResponse(code, message) {
|
|
42
|
-
const
|
|
43
|
-
const text = JSON.stringify(structured);
|
|
86
|
+
const text = JSON.stringify({ ok: false, error: { code, message } });
|
|
44
87
|
return {
|
|
45
88
|
content: [{ type: 'text', text }],
|
|
46
|
-
structuredContent: structured,
|
|
47
89
|
isError: true,
|
|
48
90
|
};
|
|
49
91
|
}
|
|
50
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/lib/formatting.d.ts
CHANGED
|
@@ -30,4 +30,16 @@ export declare function formatThoughtsToMarkdown(session: Readonly<Session>, ran
|
|
|
30
30
|
start: number;
|
|
31
31
|
end: number;
|
|
32
32
|
}): string;
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Format a standardized progress message string.
|
|
35
|
+
*
|
|
36
|
+
* Rules:
|
|
37
|
+
* - Start/Mid: <tool>: <context> [metadata]
|
|
38
|
+
* - End: <tool>: <context> [metadata] • <outcome>
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatProgressMessage(args: {
|
|
41
|
+
toolName: string;
|
|
42
|
+
context: string;
|
|
43
|
+
metadata?: string;
|
|
44
|
+
outcome?: string;
|
|
45
|
+
}): string;
|
package/dist/lib/formatting.js
CHANGED
|
@@ -21,6 +21,9 @@ export function extractPinnedSections(thoughts) {
|
|
|
21
21
|
const byTitle = new Map();
|
|
22
22
|
for (const thought of thoughts) {
|
|
23
23
|
const { content } = thought;
|
|
24
|
+
if (!content.includes(PIN_START)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
24
27
|
let searchFrom = 0;
|
|
25
28
|
while (searchFrom < content.length) {
|
|
26
29
|
const startIdx = content.indexOf(PIN_START, searchFrom);
|
|
@@ -120,4 +123,18 @@ export function formatThoughtsToMarkdown(session, range) {
|
|
|
120
123
|
}
|
|
121
124
|
return sections.join(TRACE_SEPARATOR);
|
|
122
125
|
}
|
|
123
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Format a standardized progress message string.
|
|
128
|
+
*
|
|
129
|
+
* Rules:
|
|
130
|
+
* - Start/Mid: <tool>: <context> [metadata]
|
|
131
|
+
* - End: <tool>: <context> [metadata] • <outcome>
|
|
132
|
+
*/
|
|
133
|
+
export function formatProgressMessage(args) {
|
|
134
|
+
const { toolName, context, metadata, outcome } = args;
|
|
135
|
+
const metaPart = metadata ? ` ${metadata}` : '';
|
|
136
|
+
if (outcome) {
|
|
137
|
+
return `${toolName}: ${context}${metaPart} • ${outcome}`;
|
|
138
|
+
}
|
|
139
|
+
return `${toolName}: ${context}${metaPart}`;
|
|
140
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const PROMPT_CONTRACTS = [
|
|
2
|
+
{
|
|
3
|
+
name: 'get-help',
|
|
4
|
+
title: 'Get Help',
|
|
5
|
+
description: 'Return the server usage instructions.',
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
name: 'reasoning.basic',
|
|
9
|
+
title: 'Reasoning Basic',
|
|
10
|
+
description: 'Prepare a basic-depth reasoning request (3–5 thoughts).',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'reasoning.normal',
|
|
14
|
+
title: 'Reasoning Normal',
|
|
15
|
+
description: 'Prepare a normal-depth reasoning request (6–10 thoughts).',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'reasoning.high',
|
|
19
|
+
title: 'Reasoning High',
|
|
20
|
+
description: 'Prepare a high-depth reasoning request (15–25 thoughts).',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'reasoning.continue',
|
|
24
|
+
title: 'Continue Reasoning',
|
|
25
|
+
description: 'Continue an existing reasoning session (follow-up query optional).',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'reasoning.retry',
|
|
29
|
+
title: 'Retry Reasoning',
|
|
30
|
+
description: 'Retry a failed reasoning task with modified parameters.',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
export function getPromptContracts() {
|
|
34
|
+
return PROMPT_CONTRACTS;
|
|
35
|
+
}
|
package/dist/lib/text.d.ts
CHANGED
|
@@ -12,4 +12,3 @@ export declare function truncate(str: string, maxLength: number, segmenter?: Int
|
|
|
12
12
|
* Drops incomplete characters at the end rather than using replacement characters.
|
|
13
13
|
*/
|
|
14
14
|
export declare function truncateByUtf8Boundary(str: string, maxBytes: number): string;
|
|
15
|
-
//# sourceMappingURL=text.d.ts.map
|
package/dist/lib/text.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ToolContract {
|
|
2
|
+
name: string;
|
|
3
|
+
purpose: string;
|
|
4
|
+
model: string;
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
maxOutputTokens: number;
|
|
7
|
+
params: {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
constraints: string;
|
|
12
|
+
}[];
|
|
13
|
+
outputShape: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function getToolContracts(): readonly ToolContract[];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const TOOL_CONTRACTS = [
|
|
2
|
+
{
|
|
3
|
+
name: 'reasoning_think',
|
|
4
|
+
purpose: 'Structured multi-step reasoning tool. Decomposes analysis into sequential thought steps stored in a persistent session trace.',
|
|
5
|
+
model: 'none (engine)',
|
|
6
|
+
timeoutMs: 0,
|
|
7
|
+
maxOutputTokens: 0,
|
|
8
|
+
params: [
|
|
9
|
+
{
|
|
10
|
+
name: 'query',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: false,
|
|
13
|
+
constraints: '1-10,000 chars',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'level',
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: false,
|
|
19
|
+
constraints: 'basic | normal | high',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'runMode',
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: false,
|
|
25
|
+
constraints: 'step | run_to_completion',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'thought',
|
|
29
|
+
type: 'string | string[]',
|
|
30
|
+
required: false,
|
|
31
|
+
constraints: '1-100,000 chars',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'thoughts',
|
|
35
|
+
type: 'string[]',
|
|
36
|
+
required: false,
|
|
37
|
+
constraints: 'optional',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'targetThoughts',
|
|
41
|
+
type: 'number',
|
|
42
|
+
required: false,
|
|
43
|
+
constraints: '1-25',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'sessionId',
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: false,
|
|
49
|
+
constraints: '1-128 chars',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'observation',
|
|
53
|
+
type: 'string',
|
|
54
|
+
required: false,
|
|
55
|
+
constraints: 'optional',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'hypothesis',
|
|
59
|
+
type: 'string',
|
|
60
|
+
required: false,
|
|
61
|
+
constraints: 'optional',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'evaluation',
|
|
65
|
+
type: 'string',
|
|
66
|
+
required: false,
|
|
67
|
+
constraints: 'optional',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'step_summary',
|
|
71
|
+
type: 'string',
|
|
72
|
+
required: false,
|
|
73
|
+
constraints: 'optional',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'is_conclusion',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
required: false,
|
|
79
|
+
constraints: 'optional',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'rollback_to_step',
|
|
83
|
+
type: 'number',
|
|
84
|
+
required: false,
|
|
85
|
+
constraints: 'optional',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
outputShape: '{ok, result: {sessionId, level, status, thoughts[], generatedThoughts, requestedThoughts, totalThoughts, remainingThoughts, tokenBudget, tokensUsed, ttlMs, expiresAt, createdAt, updatedAt, summary}}',
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
export function getToolContracts() {
|
|
92
|
+
return TOOL_CONTRACTS;
|
|
93
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ContentBlock, TextResourceContents } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { IconMeta } from './types.js';
|
|
3
|
+
export declare function withIconMeta(iconMeta?: IconMeta): {
|
|
4
|
+
icons: IconMeta[];
|
|
5
|
+
} | undefined;
|
|
2
6
|
export declare function createToolResponse<T extends object>(structured: T, embeddedResource?: TextResourceContents): {
|
|
3
7
|
content: ContentBlock[];
|
|
4
8
|
structuredContent: T;
|
|
5
9
|
};
|
|
6
|
-
//# sourceMappingURL=tool-response.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export function withIconMeta(iconMeta) {
|
|
2
|
+
return iconMeta ? { icons: [iconMeta] } : undefined;
|
|
3
|
+
}
|
|
1
4
|
function createStructuredTextBlock(structured) {
|
|
2
5
|
return { type: 'text', text: JSON.stringify(structured) };
|
|
3
6
|
}
|
|
@@ -13,4 +16,3 @@ export function createToolResponse(structured, embeddedResource) {
|
|
|
13
16
|
structuredContent: structured,
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
|
-
//# sourceMappingURL=tool-response.js.map
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
export type ReasoningLevel = 'basic' | 'normal' | 'high';
|
|
2
|
+
export declare const REASONING_LEVELS: readonly ["basic", "normal", "high"];
|
|
3
|
+
/** Shared level bounds — single source of truth for min/maxThoughts per level. */
|
|
4
|
+
export declare const LEVEL_BOUNDS: {
|
|
5
|
+
readonly basic: {
|
|
6
|
+
readonly minThoughts: 3;
|
|
7
|
+
readonly maxThoughts: 5;
|
|
8
|
+
};
|
|
9
|
+
readonly normal: {
|
|
10
|
+
readonly minThoughts: 6;
|
|
11
|
+
readonly maxThoughts: 10;
|
|
12
|
+
};
|
|
13
|
+
readonly high: {
|
|
14
|
+
readonly minThoughts: 15;
|
|
15
|
+
readonly maxThoughts: 25;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
2
18
|
export type ReasoningRunMode = 'step' | 'run_to_completion';
|
|
3
19
|
export type SessionStatus = 'active' | 'completed' | 'cancelled';
|
|
20
|
+
export declare const SESSION_STATUSES: readonly ["active", "completed", "cancelled"];
|
|
4
21
|
interface Timestamped {
|
|
5
22
|
readonly createdAt: number;
|
|
6
23
|
readonly updatedAt: number;
|
|
@@ -19,6 +36,7 @@ export interface Thought {
|
|
|
19
36
|
readonly index: number;
|
|
20
37
|
readonly content: string;
|
|
21
38
|
readonly revision: number;
|
|
39
|
+
readonly stepSummary?: string;
|
|
22
40
|
}
|
|
23
41
|
export interface Session extends SessionBase {
|
|
24
42
|
readonly thoughts: readonly Thought[];
|
|
@@ -37,4 +55,3 @@ export interface IconMeta {
|
|
|
37
55
|
sizes?: string[];
|
|
38
56
|
}
|
|
39
57
|
export {};
|
|
40
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export const REASONING_LEVELS = ['basic', 'normal', 'high'];
|
|
2
|
+
/** Shared level bounds — single source of truth for min/maxThoughts per level. */
|
|
3
|
+
export const LEVEL_BOUNDS = {
|
|
4
|
+
basic: { minThoughts: 3, maxThoughts: 5 },
|
|
5
|
+
normal: { minThoughts: 6, maxThoughts: 10 },
|
|
6
|
+
high: { minThoughts: 15, maxThoughts: 25 },
|
|
7
|
+
};
|
|
8
|
+
export const SESSION_STATUSES = ['active', 'completed', 'cancelled'];
|
package/dist/lib/validators.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReasoningLevel } from './types.js';
|
|
2
2
|
export declare function getThoughtBounds(level: ReasoningLevel): {
|
|
3
3
|
minThoughts: number;
|
|
4
4
|
maxThoughts: number;
|
|
5
5
|
};
|
|
6
6
|
export declare function getTargetThoughtsError(level: ReasoningLevel, targetThoughts: number): string | undefined;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Parse a positive integer from an environment variable, returning `fallback`
|
|
9
|
+
* if the variable is absent or invalid. Values below `minimum` also fall back.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parsePositiveIntEnv(name: string, fallback: number, minimum?: number): number;
|
|
12
|
+
export declare function collectPrefixMatches(candidates: readonly string[], value: string, limit: number): string[];
|
package/dist/lib/validators.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const THOUGHT_BOUNDS = Object.freeze({
|
|
3
|
-
basic: Object.freeze({ minThoughts: 3, maxThoughts: 5 }),
|
|
4
|
-
normal: Object.freeze({ minThoughts: 6, maxThoughts: 10 }),
|
|
5
|
-
high: Object.freeze({ minThoughts: 15, maxThoughts: 25 }),
|
|
6
|
-
});
|
|
1
|
+
import { LEVEL_BOUNDS } from './types.js';
|
|
7
2
|
function isOutOfBounds(value, bounds) {
|
|
8
3
|
return value < bounds.minThoughts || value > bounds.maxThoughts;
|
|
9
4
|
}
|
|
10
5
|
export function getThoughtBounds(level) {
|
|
11
|
-
return
|
|
6
|
+
return LEVEL_BOUNDS[level];
|
|
12
7
|
}
|
|
13
8
|
export function getTargetThoughtsError(level, targetThoughts) {
|
|
14
9
|
if (!Number.isInteger(targetThoughts)) {
|
|
@@ -20,4 +15,31 @@ export function getTargetThoughtsError(level, targetThoughts) {
|
|
|
20
15
|
}
|
|
21
16
|
return undefined;
|
|
22
17
|
}
|
|
23
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Parse a positive integer from an environment variable, returning `fallback`
|
|
20
|
+
* if the variable is absent or invalid. Values below `minimum` also fall back.
|
|
21
|
+
*/
|
|
22
|
+
export function parsePositiveIntEnv(name, fallback, minimum = 1) {
|
|
23
|
+
const raw = process.env[name];
|
|
24
|
+
if (raw === undefined) {
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
const parsed = Number.parseInt(raw, 10);
|
|
28
|
+
if (!Number.isInteger(parsed) || parsed < minimum) {
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
export function collectPrefixMatches(candidates, value, limit) {
|
|
34
|
+
const results = [];
|
|
35
|
+
for (const candidate of candidates) {
|
|
36
|
+
if (!candidate.startsWith(value)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
results.push(candidate);
|
|
40
|
+
if (results.length >= limit) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return results;
|
|
45
|
+
}
|
package/dist/prompts/index.d.ts
CHANGED