@defai.digital/ax-cli 3.5.4 → 3.6.1

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.
Files changed (162) hide show
  1. package/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +69 -0
  2. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +24 -0
  3. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +69 -0
  4. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +44 -0
  5. package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +24 -0
  6. package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +44 -0
  7. package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +69 -0
  8. package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +24 -0
  9. package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +24 -0
  10. package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +69 -0
  11. package/.ax-cli/memory.json +15 -8
  12. package/README.md +423 -82
  13. package/ax.config.json +333 -0
  14. package/config-defaults/messages.yaml +75 -0
  15. package/config-defaults/models.yaml +66 -0
  16. package/config-defaults/prompts.yaml +156 -0
  17. package/config-defaults/settings.yaml +86 -0
  18. package/dist/agent/chat-history-manager.d.ts +56 -0
  19. package/dist/agent/chat-history-manager.js +150 -0
  20. package/dist/agent/chat-history-manager.js.map +1 -0
  21. package/dist/agent/llm-agent.js +1 -1
  22. package/dist/agent/llm-agent.js.map +1 -1
  23. package/dist/agent/tool-manager.d.ts +39 -0
  24. package/dist/agent/tool-manager.js +76 -0
  25. package/dist/agent/tool-manager.js.map +1 -0
  26. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js +7 -9
  27. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js.map +1 -1
  28. package/dist/analyzers/code-smells/detectors/dead-code-detector.js +1 -1
  29. package/dist/analyzers/code-smells/detectors/dead-code-detector.js.map +1 -1
  30. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +22 -10
  31. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -1
  32. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js +1 -1
  33. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js.map +1 -1
  34. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js +1 -1
  35. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js.map +1 -1
  36. package/dist/analyzers/code-smells/detectors/large-class-detector.js +4 -1
  37. package/dist/analyzers/code-smells/detectors/large-class-detector.js.map +1 -1
  38. package/dist/analyzers/code-smells/detectors/long-method-detector.js +4 -1
  39. package/dist/analyzers/code-smells/detectors/long-method-detector.js.map +1 -1
  40. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js +4 -1
  41. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js.map +1 -1
  42. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js +4 -5
  43. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js.map +1 -1
  44. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js +4 -1
  45. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js.map +1 -1
  46. package/dist/commands/memory.js +1 -1
  47. package/dist/commands/memory.js.map +1 -1
  48. package/dist/commands/setup.js +19 -6
  49. package/dist/commands/setup.js.map +1 -1
  50. package/dist/index.js +7 -0
  51. package/dist/index.js.bak +664 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/llm/client.d.ts +1 -0
  54. package/dist/llm/client.js +44 -0
  55. package/dist/llm/client.js.map +1 -1
  56. package/dist/mcp/health.js +4 -2
  57. package/dist/mcp/health.js.map +1 -1
  58. package/dist/mcp/ssrf-protection.d.ts +86 -0
  59. package/dist/mcp/ssrf-protection.js +313 -0
  60. package/dist/mcp/ssrf-protection.js.map +1 -0
  61. package/dist/mcp/validation.d.ts +4 -0
  62. package/dist/mcp/validation.js +122 -11
  63. package/dist/mcp/validation.js.map +1 -1
  64. package/dist/schemas/settings-schemas.d.ts +53 -0
  65. package/dist/schemas/settings-schemas.js +47 -0
  66. package/dist/schemas/settings-schemas.js.map +1 -1
  67. package/dist/tools/bash.d.ts +3 -2
  68. package/dist/tools/bash.js +31 -2
  69. package/dist/tools/bash.js.map +1 -1
  70. package/dist/tools/search.d.ts +1 -1
  71. package/dist/tools/search.js +121 -128
  72. package/dist/tools/search.js.map +1 -1
  73. package/dist/tools/text-editor.js +52 -15
  74. package/dist/tools/text-editor.js.map +1 -1
  75. package/dist/tools/web-search/index.d.ts +0 -2
  76. package/dist/tools/web-search/index.js +0 -2
  77. package/dist/tools/web-search/index.js.map +1 -1
  78. package/dist/tools/web-search/router.d.ts +0 -2
  79. package/dist/tools/web-search/router.js +2 -37
  80. package/dist/tools/web-search/router.js.map +1 -1
  81. package/dist/tools/web-search/web-search-tool.js +2 -12
  82. package/dist/tools/web-search/web-search-tool.js.map +1 -1
  83. package/dist/ui/components/chat-history.js +1 -1
  84. package/dist/ui/components/chat-history.js.map +1 -1
  85. package/dist/ui/components/chat-input.d.ts +4 -1
  86. package/dist/ui/components/chat-input.js +133 -52
  87. package/dist/ui/components/chat-input.js.map +1 -1
  88. package/dist/ui/components/chat-interface.js +5 -4
  89. package/dist/ui/components/chat-interface.js.map +1 -1
  90. package/dist/ui/components/confirmation-dialog.js +1 -1
  91. package/dist/ui/components/confirmation-dialog.js.map +1 -1
  92. package/dist/ui/components/keyboard-hints.js +2 -0
  93. package/dist/ui/components/keyboard-hints.js.map +1 -1
  94. package/dist/ui/components/status-bar.js +3 -13
  95. package/dist/ui/components/status-bar.js.map +1 -1
  96. package/dist/ui/components/welcome-panel.js +4 -0
  97. package/dist/ui/components/welcome-panel.js.map +1 -1
  98. package/dist/ui/hooks/use-chat-reducer.d.ts +61 -0
  99. package/dist/ui/hooks/use-chat-reducer.js +118 -0
  100. package/dist/ui/hooks/use-chat-reducer.js.map +1 -0
  101. package/dist/ui/hooks/use-enhanced-input.d.ts +44 -0
  102. package/dist/ui/hooks/use-enhanced-input.js +364 -0
  103. package/dist/ui/hooks/use-enhanced-input.js.map +1 -0
  104. package/dist/ui/hooks/use-input-handler.d.ts +48 -0
  105. package/dist/ui/hooks/use-input-handler.js +1446 -0
  106. package/dist/ui/hooks/use-input-handler.js.map +1 -0
  107. package/dist/utils/audit-logger.d.ts +205 -0
  108. package/dist/utils/audit-logger.js +269 -0
  109. package/dist/utils/audit-logger.js.map +1 -0
  110. package/dist/utils/command-security.d.ts +85 -0
  111. package/dist/utils/command-security.js +200 -0
  112. package/dist/utils/command-security.js.map +1 -0
  113. package/dist/utils/config-loader.js +3 -3
  114. package/dist/utils/config-loader.js.map +1 -1
  115. package/dist/utils/encryption.d.ts +78 -0
  116. package/dist/utils/encryption.js +216 -0
  117. package/dist/utils/encryption.js.map +1 -0
  118. package/dist/utils/error-sanitizer.d.ts +119 -0
  119. package/dist/utils/error-sanitizer.js +253 -0
  120. package/dist/utils/error-sanitizer.js.map +1 -0
  121. package/dist/utils/input-sanitizer.d.ts +210 -0
  122. package/dist/utils/input-sanitizer.js +362 -0
  123. package/dist/utils/input-sanitizer.js.map +1 -0
  124. package/dist/utils/json-utils.d.ts +13 -0
  125. package/dist/utils/json-utils.js +55 -1
  126. package/dist/utils/json-utils.js.map +1 -1
  127. package/dist/utils/paste-collapse.d.ts +46 -0
  128. package/dist/utils/paste-collapse.js +77 -0
  129. package/dist/utils/paste-collapse.js.map +1 -0
  130. package/dist/utils/paste-utils.d.ts +99 -0
  131. package/dist/utils/paste-utils.js +239 -0
  132. package/dist/utils/paste-utils.js.map +1 -0
  133. package/dist/utils/path-security.d.ts +90 -0
  134. package/dist/utils/path-security.js +328 -0
  135. package/dist/utils/path-security.js.map +1 -0
  136. package/dist/utils/process-pool.d.ts +105 -0
  137. package/dist/utils/process-pool.js +326 -0
  138. package/dist/utils/process-pool.js.map +1 -0
  139. package/dist/utils/rate-limiter.d.ts +221 -0
  140. package/dist/utils/rate-limiter.js +317 -0
  141. package/dist/utils/rate-limiter.js.map +1 -0
  142. package/dist/utils/settings-manager.js +99 -6
  143. package/dist/utils/settings-manager.js.map +1 -1
  144. package/dist/utils/streaming-analyzer.js +9 -21
  145. package/dist/utils/streaming-analyzer.js.map +1 -1
  146. package/package.json +3 -7
  147. package/packages/schemas/dist/index.d.ts +14 -0
  148. package/packages/schemas/dist/index.d.ts.map +1 -0
  149. package/packages/schemas/dist/index.js +19 -0
  150. package/packages/schemas/dist/index.js.map +1 -0
  151. package/packages/schemas/dist/public/core/brand-types.d.ts +308 -0
  152. package/packages/schemas/dist/public/core/brand-types.d.ts.map +1 -0
  153. package/packages/schemas/dist/public/core/brand-types.js +243 -0
  154. package/packages/schemas/dist/public/core/brand-types.js.map +1 -0
  155. package/packages/schemas/dist/public/core/enums.d.ts +227 -0
  156. package/packages/schemas/dist/public/core/enums.d.ts.map +1 -0
  157. package/packages/schemas/dist/public/core/enums.js +222 -0
  158. package/packages/schemas/dist/public/core/enums.js.map +1 -0
  159. package/packages/schemas/dist/public/core/id-types.d.ts +286 -0
  160. package/packages/schemas/dist/public/core/id-types.d.ts.map +1 -0
  161. package/packages/schemas/dist/public/core/id-types.js +136 -0
  162. package/packages/schemas/dist/public/core/id-types.js.map +1 -0
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Paste handling utilities for detecting and managing large paste operations
3
+ * Implements smart paste detection, collapsing, and expansion
4
+ */
5
+ /**
6
+ * Represents a pasted block of text
7
+ */
8
+ export interface PastedBlock {
9
+ id: number;
10
+ content: string;
11
+ lineCount: number;
12
+ collapsed: boolean;
13
+ startPosition: number;
14
+ previewLines: string[];
15
+ }
16
+ /**
17
+ * Paste detection and management class
18
+ */
19
+ export declare class PasteDetector {
20
+ private inputBuffer;
21
+ private readonly PASTE_DETECTION_WINDOW;
22
+ private readonly PASTE_THRESHOLD;
23
+ private accumulatedInput;
24
+ private lastInputTime;
25
+ /**
26
+ * Detect if input is part of a paste operation
27
+ * @param inputChar - Character(s) being input
28
+ * @returns true if paste detected
29
+ */
30
+ detectPaste(inputChar: string): boolean;
31
+ /**
32
+ * Accumulate input during paste operation
33
+ * @param inputChar - Character(s) being input
34
+ * @param timeout - Timeout to consider paste complete (ms)
35
+ * @returns accumulated paste content or null if still accumulating
36
+ */
37
+ accumulatePasteInput(inputChar: string, timeout?: number): string | null;
38
+ /**
39
+ * Get and clear accumulated input
40
+ */
41
+ getAccumulatedInput(): string;
42
+ /**
43
+ * Reset detector state
44
+ */
45
+ reset(): void;
46
+ }
47
+ /**
48
+ * Check if pasted content should be collapsed
49
+ * @param content - Pasted content
50
+ * @returns true if should collapse
51
+ */
52
+ export declare function shouldCollapsePaste(content: string): boolean;
53
+ /**
54
+ * Count lines in text (handles different line endings)
55
+ * @param text - Text to count lines in
56
+ * @returns number of lines
57
+ */
58
+ export declare function countLines(text: string): number;
59
+ /**
60
+ * Create a pasted block from content
61
+ * @param id - Unique block ID
62
+ * @param content - Pasted content
63
+ * @param startPosition - Position in input where inserted
64
+ * @returns PastedBlock object
65
+ */
66
+ export declare function createPastedBlock(id: number, content: string, startPosition: number): PastedBlock;
67
+ /**
68
+ * Generate placeholder text for collapsed paste
69
+ * @param block - Pasted block
70
+ * @returns placeholder string
71
+ */
72
+ export declare function generatePlaceholder(block: PastedBlock): string;
73
+ /**
74
+ * Extract placeholder ID from placeholder text
75
+ * @param placeholder - Placeholder text
76
+ * @returns block ID or null if not a placeholder
77
+ */
78
+ export declare function extractPlaceholderId(placeholder: string): number | null;
79
+ /**
80
+ * Find pasted block at cursor position
81
+ * @param input - Current input text
82
+ * @param cursorPosition - Cursor position
83
+ * @param pastedBlocks - Array of pasted blocks
84
+ * @returns PastedBlock if cursor is on one, null otherwise
85
+ */
86
+ export declare function findBlockAtCursor(input: string, cursorPosition: number, pastedBlocks: PastedBlock[]): PastedBlock | null;
87
+ /**
88
+ * Expand all placeholders in text
89
+ * @param text - Text with placeholders
90
+ * @param pastedBlocks - Array of pasted blocks
91
+ * @returns text with all placeholders expanded
92
+ */
93
+ export declare function expandAllPlaceholders(text: string, pastedBlocks: PastedBlock[]): string;
94
+ /**
95
+ * Validate paste settings
96
+ * @param settings - Paste settings to validate
97
+ * @returns true if valid
98
+ */
99
+ export declare function validatePasteSettings(settings: any): boolean;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Paste handling utilities for detecting and managing large paste operations
3
+ * Implements smart paste detection, collapsing, and expansion
4
+ */
5
+ import { getSettingsManager } from "./settings-manager.js";
6
+ /**
7
+ * Paste detection and management class
8
+ */
9
+ export class PasteDetector {
10
+ inputBuffer = [];
11
+ PASTE_DETECTION_WINDOW = 100; // 100ms window
12
+ PASTE_THRESHOLD = 10; // 10+ chars = paste
13
+ accumulatedInput = "";
14
+ lastInputTime = 0;
15
+ /**
16
+ * Detect if input is part of a paste operation
17
+ * @param inputChar - Character(s) being input
18
+ * @returns true if paste detected
19
+ */
20
+ detectPaste(inputChar) {
21
+ const now = Date.now();
22
+ // Add to buffer
23
+ this.inputBuffer.push({ char: inputChar, timestamp: now });
24
+ // Clean old entries (older than detection window)
25
+ this.inputBuffer = this.inputBuffer.filter(entry => now - entry.timestamp < this.PASTE_DETECTION_WINDOW);
26
+ // Count total characters in window
27
+ const totalChars = this.inputBuffer.reduce((sum, entry) => sum + entry.char.length, 0);
28
+ return totalChars >= this.PASTE_THRESHOLD;
29
+ }
30
+ /**
31
+ * Accumulate input during paste operation
32
+ * @param inputChar - Character(s) being input
33
+ * @param timeout - Timeout to consider paste complete (ms)
34
+ * @returns accumulated paste content or null if still accumulating
35
+ */
36
+ accumulatePasteInput(inputChar, timeout = 50) {
37
+ const now = Date.now();
38
+ // If too much time passed, start new accumulation
39
+ if (now - this.lastInputTime > timeout && this.accumulatedInput) {
40
+ const result = this.accumulatedInput;
41
+ this.accumulatedInput = inputChar;
42
+ this.lastInputTime = now;
43
+ return result;
44
+ }
45
+ // Accumulate
46
+ this.accumulatedInput += inputChar;
47
+ this.lastInputTime = now;
48
+ return null;
49
+ }
50
+ /**
51
+ * Get and clear accumulated input
52
+ */
53
+ getAccumulatedInput() {
54
+ const result = this.accumulatedInput;
55
+ this.accumulatedInput = "";
56
+ this.lastInputTime = 0;
57
+ return result;
58
+ }
59
+ /**
60
+ * Reset detector state
61
+ */
62
+ reset() {
63
+ this.inputBuffer = [];
64
+ this.accumulatedInput = "";
65
+ this.lastInputTime = 0;
66
+ }
67
+ }
68
+ /**
69
+ * Check if pasted content should be collapsed
70
+ * @param content - Pasted content
71
+ * @returns true if should collapse
72
+ */
73
+ export function shouldCollapsePaste(content) {
74
+ const settings = getSettingsManager();
75
+ const userSettings = settings.loadUserSettings();
76
+ // Check if auto-collapse is enabled (default: true)
77
+ const autoCollapse = userSettings.paste?.autoCollapse ?? true;
78
+ if (!autoCollapse) {
79
+ return false;
80
+ }
81
+ // Get collapse threshold (default: 20 lines)
82
+ const threshold = userSettings.paste?.collapseThreshold ?? 20;
83
+ // Count lines
84
+ const lineCount = countLines(content);
85
+ return lineCount >= threshold;
86
+ }
87
+ /**
88
+ * Count lines in text (handles different line endings)
89
+ * @param text - Text to count lines in
90
+ * @returns number of lines
91
+ */
92
+ export function countLines(text) {
93
+ if (!text)
94
+ return 0;
95
+ // Normalize line endings to \n
96
+ const normalized = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
97
+ // Count newlines + 1 (for last line without \n)
98
+ const newlineCount = (normalized.match(/\n/g) || []).length;
99
+ // If text ends with newline, don't count extra line
100
+ return text.endsWith('\n') || text.endsWith('\r\n') ? newlineCount : newlineCount + 1;
101
+ }
102
+ /**
103
+ * Create a pasted block from content
104
+ * @param id - Unique block ID
105
+ * @param content - Pasted content
106
+ * @param startPosition - Position in input where inserted
107
+ * @returns PastedBlock object
108
+ */
109
+ export function createPastedBlock(id, content, startPosition) {
110
+ const settings = getSettingsManager();
111
+ const userSettings = settings.loadUserSettings();
112
+ const lineCount = countLines(content);
113
+ const previewLineCount = userSettings.paste?.previewLines ?? 2;
114
+ // Extract preview lines
115
+ const lines = content.split(/\r?\n/);
116
+ const previewLines = lines.slice(0, previewLineCount);
117
+ return {
118
+ id,
119
+ content,
120
+ lineCount,
121
+ collapsed: true,
122
+ startPosition,
123
+ previewLines,
124
+ };
125
+ }
126
+ /**
127
+ * Generate placeholder text for collapsed paste
128
+ * @param block - Pasted block
129
+ * @returns placeholder string
130
+ */
131
+ export function generatePlaceholder(block) {
132
+ const settings = getSettingsManager();
133
+ const userSettings = settings.loadUserSettings();
134
+ const showLineCount = userSettings.paste?.showLineCount ?? true;
135
+ const showPreview = userSettings.paste?.showPreview ?? false;
136
+ let placeholder = `[Pasted text #${block.id}`;
137
+ if (showLineCount) {
138
+ placeholder += ` +${block.lineCount} lines`;
139
+ }
140
+ placeholder += `]`;
141
+ // Add preview if enabled
142
+ if (showPreview && block.previewLines.length > 0) {
143
+ const preview = block.previewLines
144
+ .map(line => line.slice(0, 60)) // Max 60 chars per line
145
+ .join('\n');
146
+ placeholder += `\n${preview}`;
147
+ if (block.lineCount > block.previewLines.length) {
148
+ placeholder += `\n... (${block.lineCount - block.previewLines.length} more lines)`;
149
+ }
150
+ }
151
+ return placeholder;
152
+ }
153
+ /**
154
+ * Extract placeholder ID from placeholder text
155
+ * @param placeholder - Placeholder text
156
+ * @returns block ID or null if not a placeholder
157
+ */
158
+ export function extractPlaceholderId(placeholder) {
159
+ const match = placeholder.match(/\[Pasted text #(\d+)/);
160
+ return match ? parseInt(match[1], 10) : null;
161
+ }
162
+ /**
163
+ * Find pasted block at cursor position
164
+ * @param input - Current input text
165
+ * @param cursorPosition - Cursor position
166
+ * @param pastedBlocks - Array of pasted blocks
167
+ * @returns PastedBlock if cursor is on one, null otherwise
168
+ */
169
+ export function findBlockAtCursor(input, cursorPosition, pastedBlocks) {
170
+ for (const block of pastedBlocks) {
171
+ // Check if block is collapsed (placeholder in input)
172
+ if (block.collapsed) {
173
+ const placeholder = generatePlaceholder(block);
174
+ const blockStart = input.indexOf(placeholder);
175
+ if (blockStart === -1)
176
+ continue;
177
+ const blockEnd = blockStart + placeholder.length;
178
+ if (cursorPosition >= blockStart && cursorPosition <= blockEnd) {
179
+ return block;
180
+ }
181
+ }
182
+ else {
183
+ // Block is expanded (full content in input)
184
+ const blockStart = input.indexOf(block.content);
185
+ if (blockStart === -1)
186
+ continue;
187
+ const blockEnd = blockStart + block.content.length;
188
+ if (cursorPosition >= blockStart && cursorPosition <= blockEnd) {
189
+ return block;
190
+ }
191
+ }
192
+ }
193
+ return null;
194
+ }
195
+ /**
196
+ * Expand all placeholders in text
197
+ * @param text - Text with placeholders
198
+ * @param pastedBlocks - Array of pasted blocks
199
+ * @returns text with all placeholders expanded
200
+ */
201
+ export function expandAllPlaceholders(text, pastedBlocks) {
202
+ let result = text;
203
+ // Sort blocks by ID descending to replace from end to start
204
+ // This prevents position shifts during replacement
205
+ const sortedBlocks = [...pastedBlocks].sort((a, b) => b.id - a.id);
206
+ for (const block of sortedBlocks) {
207
+ const placeholder = generatePlaceholder(block);
208
+ result = result.replace(placeholder, block.content);
209
+ }
210
+ return result;
211
+ }
212
+ /**
213
+ * Validate paste settings
214
+ * @param settings - Paste settings to validate
215
+ * @returns true if valid
216
+ */
217
+ export function validatePasteSettings(settings) {
218
+ if (!settings)
219
+ return true;
220
+ if (typeof settings.autoCollapse !== 'undefined' && typeof settings.autoCollapse !== 'boolean') {
221
+ return false;
222
+ }
223
+ if (typeof settings.collapseThreshold !== 'undefined') {
224
+ if (typeof settings.collapseThreshold !== 'number' ||
225
+ settings.collapseThreshold < 1 ||
226
+ settings.collapseThreshold > 100) {
227
+ return false;
228
+ }
229
+ }
230
+ if (typeof settings.previewLines !== 'undefined') {
231
+ if (typeof settings.previewLines !== 'number' ||
232
+ settings.previewLines < 0 ||
233
+ settings.previewLines > 10) {
234
+ return false;
235
+ }
236
+ }
237
+ return true;
238
+ }
239
+ //# sourceMappingURL=paste-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-utils.js","sourceRoot":"","sources":["../../src/utils/paste-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAsB3D;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,WAAW,GAAuB,EAAE,CAAC;IAC5B,sBAAsB,GAAG,GAAG,CAAC,CAAC,eAAe;IAC7C,eAAe,GAAG,EAAE,CAAC,CAAC,oBAAoB;IACnD,gBAAgB,GAAG,EAAE,CAAC;IACtB,aAAa,GAAG,CAAC,CAAC;IAE1B;;;;OAIG;IACI,WAAW,CAAC,SAAiB;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,gBAAgB;QAChB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAE3D,kDAAkD;QAClD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACxC,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,sBAAsB,CAC7D,CAAC;QAEF,mCAAmC;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CACxC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EACvC,CAAC,CACF,CAAC;QAEF,OAAO,UAAU,IAAI,IAAI,CAAC,e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ilities
3
+ *
4
+ * Provides comprehensive path validation to prevent path traversal,
5
+ * symlink attacks, and access to dangerous system directories (REQ-SEC-002).
6
+ *
7
+ * @module path-security
8
+ */
9
+ /**
10
+ * Result of path validation
11
+ */
12
+ export interface PathValidationResult {
13
+ success: boolean;
14
+ path?: string;
15
+ error?: string;
16
+ }
17
+ /**
18
+ * Options for path validation
19
+ */
20
+ export interface PathValidationOptions {
21
+ allowSymlinks?: boolean;
22
+ allowedRoots?: string[];
23
+ checkExists?: boolean;
24
+ }
25
+ /**
26
+ * Get OS-specific dangerous paths that should never be accessed.
27
+ *
28
+ * @returns Array of dangerous path prefixes
29
+ */
30
+ export declare function getDangerousPathsForOS(): string[];
31
+ /**
32
+ * Get dangerous file patterns that should be blocked.
33
+ *
34
+ * @returns Array of dangerous file patterns (strings or regexes)
35
+ */
36
+ export declare function getDangerousFilePatterns(): Array<string | RegExp>;
37
+ /**
38
+ * Check if a path matches a dangerous file pattern.
39
+ *
40
+ * @param filePath - Path to check
41
+ * @returns True if file matches dangerous pattern
42
+ */
43
+ export declare function isDangerousFile(filePath: string): boolean;
44
+ /**
45
+ * Canonicalize a path by resolving symlinks and normalizing.
46
+ *
47
+ * @param filePath - Path to canonicalize
48
+ * @returns Canonicalized path or original if canonicalization fails
49
+ */
50
+ export declare function canonicalizePath(filePath: string): Promise<string>;
51
+ /**
52
+ * Check if a path contains symlinks in any component.
53
+ *
54
+ * @param filePath - Path to check
55
+ * @returns True if any component is a symlink
56
+ */
57
+ export declare function containsSymlinks(filePath: string): Promise<boolean>;
58
+ /**
59
+ * Validate a file path for security.
60
+ *
61
+ * Performs comprehensive checks:
62
+ * 1. Canonicalization (resolve symlinks)
63
+ * 2. Allowed root validation
64
+ * 3. Dangerous path blocking
65
+ * 4. Symlink detection
66
+ * 5. Dangerous file detection
67
+ *
68
+ * @param filePath - Path to validate
69
+ * @param options - Validation options
70
+ * @returns Validation result with success status and validated path
71
+ */
72
+ export declare function validatePathSecure(filePath: string, options?: PathValidationOptions): Promise<PathValidationResult>;
73
+ /**
74
+ * Synchronous version of validatePathSecure.
75
+ * Less secure (doesn't resolve symlinks), use async version when possible.
76
+ *
77
+ * @param filePath - Path to validate
78
+ * @param options - Validation options
79
+ * @returns Validation result
80
+ */
81
+ export declare function validatePathSecureSync(filePath: string, options?: PathValidationOptions): PathValidationResult;
82
+ /**
83
+ * Create a safe path joiner that validates the result.
84
+ *
85
+ * @param basePath - Base directory path
86
+ * @param relativePath - Relative path to join
87
+ * @param options - Validation options
88
+ * @returns Validated joined path or null if invalid
89
+ */
90
+ export declare function safePathJoin(basePath: string, relativePath: string, options?: PathValidationOptions): Promise<string | null>;