@nocturnium/svelte-ide 1.0.0-rc.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.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/components/agents/AgentActivityPanel.svelte +565 -0
- package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
- package/dist/components/agents/AgentAvatar.svelte +417 -0
- package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
- package/dist/components/agents/AgentCursor.svelte +224 -0
- package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
- package/dist/components/agents/AgentPresenceBar.svelte +261 -0
- package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
- package/dist/components/agents/index.d.ts +4 -0
- package/dist/components/agents/index.js +5 -0
- package/dist/components/ai/AIConversationList.svelte +524 -0
- package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
- package/dist/components/ai/AIEditPreview.svelte +132 -0
- package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
- package/dist/components/ai/AIInlineEdit.svelte +155 -0
- package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
- package/dist/components/ai/AIMessage.svelte +239 -0
- package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
- package/dist/components/ai/AIMessageActions.svelte +176 -0
- package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
- package/dist/components/ai/AIMessageContent.svelte +355 -0
- package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
- package/dist/components/ai/AIPanel.svelte +561 -0
- package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
- package/dist/components/ai/AISuggestionWidget.svelte +132 -0
- package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
- package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
- package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
- package/dist/components/ai/index.d.ts +9 -0
- package/dist/components/ai/index.js +10 -0
- package/dist/components/core/Avatar.svelte +110 -0
- package/dist/components/core/Avatar.svelte.d.ts +12 -0
- package/dist/components/core/Badge.svelte +98 -0
- package/dist/components/core/Badge.svelte.d.ts +11 -0
- package/dist/components/core/Button.svelte +175 -0
- package/dist/components/core/Button.svelte.d.ts +18 -0
- package/dist/components/core/ConnectionStatus.svelte +294 -0
- package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
- package/dist/components/core/ContextMenu.svelte +176 -0
- package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
- package/dist/components/core/ErrorBoundary.svelte +277 -0
- package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
- package/dist/components/core/Icon.svelte +107 -0
- package/dist/components/core/Icon.svelte.d.ts +8 -0
- package/dist/components/core/Input.svelte +138 -0
- package/dist/components/core/Input.svelte.d.ts +20 -0
- package/dist/components/core/Kbd.svelte +34 -0
- package/dist/components/core/Kbd.svelte.d.ts +7 -0
- package/dist/components/core/ResizeHandle.svelte +200 -0
- package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
- package/dist/components/core/Spinner.svelte +35 -0
- package/dist/components/core/Spinner.svelte.d.ts +7 -0
- package/dist/components/core/Textarea.svelte +112 -0
- package/dist/components/core/Textarea.svelte.d.ts +18 -0
- package/dist/components/core/Tooltip.svelte +103 -0
- package/dist/components/core/Tooltip.svelte.d.ts +11 -0
- package/dist/components/core/index.d.ts +13 -0
- package/dist/components/core/index.js +14 -0
- package/dist/components/editor/AIFocusLayer.svelte +430 -0
- package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
- package/dist/components/editor/Breadcrumbs.svelte +435 -0
- package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
- package/dist/components/editor/BreakpointLayer.svelte +642 -0
- package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
- package/dist/components/editor/CollaborativeEditor.svelte +218 -0
- package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
- package/dist/components/editor/CommandPalette.svelte +434 -0
- package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
- package/dist/components/editor/ComplexityLayer.svelte +293 -0
- package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
- package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
- package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
- package/dist/components/editor/ContextLens.svelte +262 -0
- package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
- package/dist/components/editor/CustomEditor.svelte +1242 -0
- package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
- package/dist/components/editor/DebugConsole.svelte +646 -0
- package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
- package/dist/components/editor/EchoCursorLayer.svelte +363 -0
- package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
- package/dist/components/editor/Editor.svelte +61 -0
- package/dist/components/editor/Editor.svelte.d.ts +22 -0
- package/dist/components/editor/EditorGutter.svelte +119 -0
- package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
- package/dist/components/editor/EditorLines.svelte +182 -0
- package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
- package/dist/components/editor/EditorPane.svelte +134 -0
- package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
- package/dist/components/editor/EditorSelections.svelte +186 -0
- package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
- package/dist/components/editor/EditorTabs.svelte +170 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
- package/dist/components/editor/FileExplorer.svelte +811 -0
- package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
- package/dist/components/editor/FileIcon.svelte +110 -0
- package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
- package/dist/components/editor/FindReplace.svelte +448 -0
- package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
- package/dist/components/editor/GhostBracketLayer.svelte +391 -0
- package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
- package/dist/components/editor/GitBlameLayer.svelte +436 -0
- package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
- package/dist/components/editor/InlineDiffLayer.svelte +337 -0
- package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
- package/dist/components/editor/MinimalEditor.svelte +75 -0
- package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
- package/dist/components/editor/MinimalEditor2.svelte +84 -0
- package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
- package/dist/components/editor/Minimap.svelte +327 -0
- package/dist/components/editor/Minimap.svelte.d.ts +34 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
- package/dist/components/editor/ProblemsPanel.svelte +628 -0
- package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
- package/dist/components/editor/QuickActionsMenu.svelte +403 -0
- package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
- package/dist/components/editor/SnippetPalette.svelte +530 -0
- package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
- package/dist/components/editor/StructureMap.svelte +431 -0
- package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
- package/dist/components/editor/SymbolOutline.svelte +722 -0
- package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
- package/dist/components/editor/TimelineScrubber.svelte +470 -0
- package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
- package/dist/components/editor/TokenRenderer.svelte +69 -0
- package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
- package/dist/components/editor/constants.d.ts +32 -0
- package/dist/components/editor/constants.js +36 -0
- package/dist/components/editor/core/ai-awareness.d.ts +176 -0
- package/dist/components/editor/core/ai-awareness.js +210 -0
- package/dist/components/editor/core/bracket-healer.d.ts +189 -0
- package/dist/components/editor/core/bracket-healer.js +406 -0
- package/dist/components/editor/core/breakpoints.d.ts +203 -0
- package/dist/components/editor/core/breakpoints.js +414 -0
- package/dist/components/editor/core/commands.d.ts +108 -0
- package/dist/components/editor/core/commands.js +246 -0
- package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
- package/dist/components/editor/core/complexity-analyzer.js +376 -0
- package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
- package/dist/components/editor/core/conflict-predictor.js +316 -0
- package/dist/components/editor/core/crdt-binding.d.ts +118 -0
- package/dist/components/editor/core/crdt-binding.js +286 -0
- package/dist/components/editor/core/diagnostics.d.ts +210 -0
- package/dist/components/editor/core/diagnostics.js +335 -0
- package/dist/components/editor/core/echo-cursor.d.ts +201 -0
- package/dist/components/editor/core/echo-cursor.js +267 -0
- package/dist/components/editor/core/folding.d.ts +124 -0
- package/dist/components/editor/core/folding.js +672 -0
- package/dist/components/editor/core/ghost-pair.d.ts +122 -0
- package/dist/components/editor/core/ghost-pair.js +221 -0
- package/dist/components/editor/core/git-blame.d.ts +170 -0
- package/dist/components/editor/core/git-blame.js +324 -0
- package/dist/components/editor/core/index.d.ts +26 -0
- package/dist/components/editor/core/index.js +24 -0
- package/dist/components/editor/core/keybindings.d.ts +79 -0
- package/dist/components/editor/core/keybindings.js +357 -0
- package/dist/components/editor/core/multi-cursor.d.ts +196 -0
- package/dist/components/editor/core/multi-cursor.js +521 -0
- package/dist/components/editor/core/navigation.d.ts +107 -0
- package/dist/components/editor/core/navigation.js +408 -0
- package/dist/components/editor/core/quick-actions.d.ts +189 -0
- package/dist/components/editor/core/quick-actions.js +427 -0
- package/dist/components/editor/core/search.d.ts +88 -0
- package/dist/components/editor/core/search.js +192 -0
- package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
- package/dist/components/editor/core/semantic-analyzer.js +424 -0
- package/dist/components/editor/core/snippet-manager.d.ts +202 -0
- package/dist/components/editor/core/snippet-manager.js +565 -0
- package/dist/components/editor/core/state.d.ts +367 -0
- package/dist/components/editor/core/state.js +900 -0
- package/dist/components/editor/core/timeline.d.ts +204 -0
- package/dist/components/editor/core/timeline.js +349 -0
- package/dist/components/editor/editor-find.d.ts +56 -0
- package/dist/components/editor/editor-find.js +148 -0
- package/dist/components/editor/editor-input.d.ts +77 -0
- package/dist/components/editor/editor-input.js +445 -0
- package/dist/components/editor/editor-multicursor.d.ts +21 -0
- package/dist/components/editor/editor-multicursor.js +196 -0
- package/dist/components/editor/editor-scroll.d.ts +14 -0
- package/dist/components/editor/editor-scroll.js +34 -0
- package/dist/components/editor/index.d.ts +15 -0
- package/dist/components/editor/index.js +21 -0
- package/dist/components/editor/languages.d.ts +62 -0
- package/dist/components/editor/languages.js +285 -0
- package/dist/components/editor/theme.d.ts +88 -0
- package/dist/components/editor/theme.js +139 -0
- package/dist/components/editor/tokenizer/base.d.ts +40 -0
- package/dist/components/editor/tokenizer/base.js +203 -0
- package/dist/components/editor/tokenizer/index.d.ts +56 -0
- package/dist/components/editor/tokenizer/index.js +215 -0
- package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/css.js +194 -0
- package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/go.js +220 -0
- package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
- package/dist/components/editor/tokenizer/languages/html.js +145 -0
- package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
- package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
- package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
- package/dist/components/editor/tokenizer/languages/json.js +91 -0
- package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
- package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
- package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
- package/dist/components/editor/tokenizer/languages/python.js +227 -0
- package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
- package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
- package/dist/components/editor/tokenizer/types.d.ts +86 -0
- package/dist/components/editor/tokenizer/types.js +4 -0
- package/dist/components/layout/IDELayout.svelte +274 -0
- package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
- package/dist/components/layout/StatusBar.svelte +511 -0
- package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +3 -0
- package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
- package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
- package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
- package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
- package/dist/components/lsp/HoverTooltip.svelte +274 -0
- package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
- package/dist/components/lsp/LSPEditor.svelte +486 -0
- package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
- package/dist/components/lsp/index.d.ts +6 -0
- package/dist/components/lsp/index.js +7 -0
- package/dist/components/plugins/PluginCard.svelte +153 -0
- package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
- package/dist/components/plugins/PluginPanel.svelte +280 -0
- package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
- package/dist/components/plugins/PluginProposalForm.svelte +250 -0
- package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
- package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
- package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
- package/dist/components/plugins/index.d.ts +4 -0
- package/dist/components/plugins/index.js +5 -0
- package/dist/components/vfs/LockConflictDialog.svelte +705 -0
- package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
- package/dist/components/vfs/LockIndicator.svelte +194 -0
- package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
- package/dist/components/vfs/LockOverlay.svelte +344 -0
- package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
- package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
- package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
- package/dist/components/vfs/index.d.ts +4 -0
- package/dist/components/vfs/index.js +5 -0
- package/dist/crdt/awareness.d.ts +42 -0
- package/dist/crdt/awareness.js +109 -0
- package/dist/crdt/document.d.ts +101 -0
- package/dist/crdt/document.js +187 -0
- package/dist/crdt/index.d.ts +9 -0
- package/dist/crdt/index.js +8 -0
- package/dist/crdt/provider.d.ts +85 -0
- package/dist/crdt/provider.js +150 -0
- package/dist/crdt/types.d.ts +61 -0
- package/dist/crdt/types.js +4 -0
- package/dist/crdt/undo.d.ts +34 -0
- package/dist/crdt/undo.js +70 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.js +280 -0
- package/dist/plugins/index.d.ts +103 -0
- package/dist/plugins/index.js +153 -0
- package/dist/services/error-handling.d.ts +95 -0
- package/dist/services/error-handling.js +413 -0
- package/dist/services/ide-integration.d.ts +83 -0
- package/dist/services/ide-integration.js +367 -0
- package/dist/services/lsp-client.d.ts +69 -0
- package/dist/services/lsp-client.js +667 -0
- package/dist/services/mock-ai.d.ts +37 -0
- package/dist/services/mock-ai.js +318 -0
- package/dist/services/optimistic.d.ts +141 -0
- package/dist/services/optimistic.js +367 -0
- package/dist/services/vfs-client.d.ts +81 -0
- package/dist/services/vfs-client.js +348 -0
- package/dist/stores/agents.svelte.d.ts +85 -0
- package/dist/stores/agents.svelte.js +459 -0
- package/dist/stores/ai-persistence.svelte.d.ts +76 -0
- package/dist/stores/ai-persistence.svelte.js +334 -0
- package/dist/stores/ai.svelte.d.ts +140 -0
- package/dist/stores/ai.svelte.js +383 -0
- package/dist/stores/collaboration.svelte.d.ts +164 -0
- package/dist/stores/collaboration.svelte.js +334 -0
- package/dist/stores/editor.svelte.d.ts +131 -0
- package/dist/stores/editor.svelte.js +250 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.js +29 -0
- package/dist/stores/layout.svelte.d.ts +171 -0
- package/dist/stores/layout.svelte.js +351 -0
- package/dist/stores/plugin.svelte.d.ts +121 -0
- package/dist/stores/plugin.svelte.js +410 -0
- package/dist/stores/vfs.svelte.d.ts +123 -0
- package/dist/stores/vfs.svelte.js +680 -0
- package/dist/styles/theme.css +623 -0
- package/dist/types/agents.d.ts +127 -0
- package/dist/types/agents.js +5 -0
- package/dist/types/ai.d.ts +137 -0
- package/dist/types/ai.js +4 -0
- package/dist/types/crdt.d.ts +222 -0
- package/dist/types/crdt.js +5 -0
- package/dist/types/editor.d.ts +52 -0
- package/dist/types/editor.js +18 -0
- package/dist/types/events.d.ts +133 -0
- package/dist/types/events.js +4 -0
- package/dist/types/filesystem.d.ts +77 -0
- package/dist/types/filesystem.js +4 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +12 -0
- package/dist/types/lsp.d.ts +691 -0
- package/dist/types/lsp.js +108 -0
- package/dist/types/plugin.d.ts +239 -0
- package/dist/types/plugin.js +5 -0
- package/dist/types/vfs.d.ts +191 -0
- package/dist/types/vfs.js +18 -0
- package/dist/utils/format.d.ts +55 -0
- package/dist/utils/format.js +152 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keybindings.d.ts +33 -0
- package/dist/utils/keybindings.js +171 -0
- package/dist/utils/language.d.ts +27 -0
- package/dist/utils/language.js +222 -0
- package/package.json +178 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VFS Client Service
|
|
3
|
+
* Handles all HTTP interactions with a virtual filesystem (VFS) backend
|
|
4
|
+
*/
|
|
5
|
+
import { VFSError } from '../types';
|
|
6
|
+
const DEFAULT_BASE_URL = '/api/vfs';
|
|
7
|
+
const DEFAULT_LOCK_TTL = 300000; // 5 minutes
|
|
8
|
+
const DEFAULT_MAX_RETRIES = 30;
|
|
9
|
+
const DEFAULT_RETRY_DELAY = 100; // 100ms
|
|
10
|
+
const DEFAULT_TIMEOUT = 30000; // 30 seconds
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Configuration
|
|
13
|
+
// ============================================================================
|
|
14
|
+
let config = {
|
|
15
|
+
baseUrl: DEFAULT_BASE_URL,
|
|
16
|
+
timeout: DEFAULT_TIMEOUT,
|
|
17
|
+
lockTTL: DEFAULT_LOCK_TTL,
|
|
18
|
+
maxReconnectAttempts: 10
|
|
19
|
+
};
|
|
20
|
+
export function configure(newConfig) {
|
|
21
|
+
config = { ...config, ...newConfig };
|
|
22
|
+
}
|
|
23
|
+
export function getConfig() {
|
|
24
|
+
return { ...config };
|
|
25
|
+
}
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Helper Functions
|
|
28
|
+
// ============================================================================
|
|
29
|
+
async function request(path, options = {}) {
|
|
30
|
+
const url = `${config.baseUrl}${path}`;
|
|
31
|
+
const timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(url, {
|
|
36
|
+
...options,
|
|
37
|
+
signal: controller.signal,
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
...options.headers
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
45
|
+
throw new VFSError(error.message || `HTTP ${response.status}`, mapStatusToErrorCode(response.status), error);
|
|
46
|
+
}
|
|
47
|
+
// Handle empty responses
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
if (!text) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return JSON.parse(text);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err instanceof VFSError)
|
|
56
|
+
throw err;
|
|
57
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
58
|
+
throw new VFSError('Request timeout', 'NETWORK_ERROR');
|
|
59
|
+
}
|
|
60
|
+
throw new VFSError(err instanceof Error ? err.message : 'Unknown error', 'NETWORK_ERROR', err);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function mapStatusToErrorCode(status) {
|
|
67
|
+
switch (status) {
|
|
68
|
+
case 404:
|
|
69
|
+
return 'FILE_NOT_FOUND';
|
|
70
|
+
case 403:
|
|
71
|
+
return 'PERMISSION_DENIED';
|
|
72
|
+
case 409:
|
|
73
|
+
return 'VERSION_CONFLICT';
|
|
74
|
+
case 423:
|
|
75
|
+
return 'FILE_LOCKED';
|
|
76
|
+
default:
|
|
77
|
+
return 'NETWORK_ERROR';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function sleep(ms) {
|
|
81
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
82
|
+
}
|
|
83
|
+
// ============================================================================
|
|
84
|
+
// Workspace Operations
|
|
85
|
+
// ============================================================================
|
|
86
|
+
export async function getWorkspace(workspaceId) {
|
|
87
|
+
return request(`/workspaces/${workspaceId}`);
|
|
88
|
+
}
|
|
89
|
+
export async function updateWorkspace(workspaceId, updates) {
|
|
90
|
+
return request(`/workspaces/${workspaceId}`, {
|
|
91
|
+
method: 'PATCH',
|
|
92
|
+
body: JSON.stringify(updates)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export async function listWorkspaces() {
|
|
96
|
+
return request('/workspaces');
|
|
97
|
+
}
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// File Operations
|
|
100
|
+
// ============================================================================
|
|
101
|
+
export async function readFile(workspaceId, path) {
|
|
102
|
+
return request(`/files?workspace=${workspaceId}&path=${encodeURIComponent(path)}`);
|
|
103
|
+
}
|
|
104
|
+
export async function writeFile(workspaceId, path, content, version) {
|
|
105
|
+
return request(`/files`, {
|
|
106
|
+
method: 'PUT',
|
|
107
|
+
body: JSON.stringify({ workspace: workspaceId, path, content, version })
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export async function deleteFile(workspaceId, path, version) {
|
|
111
|
+
return request(`/files`, {
|
|
112
|
+
method: 'DELETE',
|
|
113
|
+
body: JSON.stringify({ workspace: workspaceId, path, version })
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export async function renameFile(workspaceId, oldPath, newPath, version) {
|
|
117
|
+
return request(`/files/rename`, {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
body: JSON.stringify({ workspace: workspaceId, oldPath, newPath, version })
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export async function getFileInfo(workspaceId, path) {
|
|
123
|
+
return request(`/files/info?workspace=${workspaceId}&path=${encodeURIComponent(path)}`);
|
|
124
|
+
}
|
|
125
|
+
export async function copyFile(workspaceId, sourcePath, destPath) {
|
|
126
|
+
return request(`/files/copy`, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
body: JSON.stringify({ workspace: workspaceId, source: sourcePath, destination: destPath })
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Directory Operations
|
|
133
|
+
// ============================================================================
|
|
134
|
+
export async function readDirectory(workspaceId, path) {
|
|
135
|
+
return request(`/dirs?workspace=${workspaceId}&path=${encodeURIComponent(path)}`);
|
|
136
|
+
}
|
|
137
|
+
export async function createDirectory(workspaceId, path) {
|
|
138
|
+
return request(`/dirs`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
body: JSON.stringify({ workspace: workspaceId, path })
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
export async function deleteDirectory(workspaceId, path, recursive = false) {
|
|
144
|
+
return request(`/dirs`, {
|
|
145
|
+
method: 'DELETE',
|
|
146
|
+
body: JSON.stringify({ workspace: workspaceId, path, recursive })
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// Quick Operations (Auto-Transaction)
|
|
151
|
+
// ============================================================================
|
|
152
|
+
export async function quickWriteFile(workspaceId, path, content) {
|
|
153
|
+
return request(`/quick/files`, {
|
|
154
|
+
method: 'PUT',
|
|
155
|
+
body: JSON.stringify({ workspace: workspaceId, path, content })
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export async function quickDeleteFile(workspaceId, path) {
|
|
159
|
+
return request(`/quick/files`, {
|
|
160
|
+
method: 'DELETE',
|
|
161
|
+
body: JSON.stringify({ workspace: workspaceId, path })
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// Transaction Operations
|
|
166
|
+
// ============================================================================
|
|
167
|
+
export async function beginTransaction(workspaceId) {
|
|
168
|
+
const result = await request(`/tx/begin`, {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
body: JSON.stringify({ workspace: workspaceId })
|
|
171
|
+
});
|
|
172
|
+
return result.transactionId;
|
|
173
|
+
}
|
|
174
|
+
export async function commitTransaction(transactionId, operations) {
|
|
175
|
+
return request(`/tx/${transactionId}/commit`, {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
body: JSON.stringify({ operations })
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
export async function rollbackTransaction(transactionId) {
|
|
181
|
+
return request(`/tx/${transactionId}/rollback`, {
|
|
182
|
+
method: 'POST'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
export async function getTransaction(transactionId) {
|
|
186
|
+
return request(`/tx/${transactionId}`);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Execute multiple operations in a transaction
|
|
190
|
+
* Auto-commits on success, auto-rollbacks on failure
|
|
191
|
+
*/
|
|
192
|
+
export async function executeTransaction(workspaceId, operations) {
|
|
193
|
+
const txId = await beginTransaction(workspaceId);
|
|
194
|
+
try {
|
|
195
|
+
const result = await commitTransaction(txId, operations);
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
await rollbackTransaction(txId).catch(() => {
|
|
200
|
+
// Rollback failed, transaction will auto-expire
|
|
201
|
+
});
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// ============================================================================
|
|
206
|
+
// Lock Operations
|
|
207
|
+
// ============================================================================
|
|
208
|
+
export async function acquireLock(workspaceId, path, holder, options = {}) {
|
|
209
|
+
const { ttl = config.lockTTL ?? DEFAULT_LOCK_TTL, maxRetries = DEFAULT_MAX_RETRIES, retryDelay = DEFAULT_RETRY_DELAY, purpose } = options;
|
|
210
|
+
let lastError = null;
|
|
211
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
212
|
+
try {
|
|
213
|
+
const lock = await request(`/locks`, {
|
|
214
|
+
method: 'POST',
|
|
215
|
+
body: JSON.stringify({
|
|
216
|
+
workspace: workspaceId,
|
|
217
|
+
path,
|
|
218
|
+
holder,
|
|
219
|
+
ttl,
|
|
220
|
+
purpose
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
return lock;
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
if (err instanceof VFSError && err.code === 'FILE_LOCKED') {
|
|
227
|
+
lastError = err;
|
|
228
|
+
await sleep(retryDelay);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
// Other error, throw immediately
|
|
232
|
+
throw err;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
throw lastError || new VFSError('Failed to acquire lock after retries', 'FILE_LOCKED');
|
|
236
|
+
}
|
|
237
|
+
export async function releaseLock(workspaceId, path, holder) {
|
|
238
|
+
return request(`/locks`, {
|
|
239
|
+
method: 'DELETE',
|
|
240
|
+
body: JSON.stringify({ workspace: workspaceId, path, holder })
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
export async function refreshLock(workspaceId, path, holder) {
|
|
244
|
+
return request(`/locks/refresh`, {
|
|
245
|
+
method: 'POST',
|
|
246
|
+
body: JSON.stringify({ workspace: workspaceId, path, holder })
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
export async function getLockInfo(workspaceId, path) {
|
|
250
|
+
try {
|
|
251
|
+
return await request(`/locks?workspace=${workspaceId}&path=${encodeURIComponent(path)}`);
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
if (err instanceof VFSError && err.code === 'FILE_NOT_FOUND') {
|
|
255
|
+
return null; // No lock exists
|
|
256
|
+
}
|
|
257
|
+
throw err;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export async function listLocks(workspaceId) {
|
|
261
|
+
return request(`/locks?workspace=${workspaceId}`);
|
|
262
|
+
}
|
|
263
|
+
export async function forceReleaseLock(workspaceId, path, adminId) {
|
|
264
|
+
return request(`/locks/force`, {
|
|
265
|
+
method: 'DELETE',
|
|
266
|
+
body: JSON.stringify({ workspace: workspaceId, path, admin: adminId })
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// ============================================================================
|
|
270
|
+
// Convenience Functions
|
|
271
|
+
// ============================================================================
|
|
272
|
+
/**
|
|
273
|
+
* Execute a function with a file lock
|
|
274
|
+
* Automatically acquires, executes, and releases
|
|
275
|
+
*/
|
|
276
|
+
export async function withLock(workspaceId, path, holder, fn, options) {
|
|
277
|
+
const lock = await acquireLock(workspaceId, path, holder, options);
|
|
278
|
+
try {
|
|
279
|
+
return await fn();
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
await releaseLock(workspaceId, path, holder).catch(() => {
|
|
283
|
+
// Lock release failed, will auto-expire
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Batch file operations with automatic locking and transaction
|
|
289
|
+
*/
|
|
290
|
+
export async function batchUpdate(workspaceId, holder, updates) {
|
|
291
|
+
// Acquire all locks first
|
|
292
|
+
const locks = [];
|
|
293
|
+
try {
|
|
294
|
+
for (const update of updates) {
|
|
295
|
+
const lock = await acquireLock(workspaceId, update.path, holder);
|
|
296
|
+
locks.push(lock);
|
|
297
|
+
}
|
|
298
|
+
// Execute transaction
|
|
299
|
+
const operations = updates.map((u) => ({
|
|
300
|
+
type: 'update',
|
|
301
|
+
path: u.path,
|
|
302
|
+
content: u.content,
|
|
303
|
+
version: u.version ?? 0
|
|
304
|
+
}));
|
|
305
|
+
return await executeTransaction(workspaceId, operations);
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
// Release all locks
|
|
309
|
+
for (const lock of locks) {
|
|
310
|
+
await releaseLock(workspaceId, lock.path, holder).catch(() => { });
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Read file with automatic version tracking
|
|
316
|
+
*/
|
|
317
|
+
export async function readFileWithVersion(workspaceId, path) {
|
|
318
|
+
const file = await readFile(workspaceId, path);
|
|
319
|
+
return {
|
|
320
|
+
content: typeof file.content === 'string' ? file.content : '',
|
|
321
|
+
version: file.info.version
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Write file with version conflict detection
|
|
326
|
+
*/
|
|
327
|
+
export async function safeWriteFile(workspaceId, path, content, expectedVersion) {
|
|
328
|
+
return writeFile(workspaceId, path, content, expectedVersion);
|
|
329
|
+
}
|
|
330
|
+
export async function searchFiles(workspaceId, options) {
|
|
331
|
+
return request(`/search`, {
|
|
332
|
+
method: 'POST',
|
|
333
|
+
body: JSON.stringify({ workspace: workspaceId, ...options })
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
// ============================================================================
|
|
337
|
+
// Health Check
|
|
338
|
+
// ============================================================================
|
|
339
|
+
export async function healthCheck() {
|
|
340
|
+
const start = Date.now();
|
|
341
|
+
try {
|
|
342
|
+
await request('/health');
|
|
343
|
+
return { status: 'ok', latency: Date.now() - start };
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return { status: 'error', latency: Date.now() - start };
|
|
347
|
+
}
|
|
348
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents store using Svelte 5 runes
|
|
3
|
+
* Manages multi-agent coordination and activity tracking
|
|
4
|
+
*
|
|
5
|
+
* Note: Svelte 5 modules cannot directly export $derived values.
|
|
6
|
+
* We use getter functions to expose reactive derived state.
|
|
7
|
+
*/
|
|
8
|
+
import type { Agent, AgentStatus, AgentTask, AgentProgress, TeamEvent, AgentActivity, AgentCursor, AgentFilter, AgentType, VFSEvent } from '../types';
|
|
9
|
+
export declare function getAgents(): Agent[];
|
|
10
|
+
export declare function getAgent(agentId: string): Agent | undefined;
|
|
11
|
+
export declare function getOnlineAgents(): Agent[];
|
|
12
|
+
export declare function getOfflineAgents(): Agent[];
|
|
13
|
+
export declare function getBusyAgents(): Agent[];
|
|
14
|
+
export declare function getStalledAgents(): Agent[];
|
|
15
|
+
export declare function getAgentsByType(type: AgentType): Agent[];
|
|
16
|
+
export declare function getAgentsWorkingOnFile(filePath: string): Agent[];
|
|
17
|
+
export declare function getEvents(): TeamEvent[];
|
|
18
|
+
export declare function getActivities(): AgentActivity[];
|
|
19
|
+
export declare function getActivitiesForAgent(agentId: string): AgentActivity[];
|
|
20
|
+
export declare function getRecentActivities(count: number): AgentActivity[];
|
|
21
|
+
export declare function getCursors(): AgentCursor[];
|
|
22
|
+
export declare function getCursor(agentId: string): AgentCursor | undefined;
|
|
23
|
+
export declare function getCursorsForFile(filePath: string): AgentCursor[];
|
|
24
|
+
export declare function getSelectedAgent(): Agent | undefined;
|
|
25
|
+
export declare function getFilter(): AgentFilter;
|
|
26
|
+
export declare function getConnected(): boolean;
|
|
27
|
+
export declare function getError(): string | null;
|
|
28
|
+
export declare function getFilteredAgents(): Agent[];
|
|
29
|
+
export declare function getActiveTasksCount(): number;
|
|
30
|
+
export declare function getTotalProgress(): number;
|
|
31
|
+
export declare function getAgentCount(): number;
|
|
32
|
+
export declare function getOnlineCount(): number;
|
|
33
|
+
export declare const agents: {
|
|
34
|
+
readonly current: Agent[];
|
|
35
|
+
};
|
|
36
|
+
export declare const onlineAgents: {
|
|
37
|
+
readonly current: Agent[];
|
|
38
|
+
};
|
|
39
|
+
export declare const busyAgents: {
|
|
40
|
+
readonly current: Agent[];
|
|
41
|
+
};
|
|
42
|
+
export declare const events: {
|
|
43
|
+
readonly current: TeamEvent[];
|
|
44
|
+
};
|
|
45
|
+
export declare const activities: {
|
|
46
|
+
readonly current: AgentActivity[];
|
|
47
|
+
};
|
|
48
|
+
export declare const cursors: {
|
|
49
|
+
readonly current: AgentCursor[];
|
|
50
|
+
};
|
|
51
|
+
export declare const selectedAgent: {
|
|
52
|
+
readonly current: Agent | undefined;
|
|
53
|
+
};
|
|
54
|
+
export declare const filter: {
|
|
55
|
+
readonly current: AgentFilter;
|
|
56
|
+
};
|
|
57
|
+
export declare const connected: {
|
|
58
|
+
readonly current: boolean;
|
|
59
|
+
};
|
|
60
|
+
export declare const error: {
|
|
61
|
+
readonly current: string | null;
|
|
62
|
+
};
|
|
63
|
+
export declare function addAgent(agent: Agent): void;
|
|
64
|
+
export declare function removeAgent(agentId: string): void;
|
|
65
|
+
export declare function updateAgent(agentId: string, updates: Partial<Agent>): void;
|
|
66
|
+
export declare function setAgentStatus(agentId: string, status: AgentStatus): void;
|
|
67
|
+
export declare function setAgentTask(agentId: string, task: AgentTask | undefined): void;
|
|
68
|
+
export declare function updateAgentProgress(agentId: string, progress: Partial<AgentProgress>): void;
|
|
69
|
+
export declare function completeAgentTask(agentId: string, result: 'success' | 'failure' | 'partial', summary: string): void;
|
|
70
|
+
export declare function updateCursor(cursor: AgentCursor): void;
|
|
71
|
+
export declare function removeCursor(agentId: string): void;
|
|
72
|
+
export declare function clearCursorsForFile(filePath: string): void;
|
|
73
|
+
export declare function addEvent(event: TeamEvent): void;
|
|
74
|
+
export declare function onTeamEvent(type: TeamEvent['type'] | '*', handler: (event: TeamEvent) => void): () => void;
|
|
75
|
+
export declare function addActivity(activity: AgentActivity): void;
|
|
76
|
+
export declare function selectAgent(agentId: string | null): void;
|
|
77
|
+
export declare function setFilter(filter: AgentFilter): void;
|
|
78
|
+
export declare function clearActivities(): void;
|
|
79
|
+
export declare function clearEvents(): void;
|
|
80
|
+
export declare function handleVFSEvent(event: VFSEvent): void;
|
|
81
|
+
export declare function setConnected(connected: boolean): void;
|
|
82
|
+
export declare function setError(error: string | null): void;
|
|
83
|
+
export declare function clearError(): void;
|
|
84
|
+
export declare function reset(): void;
|
|
85
|
+
export declare function addMockAgents(): void;
|