@j0hanz/thinkseq-mcp 1.2.5 → 1.2.7
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/app.d.ts +0 -1
- package/dist/app.js +0 -1
- package/dist/appConfig/runDependencies.d.ts +0 -1
- package/dist/appConfig/runDependencies.js +6 -4
- package/dist/appConfig/shutdown.d.ts +0 -1
- package/dist/appConfig/shutdown.js +0 -1
- package/dist/appConfig/types.d.ts +0 -1
- package/dist/appConfig/types.js +0 -1
- package/dist/appConfig.d.ts +0 -1
- package/dist/appConfig.js +0 -1
- package/dist/engine/revision.d.ts +0 -1
- package/dist/engine/revision.js +0 -1
- package/dist/engine/thoughtQueries.d.ts +0 -1
- package/dist/engine/thoughtQueries.js +24 -21
- package/dist/engine/thoughtStore.d.ts +5 -3
- package/dist/engine/thoughtStore.js +18 -7
- package/dist/engine.d.ts +0 -1
- package/dist/engine.js +4 -18
- package/dist/engineConfig.d.ts +0 -1
- package/dist/engineConfig.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/instructions.md +1 -1
- package/dist/lib/cli.d.ts +0 -1
- package/dist/lib/cli.js +0 -1
- package/dist/lib/context.d.ts +0 -1
- package/dist/lib/context.js +0 -1
- package/dist/lib/diagnostics.d.ts +0 -1
- package/dist/lib/diagnostics.js +0 -1
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/mcpLogging.d.ts +0 -1
- package/dist/lib/mcpLogging.js +0 -1
- package/dist/lib/package.d.ts +0 -1
- package/dist/lib/package.js +0 -1
- package/dist/lib/stdioGuards.d.ts +0 -1
- package/dist/lib/stdioGuards.js +59 -46
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/types.js +0 -1
- package/dist/schemas/inputs.d.ts +0 -1
- package/dist/schemas/inputs.js +0 -1
- package/dist/schemas/outputs.d.ts +0 -1
- package/dist/schemas/outputs.js +0 -1
- package/dist/tools/thinkseq.d.ts +0 -1
- package/dist/tools/thinkseq.js +54 -43
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js.map +0 -1
- package/dist/appConfig/runDependencies.d.ts.map +0 -1
- package/dist/appConfig/runDependencies.js.map +0 -1
- package/dist/appConfig/shutdown.d.ts.map +0 -1
- package/dist/appConfig/shutdown.js.map +0 -1
- package/dist/appConfig/types.d.ts.map +0 -1
- package/dist/appConfig/types.js.map +0 -1
- package/dist/appConfig.d.ts.map +0 -1
- package/dist/appConfig.js.map +0 -1
- package/dist/engine/revision.d.ts.map +0 -1
- package/dist/engine/revision.js.map +0 -1
- package/dist/engine/thoughtQueries.d.ts.map +0 -1
- package/dist/engine/thoughtQueries.js.map +0 -1
- package/dist/engine/thoughtStore.d.ts.map +0 -1
- package/dist/engine/thoughtStore.js.map +0 -1
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js.map +0 -1
- package/dist/engineConfig.d.ts.map +0 -1
- package/dist/engineConfig.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/cli.d.ts.map +0 -1
- package/dist/lib/cli.js.map +0 -1
- package/dist/lib/context.d.ts.map +0 -1
- package/dist/lib/context.js.map +0 -1
- package/dist/lib/diagnostics.d.ts.map +0 -1
- package/dist/lib/diagnostics.js.map +0 -1
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/mcpLogging.d.ts.map +0 -1
- package/dist/lib/mcpLogging.js.map +0 -1
- package/dist/lib/package.d.ts.map +0 -1
- package/dist/lib/package.js.map +0 -1
- package/dist/lib/stdioGuards.d.ts.map +0 -1
- package/dist/lib/stdioGuards.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.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/tools/thinkseq.d.ts.map +0 -1
- package/dist/tools/thinkseq.js.map +0 -1
package/dist/app.d.ts
CHANGED
package/dist/app.js
CHANGED
|
@@ -35,8 +35,8 @@ function registerInstructionsResource(server) {
|
|
|
35
35
|
}
|
|
36
36
|
const SERVER_INSTRUCTIONS = loadServerInstructions();
|
|
37
37
|
const DEFAULT_PACKAGE_READ_TIMEOUT_MS = 2000;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
function buildServerConfig() {
|
|
39
|
+
return {
|
|
40
40
|
instructions: SERVER_INSTRUCTIONS,
|
|
41
41
|
capabilities: {
|
|
42
42
|
logging: {},
|
|
@@ -44,7 +44,10 @@ const defaultCreateServer = (name, version) => {
|
|
|
44
44
|
resources: { subscribe: false, listChanged: false },
|
|
45
45
|
prompts: { listChanged: false },
|
|
46
46
|
},
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const defaultCreateServer = (name, version) => {
|
|
50
|
+
const server = new McpServer({ name, version }, buildServerConfig());
|
|
48
51
|
registerInstructionsResource(server);
|
|
49
52
|
server.registerPrompt('get-help', {
|
|
50
53
|
description: 'Get usage instructions for this server',
|
|
@@ -102,4 +105,3 @@ export function resolvePackageIdentity(pkg) {
|
|
|
102
105
|
version: pkg.version ?? '0.0.0',
|
|
103
106
|
};
|
|
104
107
|
}
|
|
105
|
-
//# sourceMappingURL=runDependencies.js.map
|
|
@@ -3,4 +3,3 @@ export type { CloseFn, EngineLike } from '../lib/types.js';
|
|
|
3
3
|
export type ProcessLike = Pick<typeof process, 'on' | 'exit'>;
|
|
4
4
|
export type TransportLike = Parameters<McpServer['connect']>[0];
|
|
5
5
|
export type ServerLike = Pick<McpServer, 'connect' | 'registerTool' | 'registerResource' | 'registerPrompt' | 'sendLoggingMessage'>;
|
|
6
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/appConfig/types.js
CHANGED
package/dist/appConfig.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export type { ProcessLike } from './appConfig/types.js';
|
|
|
2
2
|
export type { RunDependencies } from './appConfig/runDependencies.js';
|
|
3
3
|
export { resolvePackageIdentity, resolveRunDependencies, } from './appConfig/runDependencies.js';
|
|
4
4
|
export { buildShutdownDependencies } from './appConfig/shutdown.js';
|
|
5
|
-
//# sourceMappingURL=appConfig.d.ts.map
|
package/dist/appConfig.js
CHANGED
package/dist/engine/revision.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!anchor)
|
|
7
|
-
throw new Error('Invariant violation: anchor thought missing');
|
|
8
|
-
const tail = activeThoughts.slice(-4);
|
|
9
|
-
recent = [anchor, ...tail];
|
|
10
|
-
stepIndexes = [
|
|
11
|
-
1,
|
|
12
|
-
...tail.map((_, index) => activeThoughts.length - 4 + index + 1),
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
recent = activeThoughts.slice();
|
|
17
|
-
stepIndexes = recent.map((_, index) => index + 1);
|
|
1
|
+
function selectRecentThoughts(activeThoughts) {
|
|
2
|
+
if (activeThoughts.length <= 5) {
|
|
3
|
+
const recent = activeThoughts.slice();
|
|
4
|
+
const stepIndexes = recent.map((_, index) => index + 1);
|
|
5
|
+
return { recent, stepIndexes };
|
|
18
6
|
}
|
|
7
|
+
const anchor = activeThoughts[0];
|
|
8
|
+
if (!anchor)
|
|
9
|
+
throw new Error('Invariant violation: anchor thought missing');
|
|
10
|
+
const tail = activeThoughts.slice(-4);
|
|
11
|
+
const recent = [anchor, ...tail];
|
|
12
|
+
const stepIndexes = [
|
|
13
|
+
1,
|
|
14
|
+
...tail.map((_, index) => activeThoughts.length - 4 + index + 1),
|
|
15
|
+
];
|
|
16
|
+
return { recent, stepIndexes };
|
|
17
|
+
}
|
|
18
|
+
function formatThoughtPreview(thought) {
|
|
19
|
+
if (thought.length <= 100)
|
|
20
|
+
return thought;
|
|
21
|
+
return `${thought.slice(0, 100)}...`;
|
|
22
|
+
}
|
|
23
|
+
export function buildContextSummary(activeThoughts, revisionInfo) {
|
|
24
|
+
const { recent, stepIndexes } = selectRecentThoughts(activeThoughts);
|
|
19
25
|
const recentThoughts = recent.map((thought, index) => ({
|
|
20
26
|
stepIndex: stepIndexes[index] ?? index + 1,
|
|
21
27
|
number: thought.thoughtNumber,
|
|
22
|
-
preview: thought.thought
|
|
23
|
-
? `${thought.thought.slice(0, 100)}...`
|
|
24
|
-
: thought.thought,
|
|
28
|
+
preview: formatThoughtPreview(thought.thought),
|
|
25
29
|
}));
|
|
26
30
|
if (revisionInfo !== undefined) {
|
|
27
31
|
return { recentThoughts, revisionInfo };
|
|
28
32
|
}
|
|
29
33
|
return { recentThoughts };
|
|
30
34
|
}
|
|
31
|
-
//# sourceMappingURL=thoughtQueries.js.map
|
|
@@ -12,11 +12,13 @@ export declare class ThoughtStore {
|
|
|
12
12
|
totalThoughts: number;
|
|
13
13
|
};
|
|
14
14
|
storeThought(stored: StoredThought): void;
|
|
15
|
-
supersedeFrom(targetNumber: number, supersededBy: number):
|
|
15
|
+
supersedeFrom(targetNumber: number, supersededBy: number, maxSupersedes?: number): {
|
|
16
|
+
supersedes: number[];
|
|
17
|
+
supersedesTotal: number;
|
|
18
|
+
};
|
|
16
19
|
getActiveThoughts(): readonly StoredThought[];
|
|
17
|
-
getActiveThoughtNumbers():
|
|
20
|
+
getActiveThoughtNumbers(max?: number): number[];
|
|
18
21
|
getThoughtByNumber(thoughtNumber: number): StoredThought | undefined;
|
|
19
22
|
getTotalLength(): number;
|
|
20
23
|
pruneHistoryIfNeeded(): void;
|
|
21
24
|
}
|
|
22
|
-
//# sourceMappingURL=thoughtStore.d.ts.map
|
|
@@ -65,11 +65,12 @@ export class ThoughtStore {
|
|
|
65
65
|
}
|
|
66
66
|
return -1;
|
|
67
67
|
}
|
|
68
|
-
supersedeFrom(targetNumber, supersededBy) {
|
|
68
|
+
supersedeFrom(targetNumber, supersededBy, maxSupersedes) {
|
|
69
69
|
const startIndex = this.#findActiveThoughtIndex(targetNumber);
|
|
70
70
|
if (startIndex < 0)
|
|
71
|
-
return [];
|
|
71
|
+
return { supersedes: [], supersedesTotal: 0 };
|
|
72
72
|
const supersedes = [];
|
|
73
|
+
let supersedesTotal = 0;
|
|
73
74
|
for (let i = startIndex; i < this.#activeThoughts.length; i += 1) {
|
|
74
75
|
const thought = this.#activeThoughts[i];
|
|
75
76
|
if (!thought)
|
|
@@ -78,18 +79,29 @@ export class ThoughtStore {
|
|
|
78
79
|
thought.isActive = false;
|
|
79
80
|
thought.supersededBy = supersededBy;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
supersedesTotal += 1;
|
|
83
|
+
if (maxSupersedes === undefined || supersedes.length < maxSupersedes) {
|
|
84
|
+
supersedes.push(thought.thoughtNumber);
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
this.#activeThoughts.length = startIndex;
|
|
84
88
|
this.#activeThoughtNumbers.length = startIndex;
|
|
85
89
|
this.#recomputeActiveMaxTotalThoughts();
|
|
86
|
-
return supersedes;
|
|
90
|
+
return { supersedes, supersedesTotal };
|
|
87
91
|
}
|
|
88
92
|
getActiveThoughts() {
|
|
89
93
|
return this.#activeThoughts;
|
|
90
94
|
}
|
|
91
|
-
getActiveThoughtNumbers() {
|
|
92
|
-
|
|
95
|
+
getActiveThoughtNumbers(max) {
|
|
96
|
+
if (max === undefined) {
|
|
97
|
+
return this.#activeThoughtNumbers.slice();
|
|
98
|
+
}
|
|
99
|
+
if (max <= 0)
|
|
100
|
+
return [];
|
|
101
|
+
if (this.#activeThoughtNumbers.length <= max) {
|
|
102
|
+
return this.#activeThoughtNumbers.slice();
|
|
103
|
+
}
|
|
104
|
+
return this.#activeThoughtNumbers.slice(-max);
|
|
93
105
|
}
|
|
94
106
|
getThoughtByNumber(thoughtNumber) {
|
|
95
107
|
return this.#thoughtIndex.get(thoughtNumber);
|
|
@@ -188,4 +200,3 @@ export class ThoughtStore {
|
|
|
188
200
|
this.#estimatedBytes = 0;
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
|
-
//# sourceMappingURL=thoughtStore.js.map
|
package/dist/engine.d.ts
CHANGED
package/dist/engine.js
CHANGED
|
@@ -36,9 +36,7 @@ export class ThinkingEngine {
|
|
|
36
36
|
const { numbers, stored } = this.#createStoredThought(input, {
|
|
37
37
|
revisionOf: targetNumber,
|
|
38
38
|
});
|
|
39
|
-
const
|
|
40
|
-
const supersedesTotal = supersedesAll.length;
|
|
41
|
-
const supersedes = capArrayStart(supersedesAll, MAX_SUPERSEDES);
|
|
39
|
+
const { supersedes, supersedesTotal } = this.#store.supersedeFrom(targetNumber, numbers.thoughtNumber, MAX_SUPERSEDES);
|
|
42
40
|
this.#hasRevisions = true;
|
|
43
41
|
this.#commitThought(stored);
|
|
44
42
|
return this.#buildProcessResult(stored, {
|
|
@@ -77,7 +75,7 @@ export class ThinkingEngine {
|
|
|
77
75
|
}
|
|
78
76
|
#resolveEffectiveTotalThoughts(input) {
|
|
79
77
|
if (input.totalThoughts !== undefined) {
|
|
80
|
-
return input.totalThoughts;
|
|
78
|
+
return normalizeInt(input.totalThoughts, _a.DEFAULT_TOTAL_THOUGHTS, { min: 1, max: MAX_THOUGHTS_CAP });
|
|
81
79
|
}
|
|
82
80
|
const activeThoughts = this.#store.getActiveThoughts();
|
|
83
81
|
const lastActive = activeThoughts[activeThoughts.length - 1];
|
|
@@ -90,9 +88,8 @@ export class ThinkingEngine {
|
|
|
90
88
|
const activeThoughts = this.#store.getActiveThoughts();
|
|
91
89
|
const context = buildContextSummary(activeThoughts, revisionInfo);
|
|
92
90
|
const isComplete = stored.thoughtNumber >= stored.totalThoughts;
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const revisableThoughts = capArrayEnd(revisableThoughtsAll, MAX_REVISABLE_THOUGHTS);
|
|
91
|
+
const revisableThoughtsTotal = activeThoughts.length;
|
|
92
|
+
const revisableThoughts = this.#store.getActiveThoughtNumbers(MAX_REVISABLE_THOUGHTS);
|
|
96
93
|
return {
|
|
97
94
|
ok: true,
|
|
98
95
|
result: {
|
|
@@ -111,14 +108,3 @@ export class ThinkingEngine {
|
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
_a = ThinkingEngine;
|
|
114
|
-
function capArrayStart(values, max) {
|
|
115
|
-
if (values.length <= max)
|
|
116
|
-
return values.slice();
|
|
117
|
-
return values.slice(0, max);
|
|
118
|
-
}
|
|
119
|
-
function capArrayEnd(values, max) {
|
|
120
|
-
if (values.length <= max)
|
|
121
|
-
return values.slice();
|
|
122
|
-
return values.slice(-max);
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=engine.js.map
|
package/dist/engineConfig.d.ts
CHANGED
package/dist/engineConfig.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/instructions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ThinkSeq Instructions
|
|
2
2
|
|
|
3
|
-
> **Guidance for the Agent:** These instructions are available as a resource (`internal://instructions`).
|
|
3
|
+
> **Guidance for the Agent:** These instructions are available as a resource (`internal://instructions`). Load them when you are confused about tool usage.
|
|
4
4
|
|
|
5
5
|
## 1. Core Capability
|
|
6
6
|
|
package/dist/lib/cli.d.ts
CHANGED
package/dist/lib/cli.js
CHANGED
package/dist/lib/context.d.ts
CHANGED
package/dist/lib/context.js
CHANGED
package/dist/lib/diagnostics.js
CHANGED
package/dist/lib/errors.d.ts
CHANGED
|
@@ -18,4 +18,3 @@ export interface CreateErrorResponseOptions {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function getErrorMessage(error: unknown): string;
|
|
20
20
|
export declare function createErrorResponse(code: string, message: string, result?: unknown, options?: CreateErrorResponseOptions): ErrorResponse;
|
|
21
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/lib/errors.js
CHANGED
package/dist/lib/mcpLogging.d.ts
CHANGED
package/dist/lib/mcpLogging.js
CHANGED
package/dist/lib/package.d.ts
CHANGED
package/dist/lib/package.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function installStdioInitializationGuards(transport: unknown): void;
|
|
2
2
|
export declare function installStdioInvalidMessageGuards(transport: unknown): void;
|
|
3
3
|
export declare function installStdioParseErrorResponder(transport: unknown): void;
|
|
4
|
-
//# sourceMappingURL=stdioGuards.d.ts.map
|
package/dist/lib/stdioGuards.js
CHANGED
|
@@ -68,6 +68,63 @@ function isParseError(error) {
|
|
|
68
68
|
function isSchemaError(error) {
|
|
69
69
|
return error instanceof Error && error.name === 'ZodError';
|
|
70
70
|
}
|
|
71
|
+
function wrapSendForInitTracking(transport, state) {
|
|
72
|
+
if (!transport.send)
|
|
73
|
+
return;
|
|
74
|
+
const originalSend = transport.send.bind(transport);
|
|
75
|
+
transport.send = (message) => {
|
|
76
|
+
trackInitializeResponse(message, state);
|
|
77
|
+
return originalSend(message);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function trackInitializeResponse(message, state) {
|
|
81
|
+
try {
|
|
82
|
+
const response = parseJsonRpcResponse(message);
|
|
83
|
+
if (!response)
|
|
84
|
+
return;
|
|
85
|
+
const key = getIdKey(response.id);
|
|
86
|
+
if (!state.pendingInitIds.has(key))
|
|
87
|
+
return;
|
|
88
|
+
state.pendingInitIds.delete(key);
|
|
89
|
+
if (response.error === undefined) {
|
|
90
|
+
state.sawInitialize = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Ignore send inspection errors.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function handleInitializeMethod(methodMessage, state, originalOnMessage, message, extra) {
|
|
98
|
+
state.pendingInitIds.add(getIdKey(methodMessage.id));
|
|
99
|
+
originalOnMessage(message, extra);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function handleNonInitializedRequest(methodMessage, transport) {
|
|
103
|
+
if (methodMessage.hasId) {
|
|
104
|
+
sendError(transport, ErrorCode.InvalidRequest, INIT_FIRST_ERROR_MESSAGE, methodMessage.id);
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
function createInitGuardHandler(state, originalOnMessage, transport) {
|
|
109
|
+
return (message, extra) => {
|
|
110
|
+
const methodMessage = parseJsonRpcMethodMessage(message);
|
|
111
|
+
if (!methodMessage) {
|
|
112
|
+
originalOnMessage(message, extra);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (methodMessage.method === 'initialize') {
|
|
116
|
+
if (!methodMessage.hasId)
|
|
117
|
+
return;
|
|
118
|
+
handleInitializeMethod(methodMessage, state, originalOnMessage, message, extra);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!state.sawInitialize) {
|
|
122
|
+
handleNonInitializedRequest(methodMessage, transport);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
originalOnMessage(message, extra);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
71
128
|
export function installStdioInitializationGuards(transport) {
|
|
72
129
|
if (!isStdioMessageTransport(transport))
|
|
73
130
|
return;
|
|
@@ -78,51 +135,8 @@ export function installStdioInitializationGuards(transport) {
|
|
|
78
135
|
sawInitialize: false,
|
|
79
136
|
pendingInitIds: new Set(),
|
|
80
137
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
transport.send = (message) => {
|
|
84
|
-
try {
|
|
85
|
-
const response = parseJsonRpcResponse(message);
|
|
86
|
-
if (response) {
|
|
87
|
-
const key = getIdKey(response.id);
|
|
88
|
-
if (state.pendingInitIds.has(key)) {
|
|
89
|
-
state.pendingInitIds.delete(key);
|
|
90
|
-
if (response.error === undefined) {
|
|
91
|
-
state.sawInitialize = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Ignore send inspection errors.
|
|
98
|
-
}
|
|
99
|
-
return originalSend(message);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
transport.onmessage = (message, extra) => {
|
|
103
|
-
const methodMessage = parseJsonRpcMethodMessage(message);
|
|
104
|
-
if (methodMessage) {
|
|
105
|
-
if (methodMessage.method === 'initialize') {
|
|
106
|
-
if (!methodMessage.hasId) {
|
|
107
|
-
// initialize must be a request (not a notification).
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
// DELEGATION: We intentionally skip manual protocolVersion checks here and
|
|
111
|
-
// let the SDK handle version negotiation. This prevents this guard from
|
|
112
|
-
// becoming a maintenance burden or rejecting valid newer versions.
|
|
113
|
-
state.pendingInitIds.add(getIdKey(methodMessage.id));
|
|
114
|
-
originalOnMessage(message, extra);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (!state.sawInitialize) {
|
|
118
|
-
if (methodMessage.hasId) {
|
|
119
|
-
sendError(transport, ErrorCode.InvalidRequest, INIT_FIRST_ERROR_MESSAGE, methodMessage.id);
|
|
120
|
-
}
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
originalOnMessage(message, extra);
|
|
125
|
-
};
|
|
138
|
+
wrapSendForInitTracking(transport, state);
|
|
139
|
+
transport.onmessage = createInitGuardHandler(state, originalOnMessage, transport);
|
|
126
140
|
}
|
|
127
141
|
export function installStdioInvalidMessageGuards(transport) {
|
|
128
142
|
if (!isStdioMessageTransport(transport))
|
|
@@ -155,4 +169,3 @@ export function installStdioParseErrorResponder(transport) {
|
|
|
155
169
|
}
|
|
156
170
|
};
|
|
157
171
|
}
|
|
158
|
-
//# sourceMappingURL=stdioGuards.js.map
|
package/dist/lib/types.d.ts
CHANGED
package/dist/lib/types.js
CHANGED
package/dist/schemas/inputs.d.ts
CHANGED
package/dist/schemas/inputs.js
CHANGED
package/dist/schemas/outputs.js
CHANGED
package/dist/tools/thinkseq.d.ts
CHANGED