@kongyo2/mcp-request-context 1.0.1 → 1.0.3
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/core/storage.d.ts +47 -20
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/core/storage.js +166 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/core/types.js +88 -0
- package/dist/core/types.js.map +1 -0
- package/dist/dashboard/server.d.ts +3 -3
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +222 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +8 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +125 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/get-context-response.d.ts +5 -21
- package/dist/tools/get-context-response.d.ts.map +1 -1
- package/dist/tools/get-context-response.js +87 -0
- package/dist/tools/get-context-response.js.map +1 -0
- package/dist/tools/index.d.ts +6 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +39 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/request-context.d.ts +5 -45
- package/dist/tools/request-context.d.ts.map +1 -1
- package/dist/tools/request-context.js +128 -0
- package/dist/tools/request-context.js.map +1 -0
- package/dist/tools/types.d.ts +7 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +1 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { RequestContextMCPServer } from './server.js';
|
|
3
|
+
function parseArgs() {
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const result = {
|
|
6
|
+
noOpen: false
|
|
7
|
+
};
|
|
8
|
+
for (let i = 0; i < args.length; i++) {
|
|
9
|
+
const arg = args[i] ?? '';
|
|
10
|
+
if (arg === '--port' || arg === '-p') {
|
|
11
|
+
const nextArg = args[i + 1] ?? '';
|
|
12
|
+
if (nextArg && !nextArg.startsWith('-')) {
|
|
13
|
+
result.port = parseInt(nextArg, 10);
|
|
14
|
+
i++;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else if (arg === '--no-open') {
|
|
18
|
+
result.noOpen = true;
|
|
19
|
+
}
|
|
20
|
+
else if (arg === '--help' || arg === '-h') {
|
|
21
|
+
printHelp();
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
function printHelp() {
|
|
28
|
+
console.log(`
|
|
29
|
+
MCP Request Context - LLM agents request context from humans
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
mcp-request-context [options]
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
--port, -p <port> Dashboard port (default: 5100)
|
|
36
|
+
--no-open Don't auto-open browser for dashboard
|
|
37
|
+
--help, -h Show this help message
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
# Start MCP server with integrated dashboard (browser auto-opens)
|
|
41
|
+
mcp-request-context
|
|
42
|
+
|
|
43
|
+
# Start on custom port without auto-opening browser
|
|
44
|
+
mcp-request-context --port 5200 --no-open
|
|
45
|
+
|
|
46
|
+
MCP Configuration:
|
|
47
|
+
Add to your MCP settings:
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"request-context": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "@kongyo2/mcp-request-context"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
async function main() {
|
|
59
|
+
const args = parseArgs();
|
|
60
|
+
// MCP + Dashboard 統合サーバーを起動
|
|
61
|
+
const server = new RequestContextMCPServer({
|
|
62
|
+
port: args.port,
|
|
63
|
+
autoOpen: !args.noOpen // デフォルトでブラウザを開く
|
|
64
|
+
});
|
|
65
|
+
const handleShutdown = async () => {
|
|
66
|
+
console.error('\nShutting down...');
|
|
67
|
+
await server.stop();
|
|
68
|
+
process.exit(0);
|
|
69
|
+
};
|
|
70
|
+
process.on('SIGINT', handleShutdown);
|
|
71
|
+
process.on('SIGTERM', handleShutdown);
|
|
72
|
+
try {
|
|
73
|
+
await server.initialize();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Failed to start server:', error);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
main().catch((error) => {
|
|
81
|
+
console.error('Fatal error:', error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAOtD,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,MAAM,GAAY;QACtB,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAE1B,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxC,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;g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AAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { ContextStorage } from './core/storage.js';
|
|
2
|
+
export interface MCPServerOptions {
|
|
3
|
+
port?: number;
|
|
4
|
+
autoOpen?: boolean;
|
|
5
|
+
}
|
|
2
6
|
export declare class RequestContextMCPServer {
|
|
3
7
|
private server;
|
|
4
8
|
private storage;
|
|
5
|
-
private
|
|
9
|
+
private dashboard;
|
|
6
10
|
private dashboardUrl?;
|
|
7
|
-
constructor(
|
|
11
|
+
constructor(options?: MCPServerOptions);
|
|
8
12
|
initialize(): Promise<void>;
|
|
9
|
-
private
|
|
13
|
+
private setupHandlers;
|
|
10
14
|
stop(): Promise<void>;
|
|
11
15
|
getStorage(): ContextStorage;
|
|
16
|
+
getDashboardUrl(): string | undefined;
|
|
12
17
|
}
|
|
13
18
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASnD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,OAAO,GAAE,gBAAqB;IA2CpC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA+CjC,OAAO,CAAC,aAAa;IAqBf,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,UAAU,IAAI,cAAc;IAI5B,eAAe,IAAI,MAAM,GAAG,SAAS;CAGtC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { ContextStorage } from './core/storage.js';
|
|
5
|
+
import { registerTools, handleToolCall } from './tools/index.js';
|
|
6
|
+
import { DashboardServer } from './dashboard/server.js';
|
|
7
|
+
import { readFileSync, existsSync } from 'fs';
|
|
8
|
+
import { join, dirname } from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
export class RequestContextMCPServer {
|
|
12
|
+
server;
|
|
13
|
+
storage;
|
|
14
|
+
dashboard;
|
|
15
|
+
dashboardUrl;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
// 共有ストレージを作成
|
|
18
|
+
this.storage = new ContextStorage();
|
|
19
|
+
// ダッシュボードを同じストレージで初期化
|
|
20
|
+
this.dashboard = new DashboardServer({
|
|
21
|
+
storage: this.storage,
|
|
22
|
+
port: options.port ?? 5100,
|
|
23
|
+
autoOpen: options.autoOpen ?? true // デフォルトでブラウザを開く
|
|
24
|
+
});
|
|
25
|
+
// Get version from package.json
|
|
26
|
+
let version = '1.0.0';
|
|
27
|
+
try {
|
|
28
|
+
const packageJsonPath = join(__dirname, '..', 'package.json');
|
|
29
|
+
if (existsSync(packageJsonPath)) {
|
|
30
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
31
|
+
version = packageJson.version ?? version;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Use default version
|
|
36
|
+
}
|
|
37
|
+
// Get all registered tools
|
|
38
|
+
const tools = registerTools();
|
|
39
|
+
// Create tools capability object with each tool name
|
|
40
|
+
const toolsCapability = tools.reduce((acc, tool) => {
|
|
41
|
+
acc[tool.name] = {};
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
this.server = new Server({
|
|
45
|
+
name: 'mcp-request-context',
|
|
46
|
+
version
|
|
47
|
+
}, {
|
|
48
|
+
capabilities: {
|
|
49
|
+
tools: toolsCapability
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async initialize() {
|
|
54
|
+
// ダッシュボードを先に起動
|
|
55
|
+
try {
|
|
56
|
+
this.dashboardUrl = await this.dashboard.start();
|
|
57
|
+
console.error(`Dashboard started at: ${this.dashboardUrl}`);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('Failed to start dashboard:', error);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
// Create context for tools
|
|
64
|
+
const context = {
|
|
65
|
+
projectPath: process.cwd(),
|
|
66
|
+
storage: this.storage,
|
|
67
|
+
dashboardUrl: this.dashboardUrl
|
|
68
|
+
};
|
|
69
|
+
// Register handlers
|
|
70
|
+
this.setupHandlers(context);
|
|
71
|
+
// Connect to stdio transport
|
|
72
|
+
const transport = new StdioServerTransport();
|
|
73
|
+
// Handle client disconnection
|
|
74
|
+
transport.onclose = async () => {
|
|
75
|
+
await this.stop();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
};
|
|
78
|
+
await this.server.connect(transport);
|
|
79
|
+
// Monitor stdin for client disconnection
|
|
80
|
+
process.stdin.on('end', async () => {
|
|
81
|
+
await this.stop();
|
|
82
|
+
process.exit(0);
|
|
83
|
+
});
|
|
84
|
+
process.stdin.on('error', async (error) => {
|
|
85
|
+
console.error('stdin error:', error);
|
|
86
|
+
await this.stop();
|
|
87
|
+
process.exit(1);
|
|
88
|
+
});
|
|
89
|
+
console.error(`MCP Request Context server initialized`);
|
|
90
|
+
console.error(`Dashboard URL: ${this.dashboardUrl}`);
|
|
91
|
+
}
|
|
92
|
+
setupHandlers(context) {
|
|
93
|
+
// Tool list handler
|
|
94
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
95
|
+
tools: registerTools()
|
|
96
|
+
}));
|
|
97
|
+
// Tool call handler
|
|
98
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
99
|
+
try {
|
|
100
|
+
return await handleToolCall(request.params.name, request.params.arguments || {}, context);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
+
throw new McpError(ErrorCode.InternalError, message);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async stop() {
|
|
109
|
+
try {
|
|
110
|
+
await this.dashboard.stop();
|
|
111
|
+
this.storage.stop();
|
|
112
|
+
await this.server.close();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('Error during shutdown:', error);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
getStorage() {
|
|
119
|
+
return this.storage;
|
|
120
|
+
}
|
|
121
|
+
getDashboardUrl() {
|
|
122
|
+
return this.dashboardUrl;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qB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OAAO,CACR,CAAC;YACJ,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACvD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
requestId: string;
|
|
8
|
-
}, {
|
|
9
|
-
requestId: string;
|
|
10
|
-
}>;
|
|
11
|
-
export type GetContextResponseInput = z.infer<typeof GetContextResponseInputSchema>;
|
|
12
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_NAME = "get_context_response";
|
|
13
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_TITLE = "Get Context Response";
|
|
14
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_DESCRIPTION = "Check the status of a context request and retrieve the human's response.\n\nUse this tool to poll for responses after creating a context request with 'request_context'.\n\n## Status Values\n- pending: Human has not yet responded\n- answered: Human has provided the requested information\n- cancelled: Request was cancelled\n- expired: Request expired without a response\n\nWhen status is 'answered', the response field contains the information provided by the human.";
|
|
15
|
-
export declare const GET_CONTEXT_RESPONSE_ANNOTATIONS: {
|
|
16
|
-
readOnlyHint: boolean;
|
|
17
|
-
destructiveHint: boolean;
|
|
18
|
-
idempotentHint: boolean;
|
|
19
|
-
openWorldHint: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function getContextResponseHandler(args: GetContextResponseInput, storage: ContextStorage, dashboardUrl?: string): Promise<MCPToolResponse>;
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export declare const getContextResponseTool: Tool;
|
|
5
|
+
export declare function getContextResponseHandler(args: Record<string, unknown>, context: ToolContext): ToolResponse;
|
|
22
6
|
//# sourceMappingURL=get-context-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-context-response.d.ts","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-context-response.d.ts","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,eAAO,MAAM,sBAAsB,EAAE,IAuBpC,CAAC;AAOF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,YAAY,CAgEd"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Tool definition using MCP Tool format with JSON Schema
|
|
2
|
+
export const getContextResponseTool = {
|
|
3
|
+
name: 'get_context_response',
|
|
4
|
+
description: `Check the status of a context request and retrieve the human's response.
|
|
5
|
+
|
|
6
|
+
Use this tool to poll for responses after creating a context request with 'request_context'.
|
|
7
|
+
|
|
8
|
+
## Status Values
|
|
9
|
+
- pending: Human has not yet responded
|
|
10
|
+
- answered: Human has provided the requested information
|
|
11
|
+
- cancelled: Request was cancelled
|
|
12
|
+
- expired: Request expired without a response
|
|
13
|
+
|
|
14
|
+
When status is 'answered', the response field contains the information provided by the human.`,
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
requestId: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The ID of the context request to check'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
required: ['requestId']
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export function getContextResponseHandler(args, context) {
|
|
27
|
+
const input = args;
|
|
28
|
+
// Validate required fields
|
|
29
|
+
if (!input.requestId) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
message: 'Missing required field: requestId is required'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const result = context.storage.getRequest(input.requestId);
|
|
36
|
+
if (result.isErr()) {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
message: `Failed to get context request: ${result.error.message}`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const request = result.value;
|
|
43
|
+
const isAnswered = request.status === 'answered';
|
|
44
|
+
const isPending = request.status === 'pending';
|
|
45
|
+
const canProceed = isAnswered;
|
|
46
|
+
const nextSteps = [];
|
|
47
|
+
if (isPending) {
|
|
48
|
+
nextSteps.push('BLOCKED - Human has not yet responded');
|
|
49
|
+
nextSteps.push('Continue polling with get_context_response');
|
|
50
|
+
if (context.dashboardUrl) {
|
|
51
|
+
nextSteps.push(`Human should respond at: ${context.dashboardUrl}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (isAnswered) {
|
|
55
|
+
nextSteps.push('UNBLOCKED - Response received');
|
|
56
|
+
nextSteps.push('Use the response data to proceed with your task');
|
|
57
|
+
}
|
|
58
|
+
else if (request.status === 'cancelled') {
|
|
59
|
+
nextSteps.push('Request was cancelled by human');
|
|
60
|
+
nextSteps.push('Consider creating a new request if still needed');
|
|
61
|
+
}
|
|
62
|
+
else if (request.status === 'expired') {
|
|
63
|
+
nextSteps.push('Request expired without response');
|
|
64
|
+
nextSteps.push('Create a new request if still needed');
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
message: isAnswered
|
|
69
|
+
? 'Context response received from human'
|
|
70
|
+
: `Request status: ${request.status}`,
|
|
71
|
+
data: {
|
|
72
|
+
requestId: request.id,
|
|
73
|
+
type: request.type,
|
|
74
|
+
priority: request.priority,
|
|
75
|
+
title: request.title,
|
|
76
|
+
status: request.status,
|
|
77
|
+
createdAt: request.createdAt,
|
|
78
|
+
answeredAt: request.answeredAt,
|
|
79
|
+
expiresAt: request.expiresAt,
|
|
80
|
+
response: request.response,
|
|
81
|
+
canProceed,
|
|
82
|
+
mustWait: isPending
|
|
83
|
+
},
|
|
84
|
+
nextSteps
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=get-context-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context-response.js","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE;;;;;;;;;;8FAU+E;IAC5F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wCAAwC;aACtD;SACF;QACD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MAAM,KAAK,WAAW,EAAE,CAAC;QAC1C,SAAS,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QACjD,SAAS,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACpE,CAAC;SAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACxC,SAAS,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACnD,SAAS,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAU;YACjB,CAAC,CAAC,sCAAsC;YACxC,CAAC,CAAC,mBAAmB,OAAO,CAAC,MAAM,EAAE;QACvC,IAAI,EAAE;YACJ,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU;YACV,QAAQ,EAAE,SAAS;SACpB;QACD,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { MCPToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export { ToolContext } from './types.js';
|
|
5
|
+
export declare function registerTools(): Tool[];
|
|
6
|
+
export declare function handleToolCall(name: string, args: Record<string, unknown>, context: ToolContext): MCPToolResponse;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAgB,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,wBAAgB,aAAa,IAAI,IAAI,EAAE,CAKtC;AAGD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,eAAe,CA6BjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { toMCPResponse } from '../core/types.js';
|
|
2
|
+
import { requestContextTool, requestContextHandler } from './request-context.js';
|
|
3
|
+
import { getContextResponseTool, getContextResponseHandler } from './get-context-response.js';
|
|
4
|
+
// Export all registered tools as Tool[] for ListToolsRequestSchema
|
|
5
|
+
export function registerTools() {
|
|
6
|
+
return [
|
|
7
|
+
requestContextTool,
|
|
8
|
+
getContextResponseTool
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
// Handle tool calls - central dispatcher
|
|
12
|
+
export function handleToolCall(name, args, context) {
|
|
13
|
+
let response;
|
|
14
|
+
let isError = false;
|
|
15
|
+
try {
|
|
16
|
+
switch (name) {
|
|
17
|
+
case 'request_context':
|
|
18
|
+
response = requestContextHandler(args, context);
|
|
19
|
+
break;
|
|
20
|
+
case 'get_context_response':
|
|
21
|
+
response = getContextResponseHandler(args, context);
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
// Check if the response indicates an error
|
|
27
|
+
isError = !response.success;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
31
|
+
response = {
|
|
32
|
+
success: false,
|
|
33
|
+
message: `Tool execution failed: ${errorMessage}`
|
|
34
|
+
};
|
|
35
|
+
isError = true;
|
|
36
|
+
}
|
|
37
|
+
return toMCPResponse(response, isError);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAM9F,mEAAmE;AACnE,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,kBAAkB;QAClB,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,IAA6B,EAC7B,OAAoB;IAEpB,IAAI,QAAsB,CAAC;IAC3B,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,IAAI,CAAC;QACH,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,iBAAiB;gBACpB,QAAQ,GAAG,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAChD,MAAM;YACR,KAAK,sBAAsB;gBACzB,QAAQ,GAAG,yBAAyB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACpD,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;QAED,2CAA2C;QAC3C,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC;IAE9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,QAAQ,GAAG;YACT,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,0BAA0B,YAAY,EAAE;SAClD,CAAC;QACF,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,46 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
priority: z.ZodDefault<z.ZodEnum<["critical", "high", "normal", "low"]>>;
|
|
7
|
-
title: z.ZodString;
|
|
8
|
-
description: z.ZodString;
|
|
9
|
-
url: z.ZodOptional<z.ZodString>;
|
|
10
|
-
hints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
-
expectedFormat: z.ZodOptional<z.ZodString>;
|
|
12
|
-
expiresInMinutes: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
-
}, "strict", z.ZodTypeAny, {
|
|
15
|
-
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
16
|
-
priority: "critical" | "high" | "normal" | "low";
|
|
17
|
-
title: string;
|
|
18
|
-
description: string;
|
|
19
|
-
url?: string | undefined;
|
|
20
|
-
hints?: string[] | undefined;
|
|
21
|
-
expectedFormat?: string | undefined;
|
|
22
|
-
tags?: string[] | undefined;
|
|
23
|
-
expiresInMinutes?: number | undefined;
|
|
24
|
-
}, {
|
|
25
|
-
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
26
|
-
title: string;
|
|
27
|
-
description: string;
|
|
28
|
-
priority?: "critical" | "high" | "normal" | "low" | undefined;
|
|
29
|
-
url?: string | undefined;
|
|
30
|
-
hints?: string[] | undefined;
|
|
31
|
-
expectedFormat?: string | undefined;
|
|
32
|
-
tags?: string[] | undefined;
|
|
33
|
-
expiresInMinutes?: number | undefined;
|
|
34
|
-
}>;
|
|
35
|
-
export type RequestContextInput = z.infer<typeof RequestContextInputSchema>;
|
|
36
|
-
export declare const REQUEST_CONTEXT_TOOL_NAME = "request_context";
|
|
37
|
-
export declare const REQUEST_CONTEXT_TOOL_TITLE = "Request Context from Human";
|
|
38
|
-
export declare const REQUEST_CONTEXT_TOOL_DESCRIPTION = "Request context/information from a human operator.\n\nUse this tool when you need information that:\n- Is behind a URL you cannot access\n- Requires reading documentation that is difficult to parse\n- Involves dependency/API information the human can provide faster\n- Would take multiple turns to gather but the human can provide directly\n\nThe human will see your request in a dashboard UI and can respond with the needed information.\n\n## Context Types\n- url_content: Content from a URL you cannot access\n- documentation: API/library documentation content\n- dependency_info: Package/dependency information\n- code_snippet: Specific code snippets\n- configuration: Configuration file contents\n- api_response: Example API responses\n- error_context: Additional error context\n- custom: Any other type of context\n\n## Priority Levels\n- critical: Blocking - cannot proceed without this\n- high: Important - needed soon\n- normal: Standard priority\n- low: Nice to have\n\nAfter creating a request, poll the status using 'get_context_response' tool.";
|
|
39
|
-
export declare const REQUEST_CONTEXT_ANNOTATIONS: {
|
|
40
|
-
readOnlyHint: boolean;
|
|
41
|
-
destructiveHint: boolean;
|
|
42
|
-
idempotentHint: boolean;
|
|
43
|
-
openWorldHint: boolean;
|
|
44
|
-
};
|
|
45
|
-
export declare function requestContextHandler(args: RequestContextInput, storage: ContextStorage, dashboardUrl?: string): Promise<MCPToolResponse>;
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export declare const requestContextTool: Tool;
|
|
5
|
+
export declare function requestContextHandler(args: Record<string, unknown>, context: ToolContext): ToolResponse;
|
|
46
6
|
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,eAAO,MAAM,kBAAkB,EAAE,IA2EhC,CAAC;AAeF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,YAAY,CAqDd"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Tool definition using MCP Tool format with JSON Schema
|
|
2
|
+
export const requestContextTool = {
|
|
3
|
+
name: 'request_context',
|
|
4
|
+
description: `Request context/information from a human operator.
|
|
5
|
+
|
|
6
|
+
Use this tool when you need information that:
|
|
7
|
+
- Is behind a URL you cannot access
|
|
8
|
+
- Requires reading documentation that is difficult to parse
|
|
9
|
+
- Involves dependency/API information the human can provide faster
|
|
10
|
+
- Would take multiple turns to gather but the human can provide directly
|
|
11
|
+
|
|
12
|
+
The human will see your request in a dashboard UI and can respond with the needed information.
|
|
13
|
+
|
|
14
|
+
## Context Types
|
|
15
|
+
- url_content: Content from a URL you cannot access
|
|
16
|
+
- documentation: API/library documentation content
|
|
17
|
+
- dependency_info: Package/dependency information
|
|
18
|
+
- code_snippet: Specific code snippets
|
|
19
|
+
- configuration: Configuration file contents
|
|
20
|
+
- api_response: Example API responses
|
|
21
|
+
- error_context: Additional error context
|
|
22
|
+
- custom: Any other type of context
|
|
23
|
+
|
|
24
|
+
## Priority Levels
|
|
25
|
+
- critical: Blocking - cannot proceed without this
|
|
26
|
+
- high: Important - needed soon
|
|
27
|
+
- normal: Standard priority
|
|
28
|
+
- low: Nice to have
|
|
29
|
+
|
|
30
|
+
After creating a request, poll the status using 'get_context_response' tool.`,
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
type: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: ['url_content', 'documentation', 'dependency_info', 'code_snippet', 'configuration', 'api_response', 'error_context', 'custom'],
|
|
37
|
+
description: 'The type of context being requested'
|
|
38
|
+
},
|
|
39
|
+
priority: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
enum: ['critical', 'high', 'normal', 'low'],
|
|
42
|
+
description: 'Priority level of the request (default: normal)'
|
|
43
|
+
},
|
|
44
|
+
title: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Brief title describing what information is needed (max 200 chars)'
|
|
47
|
+
},
|
|
48
|
+
description: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Detailed description of what information is needed and why (max 2000 chars)'
|
|
51
|
+
},
|
|
52
|
+
url: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'URL to fetch content from (for url_content type)'
|
|
55
|
+
},
|
|
56
|
+
hints: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: { type: 'string' },
|
|
59
|
+
description: 'Hints to help the human provide the right information'
|
|
60
|
+
},
|
|
61
|
+
expectedFormat: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Description of the expected response format'
|
|
64
|
+
},
|
|
65
|
+
expiresInMinutes: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
description: 'Request expiration time in minutes'
|
|
68
|
+
},
|
|
69
|
+
tags: {
|
|
70
|
+
type: 'array',
|
|
71
|
+
items: { type: 'string' },
|
|
72
|
+
description: 'Tags to categorize the request'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
required: ['type', 'title', 'description']
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export function requestContextHandler(args, context) {
|
|
79
|
+
const input = args;
|
|
80
|
+
// Validate required fields
|
|
81
|
+
if (!input.type || !input.title || !input.description) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
message: 'Missing required fields: type, title, and description are required'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const result = context.storage.createRequest({
|
|
88
|
+
type: input.type,
|
|
89
|
+
priority: input.priority ?? 'normal',
|
|
90
|
+
title: input.title,
|
|
91
|
+
description: input.description,
|
|
92
|
+
url: input.url,
|
|
93
|
+
hints: input.hints,
|
|
94
|
+
expectedFormat: input.expectedFormat,
|
|
95
|
+
expiresInMinutes: input.expiresInMinutes,
|
|
96
|
+
tags: input.tags
|
|
97
|
+
});
|
|
98
|
+
if (result.isErr()) {
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
message: `Failed to create context request: ${result.error.message}`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const request = result.value;
|
|
105
|
+
return {
|
|
106
|
+
success: true,
|
|
107
|
+
message: `Context request created successfully. Human will respond via dashboard.`,
|
|
108
|
+
data: {
|
|
109
|
+
requestId: request.id,
|
|
110
|
+
type: request.type,
|
|
111
|
+
priority: request.priority,
|
|
112
|
+
title: request.title,
|
|
113
|
+
status: request.status,
|
|
114
|
+
createdAt: request.createdAt,
|
|
115
|
+
expiresAt: request.expiresAt,
|
|
116
|
+
dashboardUrl: context.dashboardUrl
|
|
117
|
+
},
|
|
118
|
+
nextSteps: [
|
|
119
|
+
'BLOCKING - Wait for human response',
|
|
120
|
+
context.dashboardUrl
|
|
121
|
+
? `Human should respond at: ${context.dashboardUrl}`
|
|
122
|
+
: 'Dashboard is starting...',
|
|
123
|
+
`Poll status with: get_context_response requestId:"${request.id}"`,
|
|
124
|
+
'Do NOT proceed until response is received'
|
|
125
|
+
]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACtC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B8D;IAC3E,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,CAAC;gBACrI,WAAW,EAAE,qCAAqC;aACnD;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;gBAC3C,WAAW,EAAE,iDAAiD;aAC/D;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mEAAmE;aACjF;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6EAA6E;aAC3F;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kDAAkD;aAChE;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,uDAAuD;aACrE;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ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