@nanocollective/nanocoder 1.16.3 → 1.16.5
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 +17 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +4 -29
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts +6 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +104 -10
- package/dist/commands/update.js.map +1 -1
- package/dist/components/status.d.ts +1 -6
- package/dist/components/status.d.ts.map +1 -1
- package/dist/components/status.js +3 -2
- package/dist/components/status.js.map +1 -1
- package/dist/components/tool-confirmation.d.ts.map +1 -1
- package/dist/components/tool-confirmation.js +5 -19
- package/dist/components/tool-confirmation.js.map +1 -1
- package/dist/components/user-input.d.ts.map +1 -1
- package/dist/components/user-input.js +61 -19
- package/dist/components/user-input.js.map +1 -1
- package/dist/components/warning-message.d.ts +7 -0
- package/dist/components/warning-message.d.ts.map +1 -0
- package/dist/components/warning-message.js +12 -0
- package/dist/components/warning-message.js.map +1 -0
- package/dist/config/index.js +6 -6
- package/dist/config/index.js.map +1 -1
- package/dist/config/paths.d.ts +1 -0
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +28 -3
- package/dist/config/paths.js.map +1 -1
- package/dist/config/paths.spec.d.ts +2 -0
- package/dist/config/paths.spec.d.ts.map +1 -0
- package/dist/config/paths.spec.js +114 -0
- package/dist/config/paths.spec.js.map +1 -0
- package/dist/config/themes.d.ts.map +1 -1
- package/dist/config/themes.js +19 -0
- package/dist/config/themes.js.map +1 -1
- package/dist/hooks/useChatHandler.d.ts.map +1 -1
- package/dist/hooks/useChatHandler.js +10 -71
- package/dist/hooks/useChatHandler.js.map +1 -1
- package/dist/hooks/useDirectoryTrust.d.ts.map +1 -1
- package/dist/hooks/useDirectoryTrust.js +4 -4
- package/dist/hooks/useDirectoryTrust.js.map +1 -1
- package/dist/hooks/useInputState.d.ts.map +1 -1
- package/dist/hooks/useInputState.js +95 -8
- package/dist/hooks/useInputState.js.map +1 -1
- package/dist/hooks/useToolHandler.d.ts +0 -1
- package/dist/hooks/useToolHandler.d.ts.map +1 -1
- package/dist/hooks/useToolHandler.js +9 -75
- package/dist/hooks/useToolHandler.js.map +1 -1
- package/dist/message-handler.d.ts.map +1 -1
- package/dist/message-handler.js +6 -11
- package/dist/message-handler.js.map +1 -1
- package/dist/models/models-dev-client.spec.js +1 -0
- package/dist/models/models-dev-client.spec.js.map +1 -1
- package/dist/tools/execute-bash.d.ts.map +1 -1
- package/dist/tools/execute-bash.js +5 -3
- package/dist/tools/execute-bash.js.map +1 -1
- package/dist/types/ui.d.ts +1 -1
- package/dist/types/ui.d.ts.map +1 -1
- package/dist/types/utils.d.ts +2 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/usage/storage.d.ts +1 -1
- package/dist/usage/storage.d.ts.map +1 -1
- package/dist/usage/storage.js +55 -9
- package/dist/usage/storage.js.map +1 -1
- package/dist/usage/storage.spec.js +136 -2
- package/dist/usage/storage.spec.js.map +1 -1
- package/dist/utils/error-formatter.d.ts +22 -0
- package/dist/utils/error-formatter.d.ts.map +1 -0
- package/dist/utils/error-formatter.js +27 -0
- package/dist/utils/error-formatter.js.map +1 -0
- package/dist/utils/error-formatter.spec.d.ts +2 -0
- package/dist/utils/error-formatter.spec.d.ts.map +1 -0
- package/dist/utils/error-formatter.spec.js +147 -0
- package/dist/utils/error-formatter.spec.js.map +1 -0
- package/dist/utils/fuzzy-matching.spec.js +1 -0
- package/dist/utils/fuzzy-matching.spec.js.map +1 -1
- package/dist/utils/installation-detector.d.ts +16 -0
- package/dist/utils/installation-detector.d.ts.map +1 -0
- package/dist/utils/installation-detector.js +118 -0
- package/dist/utils/installation-detector.js.map +1 -0
- package/dist/utils/installation-detector.spec.d.ts +2 -0
- package/dist/utils/installation-detector.spec.d.ts.map +1 -0
- package/dist/utils/installation-detector.spec.js +141 -0
- package/dist/utils/installation-detector.spec.js.map +1 -0
- package/dist/utils/message-queue.d.ts +2 -0
- package/dist/utils/message-queue.d.ts.map +1 -1
- package/dist/utils/message-queue.js +11 -0
- package/dist/utils/message-queue.js.map +1 -1
- package/dist/utils/paste-detection.d.ts.map +1 -1
- package/dist/utils/paste-detection.js +8 -3
- package/dist/utils/paste-detection.js.map +1 -1
- package/dist/utils/paste-detection.spec.js +15 -8
- package/dist/utils/paste-detection.spec.js.map +1 -1
- package/dist/utils/paste-utils.d.ts.map +1 -1
- package/dist/utils/paste-utils.js +4 -2
- package/dist/utils/paste-utils.js.map +1 -1
- package/dist/utils/paste-utils.spec.js +19 -3
- package/dist/utils/paste-utils.spec.js.map +1 -1
- package/dist/utils/tool-args-parser.d.ts +37 -0
- package/dist/utils/tool-args-parser.d.ts.map +1 -0
- package/dist/utils/tool-args-parser.js +50 -0
- package/dist/utils/tool-args-parser.js.map +1 -0
- package/dist/utils/tool-args-parser.spec.d.ts +2 -0
- package/dist/utils/tool-args-parser.spec.d.ts.map +1 -0
- package/dist/utils/tool-args-parser.spec.js +111 -0
- package/dist/utils/tool-args-parser.spec.js.map +1 -0
- package/dist/utils/tool-cancellation.d.ts +21 -0
- package/dist/utils/tool-cancellation.d.ts.map +1 -0
- package/dist/utils/tool-cancellation.js +27 -0
- package/dist/utils/tool-cancellation.js.map +1 -0
- package/dist/utils/tool-cancellation.spec.d.ts +2 -0
- package/dist/utils/tool-cancellation.spec.d.ts.map +1 -0
- package/dist/utils/tool-cancellation.spec.js +186 -0
- package/dist/utils/tool-cancellation.spec.js.map +1 -0
- package/dist/utils/tool-result-display.d.ts +15 -0
- package/dist/utils/tool-result-display.d.ts.map +1 -0
- package/dist/utils/tool-result-display.js +51 -0
- package/dist/utils/tool-result-display.js.map +1 -0
- package/dist/utils/update-checker.d.ts.map +1 -1
- package/dist/utils/update-checker.js +31 -3
- package/dist/utils/update-checker.js.map +1 -1
- package/dist/utils/update-checker.spec.js +68 -18
- package/dist/utils/update-checker.spec.js.map +1 -1
- package/dist/wizard/steps/location-step.js +2 -2
- package/dist/wizard/steps/location-step.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A local-first CLI coding agent that brings the power of agentic coding tools lik
|
|
|
14
14
|
- [AI Provider Setup](#ai-provider-setup)
|
|
15
15
|
- [MCP (Model Context Protocol) Servers](#mcp-model-context-protocol-servers)
|
|
16
16
|
- [User Preferences](#user-preferences)
|
|
17
|
+
- [Application Data Directory](#application-data-directory)
|
|
17
18
|
- [Commands](#commands)
|
|
18
19
|
- [Built-in Commands](#built-in-commands)
|
|
19
20
|
- [Custom Commands](#custom-commands)
|
|
@@ -183,7 +184,7 @@ Nanocoder looks for configuration in the following order (first found wins):
|
|
|
183
184
|
- Use this for project-specific providers, models, or API keys
|
|
184
185
|
- Perfect for team sharing or repository-specific configurations
|
|
185
186
|
|
|
186
|
-
2. **User-level (preferred)**: Platform-specific
|
|
187
|
+
2. **User-level (preferred)**: Platform-specific configuration directory
|
|
187
188
|
|
|
188
189
|
- **macOS**: `~/Library/Preferences/nanocoder/agents.config.json`
|
|
189
190
|
- **Linux/Unix**: `~/.config/nanocoder/agents.config.json`
|
|
@@ -191,6 +192,8 @@ Nanocoder looks for configuration in the following order (first found wins):
|
|
|
191
192
|
- Your global default configuration
|
|
192
193
|
- Used when no project-level config exists
|
|
193
194
|
|
|
195
|
+
You can override this global configuration directory by setting `NANOCODER_CONFIG_DIR`. When set, Nanocoder will look for `agents.config.json` and related config files directly in this directory.
|
|
196
|
+
|
|
194
197
|
3. **User-level (legacy)**: `~/.agents.config.json`
|
|
195
198
|
- Supported for backward compatibility
|
|
196
199
|
- Recommended to migrate to platform-specific location above
|
|
@@ -263,6 +266,9 @@ Nanocoder looks for configuration in the following order (first found wins):
|
|
|
263
266
|
|
|
264
267
|
Keep API keys out of version control using environment variables. Variables are loaded from shell environment (`.bashrc`, `.zshrc`) or `.env` file in your working directory.
|
|
265
268
|
|
|
269
|
+
- `NANOCODER_CONFIG_DIR`: Override the global configuration directory.
|
|
270
|
+
- `NANOCODER_DATA_DIR`: Override the application data directory used for internal data like usage statistics.
|
|
271
|
+
|
|
266
272
|
**Syntax:** `$VAR_NAME`, `${VAR_NAME}`, or `${VAR_NAME:-default}`
|
|
267
273
|
**Supported in:** `baseUrl`, `apiKey`, `models`, MCP server `command`, `args`, `env`
|
|
268
274
|
|
|
@@ -402,6 +408,16 @@ Preferences follow the same location hierarchy as configuration files:
|
|
|
402
408
|
- View current preferences: The file is human-readable JSON
|
|
403
409
|
- Reset preferences: Delete any `nanocoder-preferences.json` to start fresh
|
|
404
410
|
|
|
411
|
+
### Application Data Directory
|
|
412
|
+
|
|
413
|
+
Nanocoder stores internal application data (such as usage statistics) in a separate application data directory:
|
|
414
|
+
|
|
415
|
+
- **macOS**: `~/Library/Application Support/nanocoder`
|
|
416
|
+
- **Linux/Unix**: `$XDG_DATA_HOME/nanocoder` or `~/.local/share/nanocoder`
|
|
417
|
+
- **Windows**: `%APPDATA%\nanocoder`
|
|
418
|
+
|
|
419
|
+
You can override this directory using `NANOCODER_DATA_DIR`.
|
|
420
|
+
|
|
405
421
|
### Commands
|
|
406
422
|
|
|
407
423
|
#### Built-in Commands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../source/commands/init.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../source/commands/init.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAkMtC,eAAO,MAAM,WAAW,EAAE,OA6GzB,CAAC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -12,29 +12,11 @@ import { AgentsTemplateGenerator } from '../init/agents-template-generator.js';
|
|
|
12
12
|
import { ExistingRulesExtractor } from '../init/existing-rules-extractor.js';
|
|
13
13
|
function InitSuccess({ created, analysis, }) {
|
|
14
14
|
const boxWidth = useTerminalWidth();
|
|
15
|
-
return (_jsxs(TitledBox, { borderStyle: "round", titles: ['Project Initialized'], titleStyles: titleStyles.pill, width: boxWidth, borderColor: colors.primary, paddingX: 2, paddingY: 1, flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.primary, bold: true, children: "\u2713 Nanocoder project initialized successfully!" }) }), analysis && (_jsxs(_Fragment, { children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.white, bold: true, children: "Project Analysis:" }) }), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Type: ", analysis.projectType] }), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Primary Language: ", analysis.primaryLanguage] }), analysis.frameworks.length > 0 && (_jsxs(Text, { color: colors.secondary, children: ["\u2022 Frameworks: ", analysis.frameworks.slice(0, 3).join(', ')] })), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Files Analyzed: ", analysis.totalFiles] }), _jsx(Box, { marginBottom: 1 })] })), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.white, bold: true, children: "Files Created:" }) }), created.map((item, index) => (_jsxs(Text, { color: colors.secondary, children: ["\u2022 ", item] }, index))), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: colors.white, children: "Your project is now ready for AI-assisted development!" }), _jsx(Text, { color: colors.secondary, children: "The AGENTS.md file will help AI understand your project context." })] })] }));
|
|
15
|
+
return (_jsxs(TitledBox, { borderStyle: "round", titles: ['Project Initialized'], titleStyles: titleStyles.pill, width: boxWidth, borderColor: colors.primary, paddingX: 2, paddingY: 1, flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.primary, bold: true, children: "\u2713 Nanocoder project initialized successfully!" }) }), analysis && (_jsxs(_Fragment, { children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.white, bold: true, children: "Project Analysis:" }) }), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Type: ", analysis.projectType] }), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Primary Language: ", analysis.primaryLanguage] }), analysis.frameworks.length > 0 && (_jsxs(Text, { color: colors.secondary, children: ["\u2022 Frameworks: ", analysis.frameworks.slice(0, 3).join(', ')] })), _jsxs(Text, { color: colors.secondary, children: ["\u2022 Files Analyzed: ", analysis.totalFiles] }), _jsx(Box, { marginBottom: 1 })] })), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.white, bold: true, children: "Files Created:" }) }), created.map((item, index) => (_jsxs(Text, { color: colors.secondary, children: ["\u2022 ", item] }, index))), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.white, children: "Your project is now ready for AI-assisted development!" }) }), _jsx(Text, { color: colors.secondary, children: "The AGENTS.md file will help AI understand your project context." })] })] }));
|
|
16
16
|
}
|
|
17
17
|
function InitError({ message }) {
|
|
18
|
-
return _jsx(ErrorMessage, { message: `✗ ${message}` });
|
|
18
|
+
return _jsx(ErrorMessage, { hideBox: true, message: `✗ ${message}` });
|
|
19
19
|
}
|
|
20
|
-
const DEFAULT_CONFIG = {
|
|
21
|
-
nanocoder: {
|
|
22
|
-
providers: [
|
|
23
|
-
{
|
|
24
|
-
name: 'OpenRouter',
|
|
25
|
-
baseUrl: 'https://openrouter.ai/api/v1',
|
|
26
|
-
apiKey: 'your-openrouter-api-key-here',
|
|
27
|
-
models: ['openai/gpt-4o-mini', 'anthropic/claude-3-haiku'],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Local Ollama',
|
|
31
|
-
baseUrl: 'http://localhost:11434/v1',
|
|
32
|
-
models: ['llama3.2', 'qwen2.5-coder'],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
mcpServers: [],
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
20
|
// Enhanced example commands based on detected project type
|
|
39
21
|
const getExampleCommands = (projectType, primaryLanguage) => {
|
|
40
22
|
const baseCommands = {
|
|
@@ -133,17 +115,15 @@ export const initCommand = {
|
|
|
133
115
|
const created = [];
|
|
134
116
|
try {
|
|
135
117
|
// Check if already initialized
|
|
136
|
-
const configPath = join(cwd, 'agents.config.json');
|
|
137
118
|
const agentsPath = join(cwd, 'AGENTS.md');
|
|
138
119
|
const nanocoderDir = join(cwd, '.nanocoder');
|
|
139
120
|
// Check for existing initialization
|
|
140
|
-
const hasConfig = existsSync(configPath);
|
|
141
121
|
const hasAgents = existsSync(agentsPath);
|
|
142
122
|
const hasNanocoder = existsSync(nanocoderDir);
|
|
143
|
-
if (
|
|
123
|
+
if (hasAgents && hasNanocoder) {
|
|
144
124
|
return Promise.resolve(React.createElement(InitError, {
|
|
145
125
|
key: `init-error-${Date.now()}`,
|
|
146
|
-
message: 'Project already
|
|
126
|
+
message: 'Project already initialized. Found AGENTS.md and .nanocoder/ directory.',
|
|
147
127
|
}));
|
|
148
128
|
}
|
|
149
129
|
// Show progress indicator for analysis
|
|
@@ -155,11 +135,6 @@ export const initCommand = {
|
|
|
155
135
|
// Extract existing AI configuration files
|
|
156
136
|
const rulesExtractor = new ExistingRulesExtractor(cwd);
|
|
157
137
|
const existingRules = rulesExtractor.extractExistingRules();
|
|
158
|
-
// Create agents.config.json if it doesn't exist
|
|
159
|
-
if (!hasConfig) {
|
|
160
|
-
writeFileSync(configPath, JSON.stringify(DEFAULT_CONFIG, null, 2));
|
|
161
|
-
created.push('agents.config.json');
|
|
162
|
-
}
|
|
163
138
|
// Create AGENTS.md based on analysis and existing rules
|
|
164
139
|
if (!hasAgents) {
|
|
165
140
|
const agentsContent = AgentsTemplateGenerator.generateAgentsMd(analysis, existingRules);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../source/commands/init.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS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AAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC1D,OAAO,OAAO,CAAC,OAAO,CACrB,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;gBAC9B,GAAG,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,EAAE;gBAC/B,OAAO,EAAE,iCAAiC,YAAY,EAAE;aACxD,CAAC,CACF,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Command } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if a command execution failed based on multiple signals.
|
|
4
|
+
* Checks exit code first (most reliable), then looks for specific error patterns.
|
|
5
|
+
* Exported for testing purposes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasCommandFailed(output: string): boolean;
|
|
2
8
|
export declare const updateCommand: Command;
|
|
3
9
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../source/commands/update.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../source/commands/update.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAStC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAyDxD;AAED,eAAO,MAAM,aAAa,EAAE,OAiF3B,CAAC"}
|
package/dist/commands/update.js
CHANGED
|
@@ -3,6 +3,65 @@ import { logInfo, logError } from '../utils/message-queue.js';
|
|
|
3
3
|
import { toolRegistry } from '../tools/index.js';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import SuccessMessage from '../components/success-message.js';
|
|
6
|
+
import InfoMessage from '../components/info-message.js';
|
|
7
|
+
import ErrorMessage from '../components/error-message.js';
|
|
8
|
+
/**
|
|
9
|
+
* Determines if a command execution failed based on multiple signals.
|
|
10
|
+
* Checks exit code first (most reliable), then looks for specific error patterns.
|
|
11
|
+
* Exported for testing purposes.
|
|
12
|
+
*/
|
|
13
|
+
export function hasCommandFailed(output) {
|
|
14
|
+
const outputStr = String(output || '');
|
|
15
|
+
// Strategy 1: Check exit code (most reliable)
|
|
16
|
+
const exitCodeMatch = outputStr.match(/^EXIT_CODE:\s*(\d+)/m);
|
|
17
|
+
if (exitCodeMatch) {
|
|
18
|
+
const exitCode = parseInt(exitCodeMatch[1], 10);
|
|
19
|
+
// Non-zero exit code indicates failure
|
|
20
|
+
if (exitCode !== 0) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Strategy 2: Check for critical error patterns
|
|
25
|
+
// Use word boundaries and case-sensitive matching to avoid false positives
|
|
26
|
+
const normalized = outputStr.toLowerCase();
|
|
27
|
+
// Critical errors that definitively indicate failure
|
|
28
|
+
const criticalErrors = [
|
|
29
|
+
/\bcommand not found\b/i,
|
|
30
|
+
/\bno such file or directory\b/i,
|
|
31
|
+
/\bpermission denied\b/i,
|
|
32
|
+
/^error:/im, // Error at start of line
|
|
33
|
+
/\berror:\s*(?!0\b)/i, // "error:" not followed by 0
|
|
34
|
+
/\bfatal\b/i,
|
|
35
|
+
/\bfailed\b/i,
|
|
36
|
+
/\bcannot\b/i,
|
|
37
|
+
];
|
|
38
|
+
for (const pattern of criticalErrors) {
|
|
39
|
+
if (pattern.test(normalized)) {
|
|
40
|
+
// Additional check: avoid false positives for success messages
|
|
41
|
+
// like "0 errors", "error-free", "no errors found"
|
|
42
|
+
if (/0\s*errors?|error-?free|no\s*errors?\s*found/i.test(normalized)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Strategy 3: Check if STDERR has content (warning: not always an error)
|
|
49
|
+
// Some tools write progress to stderr, so this is a weak signal
|
|
50
|
+
// Only use this if no other signals present
|
|
51
|
+
const hasStderr = /^STDERR:\s*\S/m.test(outputStr);
|
|
52
|
+
if (hasStderr) {
|
|
53
|
+
// Check if stderr contains actual error indicators, not just warnings/info
|
|
54
|
+
const stderrMatch = outputStr.match(/^STDERR:\s*([\s\S]*?)(?:^STDOUT:|$)/m);
|
|
55
|
+
if (stderrMatch) {
|
|
56
|
+
const stderrContent = stderrMatch[1].toLowerCase();
|
|
57
|
+
// Only treat as error if stderr contains error-like content
|
|
58
|
+
if (/\berror\b|\bfatal\b|\bfailed\b|\bcannot\b/i.test(stderrContent)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
6
65
|
export const updateCommand = {
|
|
7
66
|
name: 'update',
|
|
8
67
|
description: 'Update Nanocoder to the latest version',
|
|
@@ -14,20 +73,52 @@ export const updateCommand = {
|
|
|
14
73
|
if (updateInfo.hasUpdate) {
|
|
15
74
|
// Show updating message
|
|
16
75
|
logInfo('Downloading and installing the latest Nanocoder update...', true);
|
|
17
|
-
// Run
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
76
|
+
// Run update command if provided; otherwise show informative message
|
|
77
|
+
if (updateInfo.updateCommand) {
|
|
78
|
+
try {
|
|
79
|
+
const result = await toolRegistry.execute_bash({
|
|
80
|
+
command: updateInfo.updateCommand,
|
|
81
|
+
});
|
|
82
|
+
// Check for command failure using multiple strategies
|
|
83
|
+
if (hasCommandFailed(result)) {
|
|
84
|
+
logError('Update command executed but returned an error', true);
|
|
85
|
+
return React.createElement(ErrorMessage, {
|
|
86
|
+
message: `Update command failed. Output: ${String(result)}`,
|
|
87
|
+
hideBox: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Show success message
|
|
91
|
+
return React.createElement(SuccessMessage, {
|
|
92
|
+
message: 'Nanocoder has been updated to the latest version. Please restart your session to apply the update.',
|
|
93
|
+
hideBox: true,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
98
|
+
logError(`Failed to execute update command: ${errorMessage}`, true);
|
|
99
|
+
return React.createElement(ErrorMessage, {
|
|
100
|
+
message: `Failed to execute update command: ${errorMessage}`,
|
|
101
|
+
hideBox: true,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (updateInfo.updateMessage) {
|
|
106
|
+
// We cannot run an automated update; show instructions to user
|
|
107
|
+
return React.createElement(InfoMessage, {
|
|
108
|
+
message: updateInfo.updateMessage,
|
|
109
|
+
hideBox: true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// Fallback for unknown installation method
|
|
113
|
+
return React.createElement(InfoMessage, {
|
|
114
|
+
message: 'A new version is available. Please update using your package manager.',
|
|
24
115
|
hideBox: true,
|
|
25
116
|
});
|
|
26
117
|
}
|
|
27
118
|
else {
|
|
28
119
|
// Already up to date
|
|
29
|
-
return React.createElement(
|
|
30
|
-
message: '
|
|
120
|
+
return React.createElement(InfoMessage, {
|
|
121
|
+
message: 'You are already on the latest version.',
|
|
31
122
|
hideBox: true,
|
|
32
123
|
});
|
|
33
124
|
}
|
|
@@ -35,7 +126,10 @@ export const updateCommand = {
|
|
|
35
126
|
catch (error) {
|
|
36
127
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
37
128
|
logError(`Failed to update Nanocoder: ${errorMessage}`, true);
|
|
38
|
-
return React.createElement(
|
|
129
|
+
return React.createElement(ErrorMessage, {
|
|
130
|
+
message: `Failed to check for updates: ${errorMessage}`,
|
|
131
|
+
hideBox: true,
|
|
132
|
+
});
|
|
39
133
|
}
|
|
40
134
|
},
|
|
41
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../source/commands/update.tsx"],"names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BAED,2CAA2C;gBAC3C,OAAO,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;oBACvC,OAAO,EACN,uEAAuE;oBACxE,OAAO,EAAE,IAAI;iBACb,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,qBAAqB;gBACrB,OAAO,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;oBACvC,OAAO,EAAE,wCAAwC;oBACjD,OAAO,EAAE,IAAI;iBACb,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,YAAY,GACjB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxD,QAAQ,CAAC,+BAA+B,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE;gBACxC,OAAO,EAAE,gCAAgC,YAAY,EAAE;gBACvD,OAAO,EAAE,IAAI;aACb,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { ThemePreset } from '../types/ui.js';
|
|
2
|
-
|
|
3
|
-
hasUpdate: boolean;
|
|
4
|
-
currentVersion: string;
|
|
5
|
-
latestVersion?: string;
|
|
6
|
-
updateCommand?: string;
|
|
7
|
-
}
|
|
2
|
+
import type { UpdateInfo } from '../types/utils.js';
|
|
8
3
|
declare const _default: import("react").NamedExoticComponent<{
|
|
9
4
|
provider: string;
|
|
10
5
|
model: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../source/components/status.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../source/components/status.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;;cAcnC,MAAM;WACT,MAAM;WACN,WAAW;iBACL,UAAU,GAAG,IAAI;qBACb,OAAO;;AAXzB,wBAkIG"}
|
|
@@ -8,6 +8,7 @@ import { confDirMap } from '../config/index.js';
|
|
|
8
8
|
import { themes, getThemeColors } from '../config/themes.js';
|
|
9
9
|
// Get CWD once at module load time
|
|
10
10
|
const cwd = process.cwd();
|
|
11
|
+
// Using UpdateInfo from '../types/utils.js' for type consistency
|
|
11
12
|
export default memo(function Status({ provider, model, theme, updateInfo, agentsMdLoaded, }) {
|
|
12
13
|
const { boxWidth, isNarrow, truncatePath } = useResponsiveTerminal();
|
|
13
14
|
const colors = getThemeColors(theme);
|
|
@@ -15,8 +16,8 @@ export default memo(function Status({ provider, model, theme, updateInfo, agents
|
|
|
15
16
|
const hasAgentsMd = agentsMdLoaded ?? existsSync(`${cwd}/AGENTS.md`);
|
|
16
17
|
// Calculate max path length based on terminal size
|
|
17
18
|
const maxPathLength = isNarrow ? 30 : 60;
|
|
18
|
-
return (_jsx(_Fragment, { children: isNarrow ? (_jsxs(Box, { flexDirection: "column", marginBottom: 1, borderStyle: "round", borderColor: colors.info, paddingY: 1, paddingX: 2, children: [_jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "CWD: " }), truncatePath(cwd, maxPathLength)] }), _jsxs(Text, { color: colors.success, children: [_jsx(Text, { bold: true, children: "Model: " }), model] }), _jsxs(Text, { color: colors.primary, children: [_jsx(Text, { bold: true, children: "Theme: " }), themes[theme].displayName] }), hasAgentsMd ? (_jsx(Text, { color: colors.secondary, italic: true, children: "\u2713 AGENTS.md" })) : (_jsx(Text, { color: colors.secondary, italic: true, children: "\u2717 No AGENTS.md" })), updateInfo?.hasUpdate && (_jsxs(Text, { color: colors.warning, children: ["\u26A0 v", updateInfo.currentVersion, " \u2192 v", updateInfo.latestVersion] }))] })) : (
|
|
19
|
+
return (_jsx(_Fragment, { children: isNarrow ? (_jsxs(Box, { flexDirection: "column", marginBottom: 1, borderStyle: "round", borderColor: colors.info, paddingY: 1, paddingX: 2, children: [_jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "CWD: " }), truncatePath(cwd, maxPathLength)] }), _jsxs(Text, { color: colors.success, children: [_jsx(Text, { bold: true, children: "Model: " }), model] }), _jsxs(Text, { color: colors.primary, children: [_jsx(Text, { bold: true, children: "Theme: " }), themes[theme].displayName] }), hasAgentsMd ? (_jsx(Text, { color: colors.secondary, italic: true, children: "\u2713 AGENTS.md" })) : (_jsx(Text, { color: colors.secondary, italic: true, children: "\u2717 No AGENTS.md" })), updateInfo?.hasUpdate && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.warning, children: ["\u26A0 v", updateInfo.currentVersion, " \u2192 v", updateInfo.latestVersion] }), updateInfo.updateCommand ? (_jsxs(Text, { color: colors.secondary, children: ["\u21B3 Run: /update or ", updateInfo.updateCommand] })) : updateInfo.updateMessage ? (_jsx(Text, { color: colors.secondary, children: updateInfo.updateMessage })) : null] }))] })) : (
|
|
19
20
|
/* Normal/Wide terminal: full layout with TitledBox */
|
|
20
|
-
_jsxs(TitledBox, { borderStyle: "round", titles: ['Status'], titleStyles: titleStyles.pill, width: boxWidth, borderColor: colors.info, paddingX: 2, paddingY: 1, flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "CWD: " }), truncatePath(cwd, maxPathLength)] }), _jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "Config: " }), truncatePath(confDirMap['agents.config.json'], maxPathLength)] }), _jsxs(Text, { color: colors.success, children: [_jsx(Text, { bold: true, children: "Provider: " }), provider, ", ", _jsx(Text, { bold: true, children: "Model: " }), model] }), _jsxs(Text, { color: colors.primary, children: [_jsx(Text, { bold: true, children: "Theme: " }), themes[theme].displayName] }), hasAgentsMd ? (_jsx(Text, { color: colors.secondary, italic: true, children: _jsx(Text, { children: "\u21B3 Using AGENTS.md. Project initialized" }) })) : (_jsx(Text, { color: colors.secondary, italic: true, children: "\u21B3 No AGENTS.md file found, run `/init` to initialize this directory" })), updateInfo?.hasUpdate && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.warning, children: [_jsx(Text, { bold: true, children: "Update Available: " }), "v", updateInfo.currentVersion, " \u2192 v", updateInfo.latestVersion] }), updateInfo.updateCommand
|
|
21
|
+
_jsxs(TitledBox, { borderStyle: "round", titles: ['Status'], titleStyles: titleStyles.pill, width: boxWidth, borderColor: colors.info, paddingX: 2, paddingY: 1, flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "CWD: " }), truncatePath(cwd, maxPathLength)] }), _jsxs(Text, { color: colors.info, children: [_jsx(Text, { bold: true, children: "Config: " }), truncatePath(confDirMap['agents.config.json'], maxPathLength)] }), _jsxs(Text, { color: colors.success, children: [_jsx(Text, { bold: true, children: "Provider: " }), provider, ", ", _jsx(Text, { bold: true, children: "Model: " }), model] }), _jsxs(Text, { color: colors.primary, children: [_jsx(Text, { bold: true, children: "Theme: " }), themes[theme].displayName] }), hasAgentsMd ? (_jsx(Text, { color: colors.secondary, italic: true, children: _jsx(Text, { children: "\u21B3 Using AGENTS.md. Project initialized" }) })) : (_jsx(Text, { color: colors.secondary, italic: true, children: "\u21B3 No AGENTS.md file found, run `/init` to initialize this directory" })), updateInfo?.hasUpdate && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.warning, children: [_jsx(Text, { bold: true, children: "Update Available: " }), "v", updateInfo.currentVersion, " \u2192 v", updateInfo.latestVersion] }), updateInfo.updateCommand ? (_jsxs(Text, { color: colors.secondary, children: ["\u21B3 Run: /update or ", updateInfo.updateCommand] })) : updateInfo.updateMessage ? (_jsx(Text, { color: colors.secondary, children: updateInfo.updateMessage })) : null] }))] }, colors.primary)) }));
|
|
21
22
|
});
|
|
22
23
|
//# sourceMappingURL=status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../source/components/status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../source/components/status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAIvD,mCAAmC;AACnC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE1B,6DAA6D;AAE7D,eAAe,IAAI,CAAC,SAAS,MAAM,CAAC,EACnC,QAAQ,EACR,KAAK,EACL,KAAK,EACL,UAAU,EACV,cAAc,GAOd;IACA,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAE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AM,CAAC,OAAO,aAC1B,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,wBAAgB,EAC/B,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,IACpB,EACN,WAAW,CAAC,CAAC,CAAC,CACd,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,kBACpC,KAAC,IAAI,8DAA8C,GAC7C,CACP,CAAC,CAAC,CAAC,CACH,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,+FAG9B,CACP,EACA,UAAU,EAAE,SAAS,IAAI,CACzB,8BACC,MAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,OAAO,aAC1B,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,mCAA2B,OAC1C,UAAU,CAAC,cAAc,eAAM,UAAU,CAAC,aAAa,IAClD,EACN,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAC3B,MAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,wCACT,UAAU,CAAC,aAAa,IACrC,CACP,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAC9B,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,YAAG,UAAU,CAAC,aAAa,GAAQ,CAChE,CAAC,CAAC,CAAC,IAAI,IACN,CACH,KApDI,MAAM,CAAC,OAAO,CAqDR,CACZ,GACC,CACH,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-confirmation.d.ts","sourceRoot":"","sources":["../../source/components/tool-confirmation.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-confirmation.d.ts","sourceRoot":"","sources":["../../source/components/tool-confirmation.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAO3C,UAAU,qBAAqB;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAOD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACxC,QAAQ,EACR,SAAS,EACT,QAAQ,GACR,EAAE,qBAAqB,2CA0JvB"}
|
|
@@ -6,6 +6,8 @@ import { useTheme } from '../hooks/useTheme.js';
|
|
|
6
6
|
import { toolFormatters } from '../tools/index.js';
|
|
7
7
|
import { useTerminalWidth } from '../hooks/useTerminalWidth.js';
|
|
8
8
|
import { getToolManager } from '../message-handler.js';
|
|
9
|
+
import { parseToolArguments } from '../utils/tool-args-parser.js';
|
|
10
|
+
import { formatError } from '../utils/error-formatter.js';
|
|
9
11
|
export default function ToolConfirmation({ toolCall, onConfirm, onCancel, }) {
|
|
10
12
|
const boxWidth = useTerminalWidth();
|
|
11
13
|
const { colors } = useTheme();
|
|
@@ -28,15 +30,7 @@ export default function ToolConfirmation({ toolCall, onConfirm, onCancel, }) {
|
|
|
28
30
|
if (validator) {
|
|
29
31
|
try {
|
|
30
32
|
// Parse arguments if they're a JSON string
|
|
31
|
-
|
|
32
|
-
if (typeof parsedArgs === 'string') {
|
|
33
|
-
try {
|
|
34
|
-
parsedArgs = JSON.parse(parsedArgs);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// If parsing fails, use as-is
|
|
38
|
-
}
|
|
39
|
-
}
|
|
33
|
+
const parsedArgs = parseToolArguments(toolCall.function.arguments);
|
|
40
34
|
const validationResult = await validator(parsedArgs);
|
|
41
35
|
if (!validationResult.valid) {
|
|
42
36
|
setValidationError(validationResult.error);
|
|
@@ -47,7 +41,7 @@ export default function ToolConfirmation({ toolCall, onConfirm, onCancel, }) {
|
|
|
47
41
|
}
|
|
48
42
|
catch (error) {
|
|
49
43
|
console.error('Error running validator:', error);
|
|
50
|
-
const errorMsg = `Validation error: ${
|
|
44
|
+
const errorMsg = `Validation error: ${formatError(error)}`;
|
|
51
45
|
setValidationError(errorMsg);
|
|
52
46
|
setHasValidationError(true);
|
|
53
47
|
setFormatterPreview(_jsx(Text, { color: colors.error, children: errorMsg }));
|
|
@@ -60,15 +54,7 @@ export default function ToolConfirmation({ toolCall, onConfirm, onCancel, }) {
|
|
|
60
54
|
setIsLoadingPreview(true);
|
|
61
55
|
try {
|
|
62
56
|
// Parse arguments if they're a JSON string
|
|
63
|
-
|
|
64
|
-
if (typeof parsedArgs === 'string') {
|
|
65
|
-
try {
|
|
66
|
-
parsedArgs = JSON.parse(parsedArgs);
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// If parsing fails, use as-is
|
|
70
|
-
}
|
|
71
|
-
}
|
|
57
|
+
const parsedArgs = parseToolArguments(toolCall.function.arguments);
|
|
72
58
|
const preview = await formatter(parsedArgs);
|
|
73
59
|
setFormatterPreview(preview);
|
|
74
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-confirmation.js","sourceRoot":"","sources":["../../source/components/tool-confirmation.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAC,MAAM,KAAK,CAAC;AACxC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAK3C,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-confirmation.js","sourceRoot":"","sources":["../../source/components/tool-confirmation.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA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,CAAC,UAAU,GAAG;wCAC5E,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAClC,GAAG,GACA,GACF,EAEN,KAAC,WAAW,IAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAI,EAEvD,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YAChB,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,uCAA+B,GACvD,IACJ,CACH,EAGA,iBAAiB,IAAI,CAAC,kBAAkB,IAAI,CAC5C,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,aAChB,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,iEAElB,EACP,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,yCAAiC,IACzD,CACN,IACI,GACD,CACN,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../source/components/user-input.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAC,eAAe,EAA0B,MAAM,cAAc,CAAC;AAOtE,UAAU,SAAS;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,QAAQ,EACR,WAAW,EACX,cAAmB,EACnB,QAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,eAA0B,GAC1B,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../source/components/user-input.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAC,eAAe,EAA0B,MAAM,cAAc,CAAC;AAOtE,UAAU,SAAS;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,QAAQ,EACR,WAAW,EACX,cAAmB,EACnB,QAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,eAA0B,GAC1B,EAAE,SAAS,2CA6eX"}
|