@achieveai/hitl-mcp-server 1.2.0 → 2.1.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/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +131 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/git-context.d.ts +7 -0
- package/dist/git-context.d.ts.map +1 -0
- package/dist/git-context.js +29 -0
- package/dist/git-context.js.map +1 -0
- package/dist/mcp-server.d.ts +3 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +237 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/ntfy-transport.d.ts +41 -0
- package/dist/ntfy-transport.d.ts.map +1 -0
- package/dist/ntfy-transport.js +150 -0
- package/dist/ntfy-transport.js.map +1 -0
- package/dist/setup.d.ts +43 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +184 -0
- package/dist/setup.js.map +1 -0
- package/package.json +61 -63
- package/scripts/postinstall.js +33 -0
- package/LICENSE +0 -20
- package/README.md +0 -422
- package/config/claude-desktop.json +0 -11
- package/config/cursor-mcp.json +0 -17
- package/config/vscode-mcp.json +0 -17
- package/dist/__tests__/dialog-manager.test.d.ts +0 -2
- package/dist/__tests__/dialog-manager.test.d.ts.map +0 -1
- package/dist/__tests__/dialog-manager.test.js +0 -140
- package/dist/__tests__/dialog-manager.test.js.map +0 -1
- package/dist/dialog-manager.d.ts +0 -37
- package/dist/dialog-manager.d.ts.map +0 -1
- package/dist/dialog-manager.js +0 -644
- package/dist/dialog-manager.js.map +0 -1
- package/dist/dialog-manager.test.d.ts +0 -2
- package/dist/dialog-manager.test.d.ts.map +0 -1
- package/dist/dialog-manager.test.js +0 -156
- package/dist/dialog-manager.test.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -222
- package/dist/index.js.map +0 -1
- package/dist/test-client.d.ts +0 -3
- package/dist/test-client.d.ts.map +0 -1
- package/dist/test-client.js +0 -125
- package/dist/test-client.js.map +0 -1
- package/dist/test-dialog-manager.d.ts +0 -2
- package/dist/test-dialog-manager.d.ts.map +0 -1
- package/dist/test-dialog-manager.js +0 -156
- package/dist/test-dialog-manager.js.map +0 -1
- package/example-usage.md +0 -223
- package/mcp.json +0 -152
- package/sounds/notification.wav +0 -0
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// Simple test to verify the dialog manager works
|
|
2
|
-
import { DialogManager } from './dialog-manager.js';
|
|
3
|
-
async function runTests() {
|
|
4
|
-
console.log('Starting DialogManager tests...\n');
|
|
5
|
-
const manager = new DialogManager();
|
|
6
|
-
let testsPassed = 0;
|
|
7
|
-
let testsFailed = 0;
|
|
8
|
-
// Test 1: Initialization
|
|
9
|
-
try {
|
|
10
|
-
const port = await manager.initialize();
|
|
11
|
-
console.log('✓ Test 1 - Initialization: Server started on port', port);
|
|
12
|
-
testsPassed++;
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
console.error('✗ Test 1 - Initialization failed:', error);
|
|
16
|
-
testsFailed++;
|
|
17
|
-
}
|
|
18
|
-
// Test 2: HTML generation with XSS protection
|
|
19
|
-
try {
|
|
20
|
-
const html = manager.generateDialogHTML({
|
|
21
|
-
id: 'test',
|
|
22
|
-
question: '<script>alert("XSS")</script>',
|
|
23
|
-
options: [
|
|
24
|
-
{
|
|
25
|
-
label: '<b>Bold</b>',
|
|
26
|
-
value: 'test',
|
|
27
|
-
description: '"Quotes" & \'apostrophes\''
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
allowMultiple: false,
|
|
31
|
-
allowOther: true
|
|
32
|
-
});
|
|
33
|
-
if (html.includes('<script>alert') || html.includes('<b>Bold</b>')) {
|
|
34
|
-
throw new Error('XSS protection failed');
|
|
35
|
-
}
|
|
36
|
-
if (!html.includes('<script>') || !html.includes('<b>')) {
|
|
37
|
-
throw new Error('HTML should be escaped');
|
|
38
|
-
}
|
|
39
|
-
console.log('✓ Test 2 - XSS Protection: HTML properly escaped');
|
|
40
|
-
testsPassed++;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error('✗ Test 2 - XSS Protection failed:', error);
|
|
44
|
-
testsFailed++;
|
|
45
|
-
}
|
|
46
|
-
// Test 3: Radio vs Checkbox rendering
|
|
47
|
-
try {
|
|
48
|
-
const radioHtml = manager.generateDialogHTML({
|
|
49
|
-
id: 'test',
|
|
50
|
-
question: 'Choose one',
|
|
51
|
-
options: [
|
|
52
|
-
{ label: 'A', value: 'a' },
|
|
53
|
-
{ label: 'B', value: 'b' }
|
|
54
|
-
],
|
|
55
|
-
allowMultiple: false,
|
|
56
|
-
allowOther: false
|
|
57
|
-
});
|
|
58
|
-
const checkboxHtml = manager.generateDialogHTML({
|
|
59
|
-
id: 'test',
|
|
60
|
-
question: 'Choose many',
|
|
61
|
-
options: [
|
|
62
|
-
{ label: 'A', value: 'a' },
|
|
63
|
-
{ label: 'B', value: 'b' }
|
|
64
|
-
],
|
|
65
|
-
allowMultiple: true,
|
|
66
|
-
allowOther: false
|
|
67
|
-
});
|
|
68
|
-
if (!radioHtml.includes('type="radio"') || radioHtml.includes('type="checkbox"')) {
|
|
69
|
-
throw new Error('Single choice should use radio buttons');
|
|
70
|
-
}
|
|
71
|
-
if (!checkboxHtml.includes('type="checkbox"') || checkboxHtml.includes('type="radio"')) {
|
|
72
|
-
throw new Error('Multiple choice should use checkboxes');
|
|
73
|
-
}
|
|
74
|
-
console.log('✓ Test 3 - Input Types: Correct radio/checkbox rendering');
|
|
75
|
-
testsPassed++;
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.error('✗ Test 3 - Input Types failed:', error);
|
|
79
|
-
testsFailed++;
|
|
80
|
-
}
|
|
81
|
-
// Test 4: Other field inclusion
|
|
82
|
-
try {
|
|
83
|
-
const withOther = manager.generateDialogHTML({
|
|
84
|
-
id: 'test',
|
|
85
|
-
question: 'Choose',
|
|
86
|
-
options: [{ label: 'A', value: 'a' }],
|
|
87
|
-
allowMultiple: false,
|
|
88
|
-
allowOther: true
|
|
89
|
-
});
|
|
90
|
-
const withoutOther = manager.generateDialogHTML({
|
|
91
|
-
id: 'test',
|
|
92
|
-
question: 'Choose',
|
|
93
|
-
options: [{ label: 'A', value: 'a' }],
|
|
94
|
-
allowMultiple: false,
|
|
95
|
-
allowOther: false
|
|
96
|
-
});
|
|
97
|
-
if (!withOther.includes('other-input')) {
|
|
98
|
-
throw new Error('Should include other field when allowed');
|
|
99
|
-
}
|
|
100
|
-
if (withoutOther.includes('Other (please specify)')) {
|
|
101
|
-
throw new Error('Should not include other field when not allowed');
|
|
102
|
-
}
|
|
103
|
-
console.log('✓ Test 4 - Other Field: Correctly included/excluded');
|
|
104
|
-
testsPassed++;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.error('✗ Test 4 - Other Field failed:', error);
|
|
108
|
-
testsFailed++;
|
|
109
|
-
}
|
|
110
|
-
// Test 5: Context inclusion
|
|
111
|
-
try {
|
|
112
|
-
const withContext = manager.generateDialogHTML({
|
|
113
|
-
id: 'test',
|
|
114
|
-
question: 'Test question',
|
|
115
|
-
options: [{ label: 'Option 1', value: 'opt1' }],
|
|
116
|
-
allowMultiple: false,
|
|
117
|
-
allowOther: false,
|
|
118
|
-
context: 'Important context information'
|
|
119
|
-
});
|
|
120
|
-
const withoutContext = manager.generateDialogHTML({
|
|
121
|
-
id: 'test',
|
|
122
|
-
question: 'Test question',
|
|
123
|
-
options: [{ label: 'Option 1', value: 'opt1' }],
|
|
124
|
-
allowMultiple: false,
|
|
125
|
-
allowOther: false
|
|
126
|
-
});
|
|
127
|
-
if (!withContext.includes('Important context information')) {
|
|
128
|
-
throw new Error('Should include context when provided');
|
|
129
|
-
}
|
|
130
|
-
if (withoutContext.includes('Context:')) {
|
|
131
|
-
throw new Error('Should not include context section when not provided');
|
|
132
|
-
}
|
|
133
|
-
console.log('✓ Test 5 - Context: Correctly included/excluded');
|
|
134
|
-
testsPassed++;
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
console.error('✗ Test 5 - Context failed:', error);
|
|
138
|
-
testsFailed++;
|
|
139
|
-
}
|
|
140
|
-
// Cleanup
|
|
141
|
-
await manager.close();
|
|
142
|
-
// Summary
|
|
143
|
-
console.log(`\n========== Test Summary ==========`);
|
|
144
|
-
console.log(`Passed: ${testsPassed}`);
|
|
145
|
-
console.log(`Failed: ${testsFailed}`);
|
|
146
|
-
console.log(`Total: ${testsPassed + testsFailed}`);
|
|
147
|
-
if (testsFailed > 0) {
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// Run tests
|
|
152
|
-
runTests().catch(error => {
|
|
153
|
-
console.error('Test suite failed:', error);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
});
|
|
156
|
-
//# sourceMappingURL=dialog-manager.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-manager.test.js","sourceRoot":"","sources":["../src/dialog-manager.test.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,KAAK,UAAU,QAAQ;IACrB,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAEjD,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,yBAAyB;IACzB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE,IAAI,CAAC,CAAC;QACvE,WAAW,EAAE,CAAC;IAChB,C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ED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { DialogManager } from './dialog-manager.js';
|
|
6
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
-
const TOOL_NAME = 'ask_human';
|
|
8
|
-
const SERVER_NAME = 'hitl-mcp-server';
|
|
9
|
-
const SERVER_VERSION = '1.0.0';
|
|
10
|
-
class HumanInTheLoopServer {
|
|
11
|
-
server;
|
|
12
|
-
dialogManager;
|
|
13
|
-
constructor() {
|
|
14
|
-
this.server = new Server({
|
|
15
|
-
name: SERVER_NAME,
|
|
16
|
-
version: SERVER_VERSION,
|
|
17
|
-
}, {
|
|
18
|
-
capabilities: {
|
|
19
|
-
tools: {},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
this.dialogManager = new DialogManager();
|
|
23
|
-
this.setupHandlers();
|
|
24
|
-
}
|
|
25
|
-
setupHandlers() {
|
|
26
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
27
|
-
tools: [
|
|
28
|
-
{
|
|
29
|
-
name: TOOL_NAME,
|
|
30
|
-
description: `CRITICAL: Use this tool whenever you have ANY doubt or need human decision-making. This tool is ESSENTIAL for:
|
|
31
|
-
|
|
32
|
-
WHEN TO USE (err on the side of asking):
|
|
33
|
-
• You have even slight uncertainty about what the user wants
|
|
34
|
-
• You need clarification on ambiguous requirements or instructions
|
|
35
|
-
• The user explicitly told you to ask for their input on decisions
|
|
36
|
-
• Multiple valid approaches exist and you're unsure which to choose
|
|
37
|
-
• A decision could have significant consequences
|
|
38
|
-
• You're about to make assumptions that might be wrong
|
|
39
|
-
• You need confirmation before critical or irreversible actions
|
|
40
|
-
• You need additional context not provided in your instructions
|
|
41
|
-
|
|
42
|
-
HOW TO USE:
|
|
43
|
-
• Provide clear, specific options for the human to choose from
|
|
44
|
-
• Think carefully about which option you would recommend and mark it with "(RECOMMENDED)" in the label
|
|
45
|
-
Example: { label: "PostgreSQL (RECOMMENDED)", value: "postgres", description: "Best for complex queries" }
|
|
46
|
-
• The human can select one or more options AND provide additional context
|
|
47
|
-
• The "(RECOMMENDED)" marker helps guide the user but won't appear in the returned value
|
|
48
|
-
|
|
49
|
-
This tool opens an interactive browser dialog with a pleasant notification sound. The human can select options and optionally provide additional context to guide your next steps.
|
|
50
|
-
|
|
51
|
-
IMPORTANT: When in doubt, ASK. Using this tool is far better than making incorrect assumptions. Getting human input ensures accuracy and alignment with user expectations.`,
|
|
52
|
-
inputSchema: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
properties: {
|
|
55
|
-
question: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
description: 'The question or decision you need help with. Be clear and specific.'
|
|
58
|
-
},
|
|
59
|
-
options: {
|
|
60
|
-
type: 'array',
|
|
61
|
-
description: 'Array of possible choices for the human to select from',
|
|
62
|
-
items: {
|
|
63
|
-
type: 'object',
|
|
64
|
-
properties: {
|
|
65
|
-
label: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
description: 'Display label for this option'
|
|
68
|
-
},
|
|
69
|
-
value: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
description: 'Value to return if this option is selected'
|
|
72
|
-
},
|
|
73
|
-
description: {
|
|
74
|
-
type: 'string',
|
|
75
|
-
description: 'Optional detailed description of what this option means'
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
required: ['label', 'value']
|
|
79
|
-
},
|
|
80
|
-
minItems: 1
|
|
81
|
-
},
|
|
82
|
-
allowMultiple: {
|
|
83
|
-
type: 'boolean',
|
|
84
|
-
description: 'Whether to allow selecting multiple options (checkbox vs radio)',
|
|
85
|
-
default: true
|
|
86
|
-
},
|
|
87
|
-
allowOther: {
|
|
88
|
-
type: 'boolean',
|
|
89
|
-
description: 'Whether to show an "Additional Context" text field where the user can provide supplementary information alongside their selection(s)',
|
|
90
|
-
default: true
|
|
91
|
-
},
|
|
92
|
-
context: {
|
|
93
|
-
type: 'string',
|
|
94
|
-
description: 'Additional context to help the human understand the situation'
|
|
95
|
-
},
|
|
96
|
-
timeout: {
|
|
97
|
-
type: 'number',
|
|
98
|
-
description: 'Timeout in milliseconds (default: no timeout)',
|
|
99
|
-
minimum: 1000,
|
|
100
|
-
maximum: 3600000
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
required: ['question', 'options']
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}));
|
|
108
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
109
|
-
if (request.params.name !== TOOL_NAME) {
|
|
110
|
-
throw new McpError(ErrorCode.MethodNotFound, `Tool not found: ${request.params.name}`);
|
|
111
|
-
}
|
|
112
|
-
const args = request.params.arguments;
|
|
113
|
-
if (!args.question || !Array.isArray(args.options) || args.options.length === 0) {
|
|
114
|
-
throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters: question and options array');
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
const dialogOptions = args.options.map((opt) => ({
|
|
118
|
-
label: opt.label || opt.value,
|
|
119
|
-
value: opt.value,
|
|
120
|
-
description: opt.description
|
|
121
|
-
}));
|
|
122
|
-
const response = await this.dialogManager.showDialog({
|
|
123
|
-
id: uuidv4(),
|
|
124
|
-
question: args.question,
|
|
125
|
-
options: dialogOptions,
|
|
126
|
-
allowMultiple: args.allowMultiple !== false,
|
|
127
|
-
allowOther: args.allowOther !== false,
|
|
128
|
-
context: args.context,
|
|
129
|
-
timeout: args.timeout
|
|
130
|
-
});
|
|
131
|
-
// Helper function to strip (RECOMMENDED) markers from values
|
|
132
|
-
const stripRecommended = (value) => {
|
|
133
|
-
return value.replace(/\s*\(RECOMMENDED\)\s*/gi, '').trim();
|
|
134
|
-
};
|
|
135
|
-
let result = {
|
|
136
|
-
success: true,
|
|
137
|
-
timestamp: response.timestamp
|
|
138
|
-
};
|
|
139
|
-
if (response.otherText === 'SKIPPED') {
|
|
140
|
-
result.skipped = true;
|
|
141
|
-
result.response = 'User skipped this question';
|
|
142
|
-
result.responseType = 'skipped';
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
// Clean the selected values
|
|
146
|
-
const cleanedValues = response.selectedValues.map(stripRecommended);
|
|
147
|
-
// Include selected values if any
|
|
148
|
-
if (cleanedValues.length > 0) {
|
|
149
|
-
result.selectedValues = args.allowMultiple ? cleanedValues : cleanedValues[0];
|
|
150
|
-
}
|
|
151
|
-
// Include context if provided
|
|
152
|
-
if (response.otherText && response.otherText !== '') {
|
|
153
|
-
result.context = response.otherText;
|
|
154
|
-
}
|
|
155
|
-
// Determine response type
|
|
156
|
-
if (cleanedValues.length > 0 && result.context) {
|
|
157
|
-
result.responseType = 'selection_with_context';
|
|
158
|
-
}
|
|
159
|
-
else if (cleanedValues.length > 0) {
|
|
160
|
-
result.responseType = 'selection';
|
|
161
|
-
}
|
|
162
|
-
else if (result.context) {
|
|
163
|
-
result.responseType = 'context_only';
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
result.responseType = 'none';
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
content: [
|
|
171
|
-
{
|
|
172
|
-
type: 'text',
|
|
173
|
-
text: JSON.stringify(result, null, 2)
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
console.error('Dialog error:', error);
|
|
180
|
-
if (error instanceof Error && error.message === 'Dialog timeout') {
|
|
181
|
-
return {
|
|
182
|
-
content: [
|
|
183
|
-
{
|
|
184
|
-
type: 'text',
|
|
185
|
-
text: JSON.stringify({
|
|
186
|
-
success: false,
|
|
187
|
-
error: 'timeout',
|
|
188
|
-
message: 'The user did not respond within the timeout period'
|
|
189
|
-
}, null, 2)
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
throw new McpError(ErrorCode.InternalError, `Failed to show dialog: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
async run() {
|
|
199
|
-
const transport = new StdioServerTransport();
|
|
200
|
-
await this.dialogManager.initialize();
|
|
201
|
-
await this.server.connect(transport);
|
|
202
|
-
console.error(`${SERVER_NAME} v${SERVER_VERSION} running on stdio`);
|
|
203
|
-
process.on('SIGINT', async () => {
|
|
204
|
-
await this.cleanup();
|
|
205
|
-
process.exit(0);
|
|
206
|
-
});
|
|
207
|
-
process.on('SIGTERM', async () => {
|
|
208
|
-
await this.cleanup();
|
|
209
|
-
process.exit(0);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
async cleanup() {
|
|
213
|
-
console.error('Shutting down...');
|
|
214
|
-
await this.dialogManager.close();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const server = new HumanInTheLoopServer();
|
|
218
|
-
server.run().catch((error) => {
|
|
219
|
-
console.error('Server error:', error);
|
|
220
|
-
process.exit(1);
|
|
221
|
-
});
|
|
222
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,QAAQ,E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AAI,oBAAoB,EAAE,CAAC;AAC1C,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/test-client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-client.d.ts","sourceRoot":"","sources":["../src/test-client.ts"],"names":[],"mappings":""}
|
package/dist/test-client.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { DialogManager } from './dialog-manager.js';
|
|
3
|
-
async function testDialogManager() {
|
|
4
|
-
console.log('Starting Dialog Manager Test...\n');
|
|
5
|
-
const manager = new DialogManager();
|
|
6
|
-
await manager.initialize();
|
|
7
|
-
const testCases = [
|
|
8
|
-
{
|
|
9
|
-
name: 'Single Choice Question',
|
|
10
|
-
request: {
|
|
11
|
-
id: 'test-1',
|
|
12
|
-
question: 'Which approach should I use for implementing the authentication system?',
|
|
13
|
-
options: [
|
|
14
|
-
{
|
|
15
|
-
label: 'JWT Tokens',
|
|
16
|
-
value: 'jwt',
|
|
17
|
-
description: 'Stateless authentication using JSON Web Tokens'
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
label: 'Session-based',
|
|
21
|
-
value: 'session',
|
|
22
|
-
description: 'Traditional server-side session management'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: 'OAuth 2.0',
|
|
26
|
-
value: 'oauth',
|
|
27
|
-
description: 'Delegated authentication using OAuth providers'
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
allowMultiple: false,
|
|
31
|
-
allowOther: true,
|
|
32
|
-
context: `This is for a new web application with expected **10k daily active users**.
|
|
33
|
-
|
|
34
|
-
**Requirements:**
|
|
35
|
-
- Must support \`refresh tokens\`
|
|
36
|
-
- Should integrate with existing \`Redis\` cache
|
|
37
|
-
- Need to handle \`multi-device\` sessions
|
|
38
|
-
|
|
39
|
-
> **Note:** Security is critical - use industry standard practices.
|
|
40
|
-
|
|
41
|
-
\`\`\`javascript
|
|
42
|
-
// Example usage
|
|
43
|
-
const token = generateToken(user);
|
|
44
|
-
\`\`\`
|
|
45
|
-
|
|
46
|
-
See [OAuth 2.0 Spec](https://oauth.net/2/) for details.`
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'Multiple Choice Question',
|
|
51
|
-
request: {
|
|
52
|
-
id: 'test-2',
|
|
53
|
-
question: 'Which files should I include in the commit?',
|
|
54
|
-
options: [
|
|
55
|
-
{
|
|
56
|
-
label: 'src/auth.ts',
|
|
57
|
-
value: 'auth.ts',
|
|
58
|
-
description: 'Main authentication module'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: 'src/middleware.ts',
|
|
62
|
-
value: 'middleware.ts',
|
|
63
|
-
description: 'Authentication middleware'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
label: 'tests/auth.test.ts',
|
|
67
|
-
value: 'auth.test.ts',
|
|
68
|
-
description: 'Unit tests for authentication'
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'README.md',
|
|
72
|
-
value: 'readme',
|
|
73
|
-
description: 'Updated documentation'
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
allowMultiple: true,
|
|
77
|
-
allowOther: false,
|
|
78
|
-
context: 'Several files have been modified in the working directory'
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: 'Timeout Test',
|
|
83
|
-
request: {
|
|
84
|
-
id: 'test-3',
|
|
85
|
-
question: 'This dialog will timeout in 10 seconds. Do you want to proceed?',
|
|
86
|
-
options: [
|
|
87
|
-
{
|
|
88
|
-
label: 'Yes',
|
|
89
|
-
value: 'yes'
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
label: 'No',
|
|
93
|
-
value: 'no'
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
allowMultiple: false,
|
|
97
|
-
allowOther: false,
|
|
98
|
-
timeout: 10000
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
|
-
for (const testCase of testCases) {
|
|
103
|
-
console.log(`\\n=== ${testCase.name} ===`);
|
|
104
|
-
console.log(`Question: ${testCase.request.question}`);
|
|
105
|
-
console.log('Waiting for user response...');
|
|
106
|
-
try {
|
|
107
|
-
const response = await manager.showDialog(testCase.request);
|
|
108
|
-
console.log('Response received:', JSON.stringify(response, null, 2));
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
112
|
-
}
|
|
113
|
-
// Wait a bit between tests
|
|
114
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
115
|
-
}
|
|
116
|
-
console.log('\\nAll tests completed. Closing dialog manager...');
|
|
117
|
-
await manager.close();
|
|
118
|
-
process.exit(0);
|
|
119
|
-
}
|
|
120
|
-
// Run the test
|
|
121
|
-
testDialogManager().catch(error => {
|
|
122
|
-
console.error('Test failed:', error);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
});
|
|
125
|
-
//# sourceMappingURL=test-client.js.map
|
package/dist/test-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-client.js","sourceRoot":"","sources":["../src/test-client.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,KAAK,UAAU,iBAAiB;IAC9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAEjD,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IACpC,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAE3B,MAAM,SAAS,GAAG;QAChB;YACE,IAAI,EAAE,wB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