@nanocollective/nanocoder 1.22.4 → 1.23.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/README.md +93 -30
- package/assets/nanocoder-vscode.vsix +0 -0
- package/dist/ai-sdk-client/chat/chat-handler.js +1 -1
- package/dist/ai-sdk-client/chat/chat-handler.js.map +1 -1
- package/dist/ai-sdk-client/chat/tool-processor.d.ts +1 -1
- package/dist/ai-sdk-client/chat/tool-processor.d.ts.map +1 -1
- package/dist/ai-sdk-client/chat/tool-processor.js +8 -3
- package/dist/ai-sdk-client/chat/tool-processor.js.map +1 -1
- package/dist/ai-sdk-client/error-handling/error-parser.d.ts.map +1 -1
- package/dist/ai-sdk-client/error-handling/error-parser.js +4 -1
- package/dist/ai-sdk-client/error-handling/error-parser.js.map +1 -1
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/App.js +106 -11
- package/dist/app/App.js.map +1 -1
- package/dist/app/components/chat-input.d.ts +6 -1
- package/dist/app/components/chat-input.d.ts.map +1 -1
- package/dist/app/components/chat-input.js +9 -7
- package/dist/app/components/chat-input.js.map +1 -1
- package/dist/app/utils/app-util.d.ts +5 -0
- package/dist/app/utils/app-util.d.ts.map +1 -1
- package/dist/app/utils/app-util.js +265 -0
- package/dist/app/utils/app-util.js.map +1 -1
- package/dist/client-factory.d.ts.map +1 -1
- package/dist/client-factory.js +3 -2
- package/dist/client-factory.js.map +1 -1
- package/dist/commands/context-max.d.ts +15 -0
- package/dist/commands/context-max.d.ts.map +1 -0
- package/dist/commands/context-max.js +22 -0
- package/dist/commands/context-max.js.map +1 -0
- package/dist/commands/custom-commands.d.ts.map +1 -1
- package/dist/commands/custom-commands.js +88 -4
- package/dist/commands/custom-commands.js.map +1 -1
- package/dist/commands/exit.d.ts.map +1 -1
- package/dist/commands/exit.js +5 -8
- package/dist/commands/exit.js.map +1 -1
- package/dist/commands/ide.d.ts +3 -0
- package/dist/commands/ide.d.ts.map +1 -0
- package/dist/commands/ide.js +10 -0
- package/dist/commands/ide.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/schedule.d.ts +3 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +177 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +4 -3
- package/dist/commands/usage.js.map +1 -1
- package/dist/components/development-mode-indicator.d.ts +3 -2
- package/dist/components/development-mode-indicator.d.ts.map +1 -1
- package/dist/components/development-mode-indicator.js +23 -9
- package/dist/components/development-mode-indicator.js.map +1 -1
- package/dist/components/ide-selector.d.ts +7 -0
- package/dist/components/ide-selector.d.ts.map +1 -0
- package/dist/components/ide-selector.js +17 -0
- package/dist/components/ide-selector.js.map +1 -0
- package/dist/components/question-prompt.d.ts +8 -0
- package/dist/components/question-prompt.d.ts.map +1 -0
- package/dist/components/question-prompt.js +58 -0
- package/dist/components/question-prompt.js.map +1 -0
- package/dist/components/scheduler-view.d.ts +14 -0
- package/dist/components/scheduler-view.d.ts.map +1 -0
- package/dist/components/scheduler-view.js +17 -0
- package/dist/components/scheduler-view.js.map +1 -0
- package/dist/components/text-input.d.ts +13 -0
- package/dist/components/text-input.d.ts.map +1 -0
- package/dist/components/text-input.js +175 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/components/user-input.d.ts +2 -1
- package/dist/components/user-input.d.ts.map +1 -1
- package/dist/components/user-input.js +8 -15
- package/dist/components/user-input.js.map +1 -1
- package/dist/config/themes.d.ts.map +1 -1
- package/dist/config/themes.js +20 -0
- package/dist/config/themes.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +55 -0
- package/dist/constants.js.map +1 -1
- package/dist/custom-commands/command-integration.d.ts +24 -0
- package/dist/custom-commands/command-integration.d.ts.map +1 -0
- package/dist/custom-commands/command-integration.js +68 -0
- package/dist/custom-commands/command-integration.js.map +1 -0
- package/dist/custom-commands/executor.d.ts.map +1 -1
- package/dist/custom-commands/executor.js +12 -2
- package/dist/custom-commands/executor.js.map +1 -1
- package/dist/custom-commands/loader.d.ts +33 -5
- package/dist/custom-commands/loader.d.ts.map +1 -1
- package/dist/custom-commands/loader.js +191 -18
- package/dist/custom-commands/loader.js.map +1 -1
- package/dist/custom-commands/parser.d.ts.map +1 -1
- package/dist/custom-commands/parser.js +115 -48
- package/dist/custom-commands/parser.js.map +1 -1
- package/dist/hooks/chat-handler/conversation/conversation-loop.d.ts +1 -1
- package/dist/hooks/chat-handler/conversation/conversation-loop.d.ts.map +1 -1
- package/dist/hooks/chat-handler/conversation/conversation-loop.js +37 -5
- package/dist/hooks/chat-handler/conversation/conversation-loop.js.map +1 -1
- package/dist/hooks/chat-handler/conversation/tool-executor.js +1 -1
- package/dist/hooks/chat-handler/conversation/tool-executor.js.map +1 -1
- package/dist/hooks/chat-handler/types.d.ts +3 -1
- package/dist/hooks/chat-handler/types.d.ts.map +1 -1
- package/dist/hooks/chat-handler/useChatHandler.d.ts +1 -1
- package/dist/hooks/chat-handler/useChatHandler.d.ts.map +1 -1
- package/dist/hooks/chat-handler/useChatHandler.js +13 -5
- package/dist/hooks/chat-handler/useChatHandler.js.map +1 -1
- package/dist/hooks/useAppHandlers.d.ts +2 -0
- package/dist/hooks/useAppHandlers.d.ts.map +1 -1
- package/dist/hooks/useAppHandlers.js +5 -0
- package/dist/hooks/useAppHandlers.js.map +1 -1
- package/dist/hooks/useAppInitialization.d.ts.map +1 -1
- package/dist/hooks/useAppInitialization.js +4 -1
- package/dist/hooks/useAppInitialization.js.map +1 -1
- package/dist/hooks/useAppState.d.ts +15 -0
- package/dist/hooks/useAppState.d.ts.map +1 -1
- package/dist/hooks/useAppState.js +23 -0
- package/dist/hooks/useAppState.js.map +1 -1
- package/dist/hooks/useContextPercentage.d.ts +17 -0
- package/dist/hooks/useContextPercentage.d.ts.map +1 -0
- package/dist/hooks/useContextPercentage.js +71 -0
- package/dist/hooks/useContextPercentage.js.map +1 -0
- package/dist/hooks/useModeHandlers.d.ts +4 -1
- package/dist/hooks/useModeHandlers.d.ts.map +1 -1
- package/dist/hooks/useModeHandlers.js +11 -1
- package/dist/hooks/useModeHandlers.js.map +1 -1
- package/dist/hooks/useNonInteractiveMode.d.ts.map +1 -1
- package/dist/hooks/useNonInteractiveMode.js +3 -1
- package/dist/hooks/useNonInteractiveMode.js.map +1 -1
- package/dist/hooks/useSchedulerMode.d.ts +30 -0
- package/dist/hooks/useSchedulerMode.d.ts.map +1 -0
- package/dist/hooks/useSchedulerMode.js +99 -0
- package/dist/hooks/useSchedulerMode.js.map +1 -0
- package/dist/lsp/lsp-manager.d.ts.map +1 -1
- package/dist/lsp/lsp-manager.js +10 -0
- package/dist/lsp/lsp-manager.js.map +1 -1
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +20 -1
- package/dist/mcp/mcp-client.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/models-dev-client.d.ts +8 -1
- package/dist/models/models-dev-client.d.ts.map +1 -1
- package/dist/models/models-dev-client.js +116 -88
- package/dist/models/models-dev-client.js.map +1 -1
- package/dist/schedule/cron.d.ts +14 -0
- package/dist/schedule/cron.d.ts.map +1 -0
- package/dist/schedule/cron.js +107 -0
- package/dist/schedule/cron.js.map +1 -0
- package/dist/schedule/index.d.ts +4 -0
- package/dist/schedule/index.d.ts.map +1 -0
- package/dist/schedule/index.js +4 -0
- package/dist/schedule/index.js.map +1 -0
- package/dist/schedule/runner.d.ts +42 -0
- package/dist/schedule/runner.d.ts.map +1 -0
- package/dist/schedule/runner.js +136 -0
- package/dist/schedule/runner.js.map +1 -0
- package/dist/schedule/storage.d.ts +9 -0
- package/dist/schedule/storage.d.ts.map +1 -0
- package/dist/schedule/storage.js +68 -0
- package/dist/schedule/storage.js.map +1 -0
- package/dist/schedule/types.d.ts +24 -0
- package/dist/schedule/types.d.ts.map +1 -0
- package/dist/schedule/types.js +2 -0
- package/dist/schedule/types.js.map +1 -0
- package/dist/services/bash-executor.d.ts.map +1 -1
- package/dist/services/bash-executor.js +5 -0
- package/dist/services/bash-executor.js.map +1 -1
- package/dist/tool-calling/json-parser.d.ts +7 -3
- package/dist/tool-calling/json-parser.d.ts.map +1 -1
- package/dist/tool-calling/json-parser.js +59 -23
- package/dist/tool-calling/json-parser.js.map +1 -1
- package/dist/tool-calling/tool-parser.d.ts +2 -2
- package/dist/tool-calling/tool-parser.d.ts.map +1 -1
- package/dist/tool-calling/tool-parser.js +27 -23
- package/dist/tool-calling/tool-parser.js.map +1 -1
- package/dist/tool-calling/xml-parser.d.ts +8 -4
- package/dist/tool-calling/xml-parser.d.ts.map +1 -1
- package/dist/tool-calling/xml-parser.js +15 -5
- package/dist/tool-calling/xml-parser.js.map +1 -1
- package/dist/tools/ask-question.d.ts +3 -0
- package/dist/tools/ask-question.d.ts.map +1 -0
- package/dist/tools/ask-question.js +66 -0
- package/dist/tools/ask-question.js.map +1 -0
- package/dist/tools/execute-bash.js +1 -1
- package/dist/tools/execute-bash.js.map +1 -1
- package/dist/tools/file-ops/copy-file.d.ts +3 -0
- package/dist/tools/file-ops/copy-file.d.ts.map +1 -0
- package/dist/tools/file-ops/copy-file.js +126 -0
- package/dist/tools/file-ops/copy-file.js.map +1 -0
- package/dist/tools/file-ops/create-directory.d.ts +3 -0
- package/dist/tools/file-ops/create-directory.d.ts.map +1 -0
- package/dist/tools/file-ops/create-directory.js +76 -0
- package/dist/tools/file-ops/create-directory.js.map +1 -0
- package/dist/tools/file-ops/delete-file.d.ts +3 -0
- package/dist/tools/file-ops/delete-file.d.ts.map +1 -0
- package/dist/tools/file-ops/delete-file.js +88 -0
- package/dist/tools/file-ops/delete-file.js.map +1 -0
- package/dist/tools/file-ops/index.d.ts +3 -0
- package/dist/tools/file-ops/index.d.ts.map +1 -0
- package/dist/tools/file-ops/index.js +8 -0
- package/dist/tools/file-ops/index.js.map +1 -0
- package/dist/tools/file-ops/move-file.d.ts +3 -0
- package/dist/tools/file-ops/move-file.d.ts.map +1 -0
- package/dist/tools/file-ops/move-file.js +126 -0
- package/dist/tools/file-ops/move-file.js.map +1 -0
- package/dist/tools/file-ops/string-replace.d.ts +3 -0
- package/dist/tools/file-ops/string-replace.d.ts.map +1 -0
- package/dist/tools/{string-replace.js → file-ops/string-replace.js} +17 -17
- package/dist/tools/file-ops/string-replace.js.map +1 -0
- package/dist/tools/file-ops/write-file.d.ts +3 -0
- package/dist/tools/file-ops/write-file.d.ts.map +1 -0
- package/dist/tools/{write-file.js → file-ops/write-file.js} +31 -17
- package/dist/tools/file-ops/write-file.js.map +1 -0
- package/dist/tools/git/git-reset.js +1 -1
- package/dist/tools/git/git-reset.js.map +1 -1
- package/dist/tools/git/index.js +3 -3
- package/dist/tools/git/index.js.map +1 -1
- package/dist/tools/git/utils.d.ts +4 -0
- package/dist/tools/git/utils.d.ts.map +1 -1
- package/dist/tools/git/utils.js +12 -0
- package/dist/tools/git/utils.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/search-file-contents.d.ts.map +1 -1
- package/dist/tools/search-file-contents.js +59 -10
- package/dist/tools/search-file-contents.js.map +1 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +9 -0
- package/dist/tools/tool-manager.js.map +1 -1
- package/dist/types/app.d.ts +2 -0
- package/dist/types/app.d.ts.map +1 -1
- package/dist/types/commands.d.ts +20 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/core.d.ts +2 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +7 -0
- package/dist/types/core.js.map +1 -1
- package/dist/types/ui.d.ts +1 -1
- package/dist/types/ui.d.ts.map +1 -1
- package/dist/utils/auto-compact.d.ts.map +1 -1
- package/dist/utils/auto-compact.js +13 -7
- package/dist/utils/auto-compact.js.map +1 -1
- package/dist/utils/file-content-loader.d.ts.map +1 -1
- package/dist/utils/file-content-loader.js +58 -1
- package/dist/utils/file-content-loader.js.map +1 -1
- package/dist/utils/logging/index.d.ts.map +1 -1
- package/dist/utils/logging/index.js +18 -30
- package/dist/utils/logging/index.js.map +1 -1
- package/dist/utils/question-queue.d.ts +15 -0
- package/dist/utils/question-queue.d.ts.map +1 -0
- package/dist/utils/question-queue.js +25 -0
- package/dist/utils/question-queue.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +108 -0
- package/dist/utils/response-formatter.d.ts.map +1 -0
- package/dist/utils/response-formatter.js +387 -0
- package/dist/utils/response-formatter.js.map +1 -0
- package/dist/utils/shutdown/index.d.ts +7 -0
- package/dist/utils/shutdown/index.d.ts.map +1 -0
- package/dist/utils/shutdown/index.js +6 -0
- package/dist/utils/shutdown/index.js.map +1 -0
- package/dist/utils/shutdown/shutdown-manager.d.ts +19 -0
- package/dist/utils/shutdown/shutdown-manager.d.ts.map +1 -0
- package/dist/utils/shutdown/shutdown-manager.js +100 -0
- package/dist/utils/shutdown/shutdown-manager.js.map +1 -0
- package/dist/utils/shutdown/types.d.ts +9 -0
- package/dist/utils/shutdown/types.d.ts.map +1 -0
- package/dist/utils/shutdown/types.js +2 -0
- package/dist/utils/shutdown/types.js.map +1 -0
- package/dist/utils/type-helpers.d.ts +140 -0
- package/dist/utils/type-helpers.d.ts.map +1 -0
- package/dist/utils/type-helpers.js +220 -0
- package/dist/utils/type-helpers.js.map +1 -0
- package/dist/utils/url-utils.d.ts +6 -0
- package/dist/utils/url-utils.d.ts.map +1 -0
- package/dist/utils/url-utils.js +22 -0
- package/dist/utils/url-utils.js.map +1 -0
- package/dist/vscode/vscode-server.d.ts.map +1 -1
- package/dist/vscode/vscode-server.js +10 -0
- package/dist/vscode/vscode-server.js.map +1 -1
- package/dist/wizards/steps/mcp-step.js +1 -1
- package/dist/wizards/steps/mcp-step.js.map +1 -1
- package/dist/wizards/steps/provider-step.js +1 -1
- package/dist/wizards/steps/provider-step.js.map +1 -1
- package/dist/wizards/templates/mcp-templates.d.ts.map +1 -1
- package/dist/wizards/templates/mcp-templates.js +8 -6
- package/dist/wizards/templates/mcp-templates.js.map +1 -1
- package/dist/wizards/templates/provider-templates.d.ts.map +1 -1
- package/dist/wizards/templates/provider-templates.js +35 -2
- package/dist/wizards/templates/provider-templates.js.map +1 -1
- package/dist/wizards/validation.d.ts.map +1 -1
- package/dist/wizards/validation.js +2 -3
- package/dist/wizards/validation.js.map +1 -1
- package/package.json +9 -18
- package/source/app/prompts/main-prompt.md +21 -3
- package/dist/hooks/chat-handler/utils/context-checker.d.ts +0 -15
- package/dist/hooks/chat-handler/utils/context-checker.d.ts.map +0 -1
- package/dist/hooks/chat-handler/utils/context-checker.js +0 -68
- package/dist/hooks/chat-handler/utils/context-checker.js.map +0 -1
- package/dist/tools/string-replace.d.ts +0 -3
- package/dist/tools/string-replace.d.ts.map +0 -1
- package/dist/tools/string-replace.js.map +0 -1
- package/dist/tools/write-file.d.ts +0 -3
- package/dist/tools/write-file.d.ts.map +0 -1
- package/dist/tools/write-file.js.map +0 -1
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
// source/utils/response-formatter.ts
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// NORMALIZATION FUNCTIONS
|
|
4
|
+
// ============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Main entry point for normalizing LLM responses
|
|
7
|
+
*
|
|
8
|
+
* This function handles all possible LLM response types:
|
|
9
|
+
* - Plain strings (most common)
|
|
10
|
+
* - JSON objects (with/without tool_calls field)
|
|
11
|
+
* - Arrays (line-based content)
|
|
12
|
+
* - Null/undefined (error responses)
|
|
13
|
+
* - Mixed content (text + tool calls embedded)
|
|
14
|
+
*
|
|
15
|
+
* @param response - The raw response from the LLM (can be any type)
|
|
16
|
+
* @param options - Configuration options
|
|
17
|
+
* @returns A normalized response with content and extracted tool calls
|
|
18
|
+
*/
|
|
19
|
+
export async function normalizeLLMResponse(response, options = {}) {
|
|
20
|
+
const { preserveRawTypes = false, // If true, keeps object structure instead of JSON.stringify
|
|
21
|
+
allowMixedContent = true, // If true, extracts tool calls from mixed content
|
|
22
|
+
} = options;
|
|
23
|
+
// Step 1: Detect response type and convert to string for parsing
|
|
24
|
+
const { content, detectedFormat } = convertToProcessableString(response);
|
|
25
|
+
// Step 2: Extract tool calls from the content
|
|
26
|
+
const { toolCalls, malformedError } = await extractToolCalls(content, {
|
|
27
|
+
allowMixedContent,
|
|
28
|
+
detectedFormat,
|
|
29
|
+
});
|
|
30
|
+
// Step 3: Detect if response is malformed
|
|
31
|
+
const isMalformed = !toolCalls.length && hasMalformedPatterns(content);
|
|
32
|
+
// Step 4: Build metadata for debugging and strategy selection
|
|
33
|
+
// Check for JSON blocks in content - only match tool call patterns, not plain JSON objects
|
|
34
|
+
const hasCodeBlocks = /```/.test(content);
|
|
35
|
+
const hasJSONBlocks = /"name"\s*:\s*"[^"]+"\s*,\s*"arguments"\s*:\s*\{/.test(content);
|
|
36
|
+
const metadata = buildMetadata(content, {
|
|
37
|
+
hasCodeBlocks,
|
|
38
|
+
hasXMLTags: /<[^>]+>/.test(content),
|
|
39
|
+
hasJSONBlocks,
|
|
40
|
+
detectedFormat,
|
|
41
|
+
malformedError,
|
|
42
|
+
isMalformed,
|
|
43
|
+
}, toolCalls.length > 0);
|
|
44
|
+
return {
|
|
45
|
+
raw: preserveRawTypes ? response : undefined, // Only preserve if requested
|
|
46
|
+
content,
|
|
47
|
+
toolCalls,
|
|
48
|
+
metadata,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts any LLM response type to a string suitable for parsing
|
|
53
|
+
*
|
|
54
|
+
* Handles the following cases:
|
|
55
|
+
* 1. string → string (identity, already processable)
|
|
56
|
+
* 2. object → JSON.stringify (structured data)
|
|
57
|
+
* 3. array → JSON.stringify (array data)
|
|
58
|
+
* 4. null/undefined → empty string (error handling)
|
|
59
|
+
* 5. number/boolean → String() (primitive types)
|
|
60
|
+
*
|
|
61
|
+
* This conversion is NECESSARY because our parsers expect strings.
|
|
62
|
+
* The type preservation happens later in the ToolCall structure.
|
|
63
|
+
*
|
|
64
|
+
* @param response - Raw response from LLM (any type)
|
|
65
|
+
* @returns Object with processable string content and detected format
|
|
66
|
+
*/
|
|
67
|
+
function convertToProcessableString(response) {
|
|
68
|
+
let content;
|
|
69
|
+
let detectedFormat = 'plain';
|
|
70
|
+
// CASE 1: Plain string response (most common)
|
|
71
|
+
if (typeof response === 'string') {
|
|
72
|
+
content = response.trim();
|
|
73
|
+
// Check if it looks like a JSON structure
|
|
74
|
+
if (content.startsWith('{') && content.endsWith('}')) {
|
|
75
|
+
detectedFormat = 'json';
|
|
76
|
+
// Don't JSON.stringify a string that's already JSON - just use it as-is
|
|
77
|
+
// The parser will parse it correctly
|
|
78
|
+
}
|
|
79
|
+
// Check if it looks like XML
|
|
80
|
+
else if (content.startsWith('<') && content.endsWith('>')) {
|
|
81
|
+
detectedFormat = 'xml';
|
|
82
|
+
// Don't JSON.stringify a string that's already XML - just use it as-is
|
|
83
|
+
// The parser will parse it correctly
|
|
84
|
+
}
|
|
85
|
+
// Check for mixed content (text + tool calls)
|
|
86
|
+
else if (hasEmbeddedToolCallPatterns(content)) {
|
|
87
|
+
detectedFormat = 'mixed';
|
|
88
|
+
// Don't JSON.stringify - keep as plain string for parser to handle
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// CASE 2: JSON object response (structured data)
|
|
92
|
+
else if (response !== null && typeof response === 'object') {
|
|
93
|
+
// Check if it has a tool_calls field (AI SDK format)
|
|
94
|
+
if ('tool_calls' in response || 'function' in response) {
|
|
95
|
+
detectedFormat = 'json';
|
|
96
|
+
// If it's already structured, we might not need JSON.stringify
|
|
97
|
+
// But for consistency with parsers, we still convert to string
|
|
98
|
+
content = JSON.stringify(response);
|
|
99
|
+
}
|
|
100
|
+
// Regular object (not a tool_calls response)
|
|
101
|
+
else {
|
|
102
|
+
detectedFormat = 'json';
|
|
103
|
+
content = JSON.stringify(response);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// CASE 3: Array response (line-based content)
|
|
107
|
+
else if (Array.isArray(response)) {
|
|
108
|
+
detectedFormat = 'mixed';
|
|
109
|
+
content = response.join('\n').trim();
|
|
110
|
+
}
|
|
111
|
+
// CASE 4: Primitives (number, boolean, null, undefined)
|
|
112
|
+
else {
|
|
113
|
+
// Convert primitives to strings
|
|
114
|
+
content = String(response);
|
|
115
|
+
// Empty string if null or undefined
|
|
116
|
+
if (response === null || response === undefined) {
|
|
117
|
+
content = '';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { content, detectedFormat };
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Extracts tool calls from normalized content
|
|
124
|
+
*
|
|
125
|
+
* This function uses the unified parser to extract tool calls from:
|
|
126
|
+
* - Plain text with embedded JSON/XML tool calls
|
|
127
|
+
* - JSON objects with tool_calls field
|
|
128
|
+
* - Mixed content (text + tool calls)
|
|
129
|
+
*
|
|
130
|
+
* @param content - Normalized content string
|
|
131
|
+
* @param options - Extraction options
|
|
132
|
+
* @returns Object with extracted tool calls and any malformed error
|
|
133
|
+
*/
|
|
134
|
+
async function extractToolCalls(content, options) {
|
|
135
|
+
const { allowMixedContent, detectedFormat } = options;
|
|
136
|
+
// If no content, no tool calls
|
|
137
|
+
if (!content) {
|
|
138
|
+
return { toolCalls: [] };
|
|
139
|
+
}
|
|
140
|
+
// CASE 1: Detected JSON format - try JSON parser
|
|
141
|
+
if (detectedFormat === 'json') {
|
|
142
|
+
try {
|
|
143
|
+
// Import here to avoid circular dependencies
|
|
144
|
+
const { parseJSONToolCalls } = await import('../tool-calling/json-parser.js');
|
|
145
|
+
const toolCalls = parseJSONToolCalls(content);
|
|
146
|
+
if (toolCalls.length > 0) {
|
|
147
|
+
return { toolCalls };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
// If JSON parsing fails, fall through to mixed content handling
|
|
152
|
+
console.warn('JSON parsing failed, trying mixed content:', error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// CASE 2: Try XML parser
|
|
156
|
+
try {
|
|
157
|
+
const { XMLToolCallParser } = await import('../tool-calling/xml-parser.js');
|
|
158
|
+
// Check for malformed XML first
|
|
159
|
+
const malformedError = XMLToolCallParser.detectMalformedToolCall(content);
|
|
160
|
+
if (malformedError) {
|
|
161
|
+
return { toolCalls: [], malformedError: malformedError.error };
|
|
162
|
+
}
|
|
163
|
+
// Check if has XML tool calls
|
|
164
|
+
if (XMLToolCallParser.hasToolCalls(content)) {
|
|
165
|
+
const parsedCalls = XMLToolCallParser.parseToolCalls(content);
|
|
166
|
+
const toolCalls = XMLToolCallParser.convertToToolCalls(parsedCalls);
|
|
167
|
+
if (toolCalls.length > 0) {
|
|
168
|
+
return { toolCalls };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
// XML parsing failed, continue
|
|
174
|
+
console.warn('XML parsing failed:', error);
|
|
175
|
+
}
|
|
176
|
+
// CASE 3: Mixed content - use unified parser
|
|
177
|
+
if (allowMixedContent) {
|
|
178
|
+
try {
|
|
179
|
+
const { parseToolCalls } = await import('../tool-calling/tool-parser.js');
|
|
180
|
+
const result = parseToolCalls(content);
|
|
181
|
+
if (result.success && result.toolCalls.length > 0) {
|
|
182
|
+
return { toolCalls: result.toolCalls };
|
|
183
|
+
}
|
|
184
|
+
if (!result.success) {
|
|
185
|
+
return { toolCalls: [], malformedError: result.error };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// Parsing failed, return empty tool calls
|
|
190
|
+
console.warn('Mixed content parsing failed:', error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// No tool calls found
|
|
194
|
+
return { toolCalls: [] };
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Detects if content contains malformed patterns
|
|
198
|
+
*
|
|
199
|
+
* Logic:
|
|
200
|
+
* 1. If it parses as valid JSON via try/catch, it is NOT malformed.
|
|
201
|
+
* 2. If parsing fails, check for known "broken tool call" signatures.
|
|
202
|
+
*
|
|
203
|
+
* @param content - Content to check
|
|
204
|
+
* @returns True if malformed patterns detected
|
|
205
|
+
*/
|
|
206
|
+
function hasMalformedPatterns(content) {
|
|
207
|
+
const trimmed = content.trim();
|
|
208
|
+
// 1. Sanity Check: Empty content is not "malformed", just empty.
|
|
209
|
+
if (!trimmed) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
// 2. THE SAFETY CHECK: Trust the Runtime (JSON.parse)
|
|
213
|
+
// We check if it starts and ends with braces to identify it as a candidate for an Object.
|
|
214
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
215
|
+
try {
|
|
216
|
+
// CRASH PROTECTION: If this succeeds, the JSON is valid.
|
|
217
|
+
// Therefore, it cannot be "malformed".
|
|
218
|
+
JSON.parse(trimmed);
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
catch (_e) {
|
|
222
|
+
// It crashed. It might be malformed.
|
|
223
|
+
// Fall through to regex checks below.
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// 3. Check for specific broken tool call patterns.
|
|
227
|
+
const malformedJSONPatterns = [
|
|
228
|
+
/^\s*\{\s*"name"\s*:\s*"[^"]+"\s*\}\s*$/, // name only, no arguments
|
|
229
|
+
/^\s*\{\s*"arguments"\s*:\s*\}\s*$/, // arguments only, no name
|
|
230
|
+
/"arguments"\s*:\s*null\s*([,}\s]*$)/s, // arguments as JSON null (followed by comma, brace, or end)
|
|
231
|
+
/^\s*\{\s*"arguments"\s*:\s*\[\s*\]\s*\}$/, // arguments as empty array
|
|
232
|
+
/^\s*\{\s*"arguments"\s*:\s*""\s*\}$/, // arguments as empty string
|
|
233
|
+
];
|
|
234
|
+
for (const pattern of malformedJSONPatterns) {
|
|
235
|
+
if (pattern.test(trimmed)) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// 4. Check for malformed XML patterns
|
|
240
|
+
const malformedXMLPatterns = [
|
|
241
|
+
/\[(?:tool_use|Tool):\s*(\w+)\]/i, // [tool_use: name] syntax
|
|
242
|
+
/<function=(\w+)>/, // <function=name> syntax
|
|
243
|
+
/<parameter=(\w+)>/, // <parameter=name> syntax
|
|
244
|
+
];
|
|
245
|
+
for (const pattern of malformedXMLPatterns) {
|
|
246
|
+
if (pattern.test(content)) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Builds metadata object for debugging and strategy selection
|
|
254
|
+
*
|
|
255
|
+
* @param content - Normalized content
|
|
256
|
+
* @param partialMetadata - Partial metadata from earlier detection
|
|
257
|
+
* @param hasToolCalls - Whether tool calls were actually extracted
|
|
258
|
+
* @returns Complete metadata object
|
|
259
|
+
*/
|
|
260
|
+
function buildMetadata(content, partialMetadata, hasToolCalls) {
|
|
261
|
+
// Check if content looks like JSON (has { and })
|
|
262
|
+
// Check if content looks like XML (has < and >)
|
|
263
|
+
// Check if content has code blocks
|
|
264
|
+
const hasCodeBlocks = /```/.test(content);
|
|
265
|
+
// Check if content has XML tags
|
|
266
|
+
const hasXMLTags = /<[^>]+>/.test(content);
|
|
267
|
+
// Check if content has JSON blocks (tool call patterns only, not plain JSON objects)
|
|
268
|
+
const hasJSONBlocks = /"name"\s*:\s*"[^"]+"\s*,\s*"arguments"\s*:\s*\{/.test(content);
|
|
269
|
+
return {
|
|
270
|
+
hasCodeBlocks: partialMetadata.hasCodeBlocks ?? hasCodeBlocks,
|
|
271
|
+
hasXMLTags: partialMetadata.hasXMLTags ?? hasXMLTags,
|
|
272
|
+
hasJSONBlocks: partialMetadata.hasJSONBlocks ?? hasJSONBlocks,
|
|
273
|
+
confidence: determineConfidence({
|
|
274
|
+
...partialMetadata,
|
|
275
|
+
hasCodeBlocks,
|
|
276
|
+
hasXMLTags,
|
|
277
|
+
hasJSONBlocks,
|
|
278
|
+
}, hasToolCalls),
|
|
279
|
+
detectedFormat: partialMetadata.detectedFormat ?? 'unknown',
|
|
280
|
+
isMalformed: partialMetadata.isMalformed ?? hasMalformedPatterns(content),
|
|
281
|
+
malformedError: partialMetadata.malformedError,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Determines confidence level in the response type classification
|
|
286
|
+
*
|
|
287
|
+
* Confidence levels:
|
|
288
|
+
* - HIGH: Clear format detected (JSON with tool_calls, XML with tool calls)
|
|
289
|
+
* - MEDIUM: Unclear format (plain text with possible tool calls)
|
|
290
|
+
* - LOW: No format detected (plain text with no tool calls)
|
|
291
|
+
*
|
|
292
|
+
* @param metadata - Metadata from response
|
|
293
|
+
* @param hasToolCalls - Whether tool calls were actually extracted
|
|
294
|
+
* @returns Confidence level
|
|
295
|
+
*/
|
|
296
|
+
function determineConfidence(metadata, hasToolCalls) {
|
|
297
|
+
// High confidence if we actually extracted tool calls
|
|
298
|
+
if (hasToolCalls) {
|
|
299
|
+
return 'high';
|
|
300
|
+
}
|
|
301
|
+
// If it is explicitly malformed, confidence is LOW
|
|
302
|
+
if (metadata.isMalformed) {
|
|
303
|
+
return 'low';
|
|
304
|
+
}
|
|
305
|
+
// Medium confidence if it looks like code/data, but contained no valid tools
|
|
306
|
+
if (metadata.detectedFormat === 'json' ||
|
|
307
|
+
metadata.detectedFormat === 'xml' ||
|
|
308
|
+
metadata.hasCodeBlocks ||
|
|
309
|
+
metadata.hasJSONBlocks ||
|
|
310
|
+
metadata.hasXMLTags) {
|
|
311
|
+
return 'medium';
|
|
312
|
+
}
|
|
313
|
+
// LOW: Plain text with no format indicators
|
|
314
|
+
return 'low';
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Checks if content contains embedded tool call patterns
|
|
318
|
+
*
|
|
319
|
+
* @param content - Content to check
|
|
320
|
+
* @returns True if embedded patterns detected
|
|
321
|
+
*/
|
|
322
|
+
function hasEmbeddedToolCallPatterns(content) {
|
|
323
|
+
// JSON tool call patterns (allow text before the pattern)
|
|
324
|
+
const jsonPatterns = [
|
|
325
|
+
/\s*\{\s*"name"\s*:\s*"[^"]+"\s*,\s*"arguments"\s*:\s*\{/s,
|
|
326
|
+
/\s*\{"name":\s*"([^"]+)",\s*"arguments":\s*\{/s,
|
|
327
|
+
];
|
|
328
|
+
// XML tool call patterns
|
|
329
|
+
const xmlPatterns = [/<(\w+)>(.*?)<\/\1>/s];
|
|
330
|
+
for (const pattern of [...jsonPatterns, ...xmlPatterns]) {
|
|
331
|
+
if (pattern.test(content)) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
// ============================================================================
|
|
338
|
+
// UTILITY FUNCTIONS
|
|
339
|
+
// ============================================================================
|
|
340
|
+
/**
|
|
341
|
+
* Formats a normalized response for debugging
|
|
342
|
+
*
|
|
343
|
+
* @param response - Normalized response to format
|
|
344
|
+
* @returns Formatted string for debugging
|
|
345
|
+
*/
|
|
346
|
+
export function formatNormalizedResponse(response) {
|
|
347
|
+
return [
|
|
348
|
+
`=== Normalized Response ===`,
|
|
349
|
+
`Raw Type: ${response.raw !== undefined ? typeof response.raw : 'undefined'}`,
|
|
350
|
+
`Content Type: ${typeof response.content}`,
|
|
351
|
+
`Content Length: ${response.content.length} chars`,
|
|
352
|
+
`Detected Format: ${response.metadata.detectedFormat}`,
|
|
353
|
+
`Confidence: ${response.metadata.confidence}`,
|
|
354
|
+
`Has Code Blocks: ${response.metadata.hasCodeBlocks}`,
|
|
355
|
+
`Has XML Tags: ${response.metadata.hasXMLTags}`,
|
|
356
|
+
`Has JSON Blocks: ${response.metadata.hasJSONBlocks}`,
|
|
357
|
+
`Is Malformed: ${response.metadata.isMalformed}`,
|
|
358
|
+
`Tool Calls: ${response.toolCalls.length}`,
|
|
359
|
+
``,
|
|
360
|
+
`Content Preview:`,
|
|
361
|
+
response.content.slice(0, 500) +
|
|
362
|
+
(response.content.length > 500 ? '...' : ''),
|
|
363
|
+
``,
|
|
364
|
+
`Tool Calls:`,
|
|
365
|
+
response.toolCalls
|
|
366
|
+
.map(tc => ` - ${tc.function.name}: ${JSON.stringify(tc.function.arguments)}`)
|
|
367
|
+
.join('\n'),
|
|
368
|
+
].join('\n');
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Checks if a response is complete and ready for processing
|
|
372
|
+
*
|
|
373
|
+
* A response is complete if:
|
|
374
|
+
* 1. It has content
|
|
375
|
+
* 2. It has low confidence (means no tool calls were found, so no further processing needed)
|
|
376
|
+
* 3. It's not malformed
|
|
377
|
+
*
|
|
378
|
+
* @param response - Normalized response to check
|
|
379
|
+
* @returns True if response is complete
|
|
380
|
+
*/
|
|
381
|
+
export function isResponseComplete(response) {
|
|
382
|
+
// Response is complete if it has content and is not malformed
|
|
383
|
+
return (response.content.length > 0 &&
|
|
384
|
+
!response.metadata.isMalformed &&
|
|
385
|
+
response.metadata.confidence !== 'low');
|
|
386
|
+
}
|
|
387
|
+
//# sourceMappingURL=response-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-formatter.js","sourceRoot":"","sources":["../../source/utils/response-formatter.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAsFrC,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,QAAiB,EACjB,UAA4B,EAAE;IAE9B,MAAM,EACL,gBAAgB,GAAG,KAAK,EAAE,4DAA4D;IACtF,iBAAiB,GAAG,I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GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,EAAE;QACF,aAAa;QACb,QAAQ,CAAC,SAAS;aAChB,GAAG,CACH,EAAE,CAAC,EAAE,CACJ,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CACpE;aACA,IAAI,CAAC,IAAI,CAAC;KACZ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA4B;IAC9D,8DAA8D;IAC9D,OAAO,CACN,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC3B,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW;QAC9B,QAAQ,CAAC,QAAQ,CAAC,UAAU,KAAK,KAAK,CACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/utils/shutdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB;AAClB,gBAAgB;AAChB,oBAAoB;AACpB,gBAAgB;AAChB,eAAe,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAC,eAAe,EAAE,sBAAsB,EAAC,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/utils/shutdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB;AAClB,gBAAgB;AAChB,oBAAoB;AACpB,gBAAgB;AAChB,eAAe,GACf,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ShutdownHandler, ShutdownManagerOptions } from './types.js';
|
|
2
|
+
export declare class ShutdownManager {
|
|
3
|
+
private handlers;
|
|
4
|
+
private isShuttingDown;
|
|
5
|
+
private timeoutMs;
|
|
6
|
+
private boundSigterm;
|
|
7
|
+
private boundSigint;
|
|
8
|
+
private boundUncaughtException;
|
|
9
|
+
private boundUnhandledRejection;
|
|
10
|
+
constructor(options?: ShutdownManagerOptions);
|
|
11
|
+
register(handler: ShutdownHandler): void;
|
|
12
|
+
unregister(name: string): void;
|
|
13
|
+
gracefulShutdown(exitCode?: number): Promise<void>;
|
|
14
|
+
private setupSignalHandlers;
|
|
15
|
+
reset(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function getShutdownManager(options?: ShutdownManagerOptions): ShutdownManager;
|
|
18
|
+
export declare function resetShutdownManager(): void;
|
|
19
|
+
//# sourceMappingURL=shutdown-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-manager.d.ts","sourceRoot":"","sources":["../../../source/utils/shutdown/shutdown-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAE,sBAAsB,EAAC,MAAM,SAAS,CAAC;AAKrE,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAA2C;IAC3D,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,uBAAuB,CAGrB;gBAEE,OAAO,CAAC,EAAE,sBAAsB;IAgC5C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxB,gBAAgB,CAAC,QAAQ,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCnD,OAAO,CAAC,mBAAmB;IAO3B,KAAK,IAAI,IAAI;CAQb;AAID,wBAAgB,kBAAkB,CACjC,OAAO,CAAC,EAAE,sBAAsB,GAC9B,eAAe,CAKjB;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { loggerProvider } from '../../utils/logging/logger-provider.js';
|
|
2
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
3
|
+
const ENV_SHUTDOWN_TIMEOUT = 'NANOCODER_DEFAULT_SHUTDOWN_TIMEOUT';
|
|
4
|
+
export class ShutdownManager {
|
|
5
|
+
handlers = new Map();
|
|
6
|
+
isShuttingDown = false;
|
|
7
|
+
timeoutMs;
|
|
8
|
+
boundSigterm;
|
|
9
|
+
boundSigint;
|
|
10
|
+
boundUncaughtException;
|
|
11
|
+
boundUnhandledRejection;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
const envTimeout = process.env[ENV_SHUTDOWN_TIMEOUT];
|
|
14
|
+
const parsedEnvTimeout = envTimeout ? parseInt(envTimeout, 10) : undefined;
|
|
15
|
+
const isValidTimeout = Number.isFinite(parsedEnvTimeout);
|
|
16
|
+
this.timeoutMs =
|
|
17
|
+
options?.timeoutMs ??
|
|
18
|
+
(isValidTimeout ? parsedEnvTimeout : undefined) ??
|
|
19
|
+
DEFAULT_TIMEOUT_MS;
|
|
20
|
+
this.boundSigterm = () => {
|
|
21
|
+
void this.gracefulShutdown(0);
|
|
22
|
+
};
|
|
23
|
+
this.boundSigint = () => {
|
|
24
|
+
void this.gracefulShutdown(0);
|
|
25
|
+
};
|
|
26
|
+
this.boundUncaughtException = (err) => {
|
|
27
|
+
const logger = loggerProvider.getLogger();
|
|
28
|
+
logger.fatal({ err }, 'Uncaught exception');
|
|
29
|
+
void this.gracefulShutdown(1);
|
|
30
|
+
};
|
|
31
|
+
this.boundUnhandledRejection = (reason, promise) => {
|
|
32
|
+
const logger = loggerProvider.getLogger();
|
|
33
|
+
logger.fatal({ reason, promise }, 'Unhandled promise rejection');
|
|
34
|
+
void this.gracefulShutdown(1);
|
|
35
|
+
};
|
|
36
|
+
this.setupSignalHandlers();
|
|
37
|
+
}
|
|
38
|
+
register(handler) {
|
|
39
|
+
this.handlers.set(handler.name, handler);
|
|
40
|
+
}
|
|
41
|
+
unregister(name) {
|
|
42
|
+
this.handlers.delete(name);
|
|
43
|
+
}
|
|
44
|
+
async gracefulShutdown(exitCode = 0) {
|
|
45
|
+
if (this.isShuttingDown) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.isShuttingDown = true;
|
|
49
|
+
const logger = loggerProvider.getLogger();
|
|
50
|
+
logger.info('Graceful shutdown initiated', { exitCode });
|
|
51
|
+
const sorted = Array.from(this.handlers.values()).sort((a, b) => a.priority - b.priority);
|
|
52
|
+
const shutdownPromise = (async () => {
|
|
53
|
+
for (const entry of sorted) {
|
|
54
|
+
try {
|
|
55
|
+
logger.info(`Shutting down: ${entry.name}`);
|
|
56
|
+
await entry.handler();
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
logger.error({ err }, `Shutdown handler failed: ${entry.name}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})();
|
|
63
|
+
const timeoutPromise = new Promise(resolve => {
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
logger.warn('Shutdown timeout reached, forcing exit');
|
|
66
|
+
resolve();
|
|
67
|
+
}, this.timeoutMs);
|
|
68
|
+
});
|
|
69
|
+
await Promise.race([shutdownPromise, timeoutPromise]);
|
|
70
|
+
process.exit(exitCode);
|
|
71
|
+
}
|
|
72
|
+
setupSignalHandlers() {
|
|
73
|
+
process.once('SIGTERM', this.boundSigterm);
|
|
74
|
+
process.once('SIGINT', this.boundSigint);
|
|
75
|
+
process.on('uncaughtException', this.boundUncaughtException);
|
|
76
|
+
process.on('unhandledRejection', this.boundUnhandledRejection);
|
|
77
|
+
}
|
|
78
|
+
reset() {
|
|
79
|
+
this.handlers.clear();
|
|
80
|
+
this.isShuttingDown = false;
|
|
81
|
+
process.removeListener('SIGTERM', this.boundSigterm);
|
|
82
|
+
process.removeListener('SIGINT', this.boundSigint);
|
|
83
|
+
process.removeListener('uncaughtException', this.boundUncaughtException);
|
|
84
|
+
process.removeListener('unhandledRejection', this.boundUnhandledRejection);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let instance = null;
|
|
88
|
+
export function getShutdownManager(options) {
|
|
89
|
+
if (!instance) {
|
|
90
|
+
instance = new ShutdownManager(options);
|
|
91
|
+
}
|
|
92
|
+
return instance;
|
|
93
|
+
}
|
|
94
|
+
export function resetShutdownManager() {
|
|
95
|
+
if (instance) {
|
|
96
|
+
instance.reset();
|
|
97
|
+
instance = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=shutdown-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-manager.js","sourceRoot":"","sources":["../../../source/utils/shutdown/shutdown-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAG/D,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,oBAAoB,GAAG,oCAAoC,CAAC;AAElE,MAAM,OAAO,eAAe;IACnB,QAAQ,GAAiC,IAAI,GAAG,EAAE,CAAC;IACnD,cAAc,GAAG,KAAK,CAAC;IACvB,SAAS,CAAS;IAElB,YAAY,CAAa;IACzB,WAAW,CAAa;IACxB,sBAAsB,CAAuB;IAC7C,uBAAuB,CAGrB;IAEV,YAAY,OAAgC;QAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QACrD,MAAM,gBAAgB,GAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3E,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS;YACb,OAAO,EAAE,SAAS;gBAClB,CAAC,cAAc,CAAC,CAAC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IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../source/utils/shutdown/types.ts"],"names":[],"mappings":""}
|