@sudocode-ai/local-server 0.1.7 → 0.1.8
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 +6 -0
- package/dist/errors/agent-errors.d.ts +43 -0
- package/dist/errors/agent-errors.d.ts.map +1 -0
- package/dist/errors/agent-errors.js +69 -0
- package/dist/errors/agent-errors.js.map +1 -0
- package/dist/execution/adapters/claude-adapter.d.ts +63 -0
- package/dist/execution/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/claude-adapter.js +82 -0
- package/dist/execution/adapters/claude-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-adapter.d.ts +67 -0
- package/dist/execution/adapters/codex-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/codex-adapter.js +183 -0
- package/dist/execution/adapters/codex-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-config-builder.d.ts +30 -0
- package/dist/execution/adapters/codex-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/codex-config-builder.js +110 -0
- package/dist/execution/adapters/codex-config-builder.js.map +1 -0
- package/dist/execution/adapters/copilot-adapter.d.ts +94 -0
- package/dist/execution/adapters/copilot-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-adapter.js +163 -0
- package/dist/execution/adapters/copilot-adapter.js.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts +48 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.js +125 -0
- package/dist/execution/adapters/copilot-config-builder.js.map +1 -0
- package/dist/execution/adapters/cursor-adapter.d.ts +66 -0
- package/dist/execution/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-adapter.js +121 -0
- package/dist/execution/adapters/cursor-adapter.js.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts +29 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.js +49 -0
- package/dist/execution/adapters/cursor-config-builder.js.map +1 -0
- package/dist/execution/adapters/shared/config-presets.d.ts +102 -0
- package/dist/execution/adapters/shared/config-presets.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-presets.js +205 -0
- package/dist/execution/adapters/shared/config-presets.js.map +1 -0
- package/dist/execution/adapters/shared/config-utils.d.ts +95 -0
- package/dist/execution/adapters/shared/config-utils.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-utils.js +163 -0
- package/dist/execution/adapters/shared/config-utils.js.map +1 -0
- package/dist/execution/adapters/shared/index.d.ts +8 -0
- package/dist/execution/adapters/shared/index.d.ts.map +1 -0
- package/dist/execution/adapters/shared/index.js +8 -0
- package/dist/execution/adapters/shared/index.js.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts +153 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.js +652 -0
- package/dist/execution/executors/agent-executor-wrapper.js.map +1 -0
- package/dist/execution/executors/executor-factory.d.ts +95 -0
- package/dist/execution/executors/executor-factory.d.ts.map +1 -0
- package/dist/execution/executors/executor-factory.js +120 -0
- package/dist/execution/executors/executor-factory.js.map +1 -0
- package/dist/execution/output/ag-ui-adapter.d.ts +0 -2
- package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -1
- package/dist/execution/output/ag-ui-adapter.js +0 -2
- package/dist/execution/output/ag-ui-adapter.js.map +1 -1
- package/dist/execution/output/index.d.ts +0 -3
- package/dist/execution/output/index.d.ts.map +1 -1
- package/dist/execution/output/index.js +0 -2
- package/dist/execution/output/index.js.map +1 -1
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts +108 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts.map +1 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js +321 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js.map +1 -0
- package/dist/execution/process/builders/claude.d.ts +24 -57
- package/dist/execution/process/builders/claude.d.ts.map +1 -1
- package/dist/execution/process/builders/claude.js +153 -19
- package/dist/execution/process/builders/claude.js.map +1 -1
- package/dist/execution/transport/ipc-transport-manager.d.ts +74 -0
- package/dist/execution/transport/ipc-transport-manager.d.ts.map +1 -0
- package/dist/execution/transport/ipc-transport-manager.js +104 -0
- package/dist/execution/transport/ipc-transport-manager.js.map +1 -0
- package/dist/execution/transport/transport-manager.d.ts.map +1 -1
- package/dist/execution/transport/transport-manager.js +3 -0
- package/dist/execution/transport/transport-manager.js.map +1 -1
- package/dist/execution/worktree/conflict-detector.d.ts +85 -0
- package/dist/execution/worktree/conflict-detector.d.ts.map +1 -0
- package/dist/execution/worktree/conflict-detector.js +129 -0
- package/dist/execution/worktree/conflict-detector.js.map +1 -0
- package/dist/execution/worktree/git-cli.d.ts +9 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-cli.js +10 -0
- package/dist/execution/worktree/git-cli.js.map +1 -1
- package/dist/execution/worktree/git-sync-cli.d.ts +187 -0
- package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -0
- package/dist/execution/worktree/git-sync-cli.js +350 -0
- package/dist/execution/worktree/git-sync-cli.js.map +1 -0
- package/dist/execution/worktree/manager.d.ts +18 -0
- package/dist/execution/worktree/manager.d.ts.map +1 -1
- package/dist/execution/worktree/manager.js +9 -3
- package/dist/execution/worktree/manager.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +132 -211
- package/dist/index.js.map +1 -1
- package/dist/middleware/project-context.d.ts +37 -0
- package/dist/middleware/project-context.d.ts.map +1 -0
- package/dist/middleware/project-context.js +91 -0
- package/dist/middleware/project-context.js.map +1 -0
- package/dist/public/assets/index-Bb_W5bUr.css +1 -0
- package/dist/public/assets/index-CFKL113G.js +710 -0
- package/dist/public/assets/index-CFKL113G.js.map +1 -0
- package/dist/public/assets/{react-vendor-ByUx1V_q.js → react-vendor-DiL5hC7l.js} +2 -2
- package/dist/public/assets/{react-vendor-ByUx1V_q.js.map → react-vendor-DiL5hC7l.js.map} +1 -1
- package/dist/public/assets/ui-vendor-B4WMPEfa.js +54 -0
- package/dist/public/assets/ui-vendor-B4WMPEfa.js.map +1 -0
- package/dist/public/index.html +4 -4
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +62 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/config.d.ts +3 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +25 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/editors.d.ts +15 -0
- package/dist/routes/editors.d.ts.map +1 -0
- package/dist/routes/editors.js +98 -0
- package/dist/routes/editors.js.map +1 -0
- package/dist/routes/executions-stream.d.ts +8 -5
- package/dist/routes/executions-stream.d.ts.map +1 -1
- package/dist/routes/executions-stream.js +10 -6
- package/dist/routes/executions-stream.js.map +1 -1
- package/dist/routes/executions.d.ts +6 -10
- package/dist/routes/executions.d.ts.map +1 -1
- package/dist/routes/executions.js +506 -54
- package/dist/routes/executions.js.map +1 -1
- package/dist/routes/feedback.d.ts +3 -2
- package/dist/routes/feedback.d.ts.map +1 -1
- package/dist/routes/feedback.js +12 -10
- package/dist/routes/feedback.js.map +1 -1
- package/dist/routes/files.d.ts +18 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +89 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/issues.d.ts +3 -2
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +19 -18
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/projects.d.ts +11 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +447 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/relationships.d.ts +3 -2
- package/dist/routes/relationships.d.ts.map +1 -1
- package/dist/routes/relationships.js +12 -10
- package/dist/routes/relationships.js.map +1 -1
- package/dist/routes/repo-info.d.ts +3 -0
- package/dist/routes/repo-info.d.ts.map +1 -0
- package/dist/routes/repo-info.js +126 -0
- package/dist/routes/repo-info.js.map +1 -0
- package/dist/routes/specs.d.ts +3 -2
- package/dist/routes/specs.d.ts.map +1 -1
- package/dist/routes/specs.js +19 -18
- package/dist/routes/specs.js.map +1 -1
- package/dist/services/agent-registry.d.ts +140 -0
- package/dist/services/agent-registry.d.ts.map +1 -0
- package/dist/services/agent-registry.js +272 -0
- package/dist/services/agent-registry.js.map +1 -0
- package/dist/services/editor-service.d.ts +57 -0
- package/dist/services/editor-service.d.ts.map +1 -0
- package/dist/services/editor-service.js +204 -0
- package/dist/services/editor-service.js.map +1 -0
- package/dist/services/execution-changes-service.d.ts +92 -0
- package/dist/services/execution-changes-service.d.ts.map +1 -0
- package/dist/services/execution-changes-service.js +546 -0
- package/dist/services/execution-changes-service.js.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +1 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -1
- package/dist/services/execution-lifecycle.js +37 -7
- package/dist/services/execution-lifecycle.js.map +1 -1
- package/dist/services/execution-logs-store.d.ts +75 -0
- package/dist/services/execution-logs-store.d.ts.map +1 -1
- package/dist/services/execution-logs-store.js +142 -2
- package/dist/services/execution-logs-store.js.map +1 -1
- package/dist/services/execution-service.d.ts +50 -58
- package/dist/services/execution-service.d.ts.map +1 -1
- package/dist/services/execution-service.js +433 -469
- package/dist/services/execution-service.js.map +1 -1
- package/dist/services/execution-worker-pool.d.ts +116 -0
- package/dist/services/execution-worker-pool.d.ts.map +1 -0
- package/dist/services/execution-worker-pool.js +326 -0
- package/dist/services/execution-worker-pool.js.map +1 -0
- package/dist/services/executions.d.ts +3 -0
- package/dist/services/executions.d.ts.map +1 -1
- package/dist/services/executions.js +11 -17
- package/dist/services/executions.js.map +1 -1
- package/dist/services/export.d.ts +8 -2
- package/dist/services/export.d.ts.map +1 -1
- package/dist/services/export.js +29 -23
- package/dist/services/export.js.map +1 -1
- package/dist/services/file-search/git-ls-files-strategy.d.ts +72 -0
- package/dist/services/file-search/git-ls-files-strategy.d.ts.map +1 -0
- package/dist/services/file-search/git-ls-files-strategy.js +176 -0
- package/dist/services/file-search/git-ls-files-strategy.js.map +1 -0
- package/dist/services/file-search/index.d.ts +9 -0
- package/dist/services/file-search/index.d.ts.map +1 -0
- package/dist/services/file-search/index.js +10 -0
- package/dist/services/file-search/index.js.map +1 -0
- package/dist/services/file-search/registry.d.ts +97 -0
- package/dist/services/file-search/registry.d.ts.map +1 -0
- package/dist/services/file-search/registry.js +140 -0
- package/dist/services/file-search/registry.js.map +1 -0
- package/dist/services/file-search/strategy.d.ts +58 -0
- package/dist/services/file-search/strategy.d.ts.map +1 -0
- package/dist/services/file-search/strategy.js +8 -0
- package/dist/services/file-search/strategy.js.map +1 -0
- package/dist/services/project-context.d.ts +69 -0
- package/dist/services/project-context.d.ts.map +1 -0
- package/dist/services/project-context.js +113 -0
- package/dist/services/project-context.js.map +1 -0
- package/dist/services/project-manager.d.ts +95 -0
- package/dist/services/project-manager.d.ts.map +1 -0
- package/dist/services/project-manager.js +388 -0
- package/dist/services/project-manager.js.map +1 -0
- package/dist/services/project-registry.d.ts +98 -0
- package/dist/services/project-registry.d.ts.map +1 -0
- package/dist/services/project-registry.js +289 -0
- package/dist/services/project-registry.js.map +1 -0
- package/dist/services/prompt-resolver.d.ts +97 -0
- package/dist/services/prompt-resolver.d.ts.map +1 -0
- package/dist/services/prompt-resolver.js +377 -0
- package/dist/services/prompt-resolver.js.map +1 -0
- package/dist/services/repo-info.d.ts +12 -0
- package/dist/services/repo-info.d.ts.map +1 -1
- package/dist/services/repo-info.js +46 -0
- package/dist/services/repo-info.js.map +1 -1
- package/dist/services/watcher.d.ts +3 -4
- package/dist/services/watcher.d.ts.map +1 -1
- package/dist/services/watcher.js +18 -35
- package/dist/services/watcher.js.map +1 -1
- package/dist/services/websocket.d.ts +30 -16
- package/dist/services/websocket.d.ts.map +1 -1
- package/dist/services/websocket.js +102 -37
- package/dist/services/websocket.js.map +1 -1
- package/dist/services/worktree-sync-service.d.ts +228 -0
- package/dist/services/worktree-sync-service.d.ts.map +1 -0
- package/dist/services/worktree-sync-service.js +563 -0
- package/dist/services/worktree-sync-service.js.map +1 -0
- package/dist/types/editor.d.ts +49 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/editor.js +50 -0
- package/dist/types/editor.js.map +1 -0
- package/dist/types/project.d.ts +58 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/project.js +10 -0
- package/dist/types/project.js.map +1 -0
- package/dist/utils/executable-check.d.ts +36 -0
- package/dist/utils/executable-check.d.ts.map +1 -0
- package/dist/utils/executable-check.js +79 -0
- package/dist/utils/executable-check.js.map +1 -0
- package/dist/workers/execution-worker.d.ts +18 -0
- package/dist/workers/execution-worker.d.ts.map +1 -0
- package/dist/workers/execution-worker.js +340 -0
- package/dist/workers/execution-worker.js.map +1 -0
- package/dist/workers/worker-ipc.d.ts +84 -0
- package/dist/workers/worker-ipc.d.ts.map +1 -0
- package/dist/workers/worker-ipc.js +29 -0
- package/dist/workers/worker-ipc.js.map +1 -0
- package/package.json +6 -5
- package/dist/execution/output/ag-ui-integration.d.ts +0 -96
- package/dist/execution/output/ag-ui-integration.d.ts.map +0 -1
- package/dist/execution/output/ag-ui-integration.js +0 -96
- package/dist/execution/output/ag-ui-integration.js.map +0 -1
- package/dist/execution/output/claude-code-output-processor.d.ts +0 -321
- package/dist/execution/output/claude-code-output-processor.d.ts.map +0 -1
- package/dist/execution/output/claude-code-output-processor.js +0 -769
- package/dist/execution/output/claude-code-output-processor.js.map +0 -1
- package/dist/public/assets/index-B3SEMufD.js +0 -580
- package/dist/public/assets/index-B3SEMufD.js.map +0 -1
- package/dist/public/assets/index-D2YGL3gX.css +0 -1
- package/dist/public/assets/ui-vendor-CotR6bx9.js +0 -54
- package/dist/public/assets/ui-vendor-CotR6bx9.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File search strategy registry
|
|
3
|
+
*
|
|
4
|
+
* Manages registration and retrieval of file search strategies.
|
|
5
|
+
* Allows switching between different search implementations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Registry for file search strategies
|
|
9
|
+
*
|
|
10
|
+
* Manages multiple search strategy implementations and provides
|
|
11
|
+
* a way to select which one to use (globally or per-project).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Register a strategy
|
|
16
|
+
* fileSearchRegistry.register('git-ls-files', new GitLsFilesStrategy())
|
|
17
|
+
*
|
|
18
|
+
* // Set as default
|
|
19
|
+
* fileSearchRegistry.setDefault('git-ls-files')
|
|
20
|
+
*
|
|
21
|
+
* // Get strategy (uses default if not specified)
|
|
22
|
+
* const strategy = fileSearchRegistry.get()
|
|
23
|
+
* const results = await strategy.search(workspacePath, options)
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class FileSearchStrategyRegistry {
|
|
27
|
+
strategies = new Map();
|
|
28
|
+
defaultStrategy = null;
|
|
29
|
+
/**
|
|
30
|
+
* Register a new search strategy
|
|
31
|
+
*
|
|
32
|
+
* @param type - Unique identifier for this strategy
|
|
33
|
+
* @param strategy - Strategy implementation
|
|
34
|
+
* @throws Error if strategy with this type already registered
|
|
35
|
+
*/
|
|
36
|
+
register(type, strategy) {
|
|
37
|
+
if (this.strategies.has(type)) {
|
|
38
|
+
throw new Error(`File search strategy '${type}' is already registered. ` +
|
|
39
|
+
`Use a different type name or unregister first.`);
|
|
40
|
+
}
|
|
41
|
+
this.strategies.set(type, strategy);
|
|
42
|
+
// Set as default if it's the first strategy registered
|
|
43
|
+
if (this.defaultStrategy === null) {
|
|
44
|
+
this.defaultStrategy = type;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Unregister a search strategy
|
|
49
|
+
*
|
|
50
|
+
* @param type - Strategy type to remove
|
|
51
|
+
* @returns True if strategy was found and removed, false otherwise
|
|
52
|
+
*/
|
|
53
|
+
unregister(type) {
|
|
54
|
+
const removed = this.strategies.delete(type);
|
|
55
|
+
// Clear default if we removed the default strategy
|
|
56
|
+
if (removed && this.defaultStrategy === type) {
|
|
57
|
+
// Set new default to first available strategy, or null if none
|
|
58
|
+
const firstStrategy = this.strategies.keys().next().value;
|
|
59
|
+
this.defaultStrategy = firstStrategy ?? null;
|
|
60
|
+
}
|
|
61
|
+
return removed;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a specific strategy by type, or the default strategy
|
|
65
|
+
*
|
|
66
|
+
* @param type - Optional strategy type. If not provided, returns default.
|
|
67
|
+
* @returns The requested strategy
|
|
68
|
+
* @throws Error if no strategy found for the given type
|
|
69
|
+
* @throws Error if no default strategy set and type not provided
|
|
70
|
+
*/
|
|
71
|
+
get(type) {
|
|
72
|
+
const strategyType = type ?? this.defaultStrategy;
|
|
73
|
+
if (strategyType === null) {
|
|
74
|
+
throw new Error("No default file search strategy set. " +
|
|
75
|
+
"Register a strategy first or provide a specific type.");
|
|
76
|
+
}
|
|
77
|
+
const strategy = this.strategies.get(strategyType);
|
|
78
|
+
if (!strategy) {
|
|
79
|
+
const available = Array.from(this.strategies.keys()).join(", ");
|
|
80
|
+
throw new Error(`File search strategy '${strategyType}' not found. ` +
|
|
81
|
+
`Available strategies: ${available || "none"}`);
|
|
82
|
+
}
|
|
83
|
+
return strategy;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set the default strategy to use
|
|
87
|
+
*
|
|
88
|
+
* @param type - Strategy type to set as default
|
|
89
|
+
* @throws Error if strategy type not registered
|
|
90
|
+
*/
|
|
91
|
+
setDefault(type) {
|
|
92
|
+
if (!this.strategies.has(type)) {
|
|
93
|
+
const available = Array.from(this.strategies.keys()).join(", ");
|
|
94
|
+
throw new Error(`Cannot set default to unregistered strategy '${type}'. ` +
|
|
95
|
+
`Available strategies: ${available || "none"}`);
|
|
96
|
+
}
|
|
97
|
+
this.defaultStrategy = type;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the current default strategy type
|
|
101
|
+
*
|
|
102
|
+
* @returns Default strategy type, or null if no default set
|
|
103
|
+
*/
|
|
104
|
+
getDefaultType() {
|
|
105
|
+
return this.defaultStrategy;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if a strategy is registered
|
|
109
|
+
*
|
|
110
|
+
* @param type - Strategy type to check
|
|
111
|
+
* @returns True if registered, false otherwise
|
|
112
|
+
*/
|
|
113
|
+
has(type) {
|
|
114
|
+
return this.strategies.has(type);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get all registered strategy types
|
|
118
|
+
*
|
|
119
|
+
* @returns Array of registered strategy type names
|
|
120
|
+
*/
|
|
121
|
+
listTypes() {
|
|
122
|
+
return Array.from(this.strategies.keys());
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Clear all registered strategies and reset default
|
|
126
|
+
*
|
|
127
|
+
* Useful for testing or complete reconfiguration
|
|
128
|
+
*/
|
|
129
|
+
clear() {
|
|
130
|
+
this.strategies.clear();
|
|
131
|
+
this.defaultStrategy = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Global file search strategy registry instance
|
|
136
|
+
*
|
|
137
|
+
* Use this singleton for application-wide strategy management.
|
|
138
|
+
*/
|
|
139
|
+
export const fileSearchRegistry = new FileSearchStrategyRegistry();
|
|
140
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/services/file-search/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,0BAA0B;IAC7B,UAAU,GAA0C,IAAI,GAAG,EAAE,CAAA;IAC7D,eAAe,GAAwB,IAAI,CAA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interface and types
|
|
3
|
+
*
|
|
4
|
+
* Provides a pluggable interface for different file search implementations.
|
|
5
|
+
* This allows swapping between git ls-files, fast-glob, indexed search, etc.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Options for file search
|
|
9
|
+
*/
|
|
10
|
+
export interface FileSearchOptions {
|
|
11
|
+
/** Search query string */
|
|
12
|
+
query: string;
|
|
13
|
+
/** Maximum number of results to return */
|
|
14
|
+
limit: number;
|
|
15
|
+
/** Whether to include directories in results */
|
|
16
|
+
includeDirectories: boolean;
|
|
17
|
+
/** Additional patterns to exclude from search (e.g., ['*.log', 'tmp/**']) */
|
|
18
|
+
excludePatterns?: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A single file search result
|
|
22
|
+
*/
|
|
23
|
+
export interface FileSearchResult {
|
|
24
|
+
/** Relative path from workspace root */
|
|
25
|
+
path: string;
|
|
26
|
+
/** Filename only (last segment of path) */
|
|
27
|
+
name: string;
|
|
28
|
+
/** True for files, false for directories */
|
|
29
|
+
isFile: boolean;
|
|
30
|
+
/** Type of match for ranking purposes */
|
|
31
|
+
matchType?: "exact" | "prefix" | "contains";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* File search strategy interface
|
|
35
|
+
*
|
|
36
|
+
* Implementations provide different ways to search for files in a workspace.
|
|
37
|
+
* Common strategies:
|
|
38
|
+
* - git-ls-files: Use git ls-files command (respects .gitignore)
|
|
39
|
+
* - fast-glob: Use fast-glob library for flexible patterns
|
|
40
|
+
* - indexed: Pre-index files for faster searching
|
|
41
|
+
*/
|
|
42
|
+
export interface FileSearchStrategy {
|
|
43
|
+
/**
|
|
44
|
+
* Search for files in the workspace
|
|
45
|
+
*
|
|
46
|
+
* @param workspacePath - Absolute path to workspace root
|
|
47
|
+
* @param options - Search options including query and filters
|
|
48
|
+
* @returns Array of matching file results, sorted by relevance
|
|
49
|
+
*/
|
|
50
|
+
search(workspacePath: string, options: FileSearchOptions): Promise<FileSearchResult[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Get the name of this strategy for debugging/logging
|
|
53
|
+
*
|
|
54
|
+
* @returns Strategy name (e.g., 'git-ls-files', 'fast-glob')
|
|
55
|
+
*/
|
|
56
|
+
getName(): string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/services/file-search/strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAA;IAEb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;IAEb,gDAAgD;IAChD,kBAAkB,EAAE,OAAO,CAAA;IAE3B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAA;IAEZ,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IAEZ,4CAA4C;IAC5C,MAAM,EAAE,OAAO,CAAA;IAEf,yCAAyC;IACzC,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;CAC5C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,MAAM,CACJ,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAE9B;;;;OAIG;IACH,OAAO,IAAI,MAAM,CAAA;CAClB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File search strategy interface and types
|
|
3
|
+
*
|
|
4
|
+
* Provides a pluggable interface for different file search implementations.
|
|
5
|
+
* This allows swapping between git ls-files, fast-glob, indexed search, etc.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/services/file-search/strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { TransportManager } from "../execution/transport/transport-manager.js";
|
|
3
|
+
import type { ExecutionService } from "./execution-service.js";
|
|
4
|
+
import type { ExecutionLogsStore } from "./execution-logs-store.js";
|
|
5
|
+
import type { ServerWatcherControl } from "./watcher.js";
|
|
6
|
+
import type { WorktreeManager } from "../execution/worktree/manager.js";
|
|
7
|
+
import type { ExecutionWorkerPool } from "./execution-worker-pool.js";
|
|
8
|
+
/**
|
|
9
|
+
* ProjectContext encapsulates all services and resources for a single open project.
|
|
10
|
+
*
|
|
11
|
+
* Each project maintains isolated:
|
|
12
|
+
* - Database connection
|
|
13
|
+
* - File watcher
|
|
14
|
+
* - Execution service
|
|
15
|
+
* - Transport manager (for SSE streaming)
|
|
16
|
+
* - Logs store
|
|
17
|
+
* - Worktree manager
|
|
18
|
+
*
|
|
19
|
+
* This ensures that operations on one project don't interfere with others.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ProjectContext {
|
|
22
|
+
/** Unique project identifier */
|
|
23
|
+
readonly id: string;
|
|
24
|
+
/** Absolute path to project root directory */
|
|
25
|
+
readonly path: string;
|
|
26
|
+
/** Absolute path to .sudocode directory */
|
|
27
|
+
readonly sudocodeDir: string;
|
|
28
|
+
/** SQLite database connection for this project */
|
|
29
|
+
readonly db: Database.Database;
|
|
30
|
+
/** Transport manager for SSE streaming */
|
|
31
|
+
readonly transportManager: TransportManager;
|
|
32
|
+
/** Execution service for managing issue executions */
|
|
33
|
+
readonly executionService: ExecutionService;
|
|
34
|
+
/** Logs store for execution output */
|
|
35
|
+
readonly logsStore: ExecutionLogsStore;
|
|
36
|
+
/** Worktree manager for execution isolation */
|
|
37
|
+
readonly worktreeManager: WorktreeManager;
|
|
38
|
+
/** Worker pool for isolated execution processes (optional) */
|
|
39
|
+
readonly workerPool: ExecutionWorkerPool | undefined;
|
|
40
|
+
/** File watcher for detecting changes */
|
|
41
|
+
watcher: ServerWatcherControl | null;
|
|
42
|
+
/** Timestamp when project was opened */
|
|
43
|
+
readonly openedAt: Date;
|
|
44
|
+
constructor(id: string, path: string, sudocodeDir: string, db: Database.Database, transportManager: TransportManager, executionService: ExecutionService, logsStore: ExecutionLogsStore, worktreeManager: WorktreeManager, workerPool?: ExecutionWorkerPool);
|
|
45
|
+
/**
|
|
46
|
+
* Initialize the project context (start file watcher, etc.)
|
|
47
|
+
*/
|
|
48
|
+
initialize(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Shutdown the project context and cleanup all resources
|
|
51
|
+
*/
|
|
52
|
+
shutdown(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Check if the project context is active (has active executions)
|
|
55
|
+
*/
|
|
56
|
+
hasActiveExecutions(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get summary information about this project context
|
|
59
|
+
*/
|
|
60
|
+
getSummary(): {
|
|
61
|
+
id: string;
|
|
62
|
+
path: string;
|
|
63
|
+
sudocodeDir: string;
|
|
64
|
+
openedAt: Date;
|
|
65
|
+
hasWatcher: boolean;
|
|
66
|
+
hasActiveExecutions: boolean;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=project-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context.d.ts","sourceRoot":"","sources":["../../src/services/project-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB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B;IAclC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAkC/B;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAS9B;;OAEG;IACH,UAAU;;;;;;;;CAUX"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProjectContext encapsulates all services and resources for a single open project.
|
|
3
|
+
*
|
|
4
|
+
* Each project maintains isolated:
|
|
5
|
+
* - Database connection
|
|
6
|
+
* - File watcher
|
|
7
|
+
* - Execution service
|
|
8
|
+
* - Transport manager (for SSE streaming)
|
|
9
|
+
* - Logs store
|
|
10
|
+
* - Worktree manager
|
|
11
|
+
*
|
|
12
|
+
* This ensures that operations on one project don't interfere with others.
|
|
13
|
+
*/
|
|
14
|
+
export class ProjectContext {
|
|
15
|
+
/** Unique project identifier */
|
|
16
|
+
id;
|
|
17
|
+
/** Absolute path to project root directory */
|
|
18
|
+
path;
|
|
19
|
+
/** Absolute path to .sudocode directory */
|
|
20
|
+
sudocodeDir;
|
|
21
|
+
/** SQLite database connection for this project */
|
|
22
|
+
db;
|
|
23
|
+
/** Transport manager for SSE streaming */
|
|
24
|
+
transportManager;
|
|
25
|
+
/** Execution service for managing issue executions */
|
|
26
|
+
executionService;
|
|
27
|
+
/** Logs store for execution output */
|
|
28
|
+
logsStore;
|
|
29
|
+
/** Worktree manager for execution isolation */
|
|
30
|
+
worktreeManager;
|
|
31
|
+
/** Worker pool for isolated execution processes (optional) */
|
|
32
|
+
workerPool;
|
|
33
|
+
/** File watcher for detecting changes */
|
|
34
|
+
watcher = null;
|
|
35
|
+
/** Timestamp when project was opened */
|
|
36
|
+
openedAt;
|
|
37
|
+
constructor(id, path, sudocodeDir, db, transportManager, executionService, logsStore, worktreeManager, workerPool) {
|
|
38
|
+
this.id = id;
|
|
39
|
+
this.path = path;
|
|
40
|
+
this.sudocodeDir = sudocodeDir;
|
|
41
|
+
this.db = db;
|
|
42
|
+
this.transportManager = transportManager;
|
|
43
|
+
this.executionService = executionService;
|
|
44
|
+
this.logsStore = logsStore;
|
|
45
|
+
this.worktreeManager = worktreeManager;
|
|
46
|
+
this.workerPool = workerPool;
|
|
47
|
+
this.openedAt = new Date();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the project context (start file watcher, etc.)
|
|
51
|
+
*/
|
|
52
|
+
async initialize() {
|
|
53
|
+
// File watcher will be started by the caller if needed
|
|
54
|
+
// (allows for SUDOCODE_WATCH=false configuration)
|
|
55
|
+
console.log(`Project context initialized: ${this.id} at ${this.path}`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Shutdown the project context and cleanup all resources
|
|
59
|
+
*/
|
|
60
|
+
async shutdown() {
|
|
61
|
+
console.log(`Shutting down project context: ${this.id}`);
|
|
62
|
+
try {
|
|
63
|
+
// 1. Shutdown worker pool (kill all workers)
|
|
64
|
+
if (this.workerPool) {
|
|
65
|
+
await this.workerPool.shutdown();
|
|
66
|
+
}
|
|
67
|
+
// 2. Cancel active executions (non-worker based)
|
|
68
|
+
if (this.executionService) {
|
|
69
|
+
await this.executionService.shutdown();
|
|
70
|
+
}
|
|
71
|
+
// 3. Stop file watcher
|
|
72
|
+
if (this.watcher) {
|
|
73
|
+
this.watcher.stop();
|
|
74
|
+
this.watcher = null;
|
|
75
|
+
}
|
|
76
|
+
// 4. Close transport streams
|
|
77
|
+
if (this.transportManager) {
|
|
78
|
+
this.transportManager.shutdown();
|
|
79
|
+
}
|
|
80
|
+
// 5. Database will be closed by ProjectManager (it manages the cache)
|
|
81
|
+
console.log(`Project context shutdown complete: ${this.id}`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error(`Error during project context shutdown: ${this.id}`, error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if the project context is active (has active executions)
|
|
90
|
+
*/
|
|
91
|
+
hasActiveExecutions() {
|
|
92
|
+
// Check worker pool if available, otherwise check execution service
|
|
93
|
+
if (this.workerPool) {
|
|
94
|
+
return this.workerPool.getActiveWorkerCount() > 0;
|
|
95
|
+
}
|
|
96
|
+
// For in-process execution, check the execution service
|
|
97
|
+
return this.executionService.hasActiveExecutions();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get summary information about this project context
|
|
101
|
+
*/
|
|
102
|
+
getSummary() {
|
|
103
|
+
return {
|
|
104
|
+
id: this.id,
|
|
105
|
+
path: this.path,
|
|
106
|
+
sudocodeDir: this.sudocodeDir,
|
|
107
|
+
openedAt: this.openedAt,
|
|
108
|
+
hasWatcher: this.watcher !== null,
|
|
109
|
+
hasActiveExecutions: this.hasActiveExecutions(),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=project-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context.js","sourceRoot":"","sources":["../../src/services/project-context.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IACzB,gCAAgC;IACvB,EAAE,CAAS;IAEpB,8CAA8C;IACrC,IAAI,CAAS;IAEtB,2CAA2C;IAClC,WAAW,CAAS;IAE7B,kDAAkD;IACzC,EAAE,CAAoB;IAE/B,0CAA0C;IACjC,gBAAgB,CAAmB;IAE5C,sDAAsD;IAC7C,gBAAgB,CAAmB;IAE5C,sCAAsC;IAC7B,SAAS,CAAqB;IAEvC,+CAA+C;IACtC,eAAe,CAAkB;IAE1C,8DAA8D;IACrD,UAAU,CAAkC;IAErD,yCAAyC;IACzC,OAAO,GAAgC,IAAI,CAAC;IAE5C,wCAAwC;IAC/B,QAAQ,CAAO;IAExB,YACE,EAAU,EACV,IAAY,EACZ,WAAmB,EACnB,EAAqB,EACrB,gBAAkC,EAClC,gBAAkC,EAClC,SAA6B,EAC7B,eAAg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gBAAgB,EAAE,CAAC;gBAC1B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YACnC,CAAC;YAED,sEAAsE;YAEtE,OAAO,CAAC,GAAG,CAAC,sCAAsC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,oEAAoE;QACpE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;QACpD,CAAC;QACD,wDAAwD;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,OAAO,KAAK,IAAI;YACjC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE;SAChD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ProjectRegistry } from "./project-registry.js";
|
|
2
|
+
import { ProjectContext } from "./project-context.js";
|
|
3
|
+
import type { ProjectError, Result } from "../types/project.js";
|
|
4
|
+
/**
|
|
5
|
+
* ProjectManager manages the lifecycle of multiple open projects.
|
|
6
|
+
*
|
|
7
|
+
* Responsibilities:
|
|
8
|
+
* - Open and close projects
|
|
9
|
+
* - Validate project directories
|
|
10
|
+
* - Cache database connections with TTL eviction
|
|
11
|
+
* - Track all open projects
|
|
12
|
+
* - Coordinate with ProjectRegistry for persistence
|
|
13
|
+
*
|
|
14
|
+
* Architecture:
|
|
15
|
+
* - Each open project gets a ProjectContext with isolated services
|
|
16
|
+
* - Database connections are cached for 30 minutes after project close
|
|
17
|
+
* - All services (file watcher, executions, etc.) are per-project
|
|
18
|
+
*/
|
|
19
|
+
export declare class ProjectManager {
|
|
20
|
+
private registry;
|
|
21
|
+
private openProjects;
|
|
22
|
+
private dbCache;
|
|
23
|
+
/** Database connection TTL: 30 minutes */
|
|
24
|
+
private readonly DB_CACHE_TTL;
|
|
25
|
+
/** Whether file watching is enabled */
|
|
26
|
+
private readonly watchEnabled;
|
|
27
|
+
constructor(registry: ProjectRegistry, options?: {
|
|
28
|
+
watchEnabled?: boolean;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Open a project and initialize all its services
|
|
32
|
+
* @param projectPath - Absolute path to project root directory
|
|
33
|
+
* @returns ProjectContext for the opened project
|
|
34
|
+
*/
|
|
35
|
+
openProject(projectPath: string): Promise<Result<ProjectContext, ProjectError>>;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize a new sudocode project in an existing directory
|
|
38
|
+
* @param projectPath - Absolute path to project root directory
|
|
39
|
+
* @param name - Optional custom project name
|
|
40
|
+
* @returns ProjectContext for the initialized and opened project
|
|
41
|
+
*/
|
|
42
|
+
initializeProject(projectPath: string, name?: string): Promise<Result<ProjectContext, ProjectError>>;
|
|
43
|
+
/**
|
|
44
|
+
* Close a project and cleanup its resources
|
|
45
|
+
* @param projectId - Project ID to close
|
|
46
|
+
* @param keepDbInCache - Whether to keep database in cache (default: true)
|
|
47
|
+
*/
|
|
48
|
+
closeProject(projectId: string, keepDbInCache?: boolean): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Get an open project by ID
|
|
51
|
+
*/
|
|
52
|
+
getProject(projectId: string): ProjectContext | null;
|
|
53
|
+
/**
|
|
54
|
+
* Get all currently open projects
|
|
55
|
+
*/
|
|
56
|
+
getAllOpenProjects(): ProjectContext[];
|
|
57
|
+
/**
|
|
58
|
+
* Check if a project is currently open
|
|
59
|
+
*/
|
|
60
|
+
isProjectOpen(projectId: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Validate that a project directory is valid for opening
|
|
63
|
+
*/
|
|
64
|
+
private validateProject;
|
|
65
|
+
/**
|
|
66
|
+
* Get or create a database connection for a project
|
|
67
|
+
* Checks cache first, then initializes new connection
|
|
68
|
+
*/
|
|
69
|
+
private getOrCreateDatabase;
|
|
70
|
+
/**
|
|
71
|
+
* Add a database to the cache with TTL eviction
|
|
72
|
+
*/
|
|
73
|
+
private addToDbCache;
|
|
74
|
+
/**
|
|
75
|
+
* Get summary of all projects (open and cached)
|
|
76
|
+
*/
|
|
77
|
+
getSummary(): {
|
|
78
|
+
openProjects: {
|
|
79
|
+
id: string;
|
|
80
|
+
path: string;
|
|
81
|
+
sudocodeDir: string;
|
|
82
|
+
openedAt: Date;
|
|
83
|
+
hasWatcher: boolean;
|
|
84
|
+
hasActiveExecutions: boolean;
|
|
85
|
+
}[];
|
|
86
|
+
cachedDatabases: string[];
|
|
87
|
+
totalOpen: number;
|
|
88
|
+
totalCached: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Shutdown the project manager and cleanup all resources
|
|
92
|
+
*/
|
|
93
|
+
shutdown(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=project-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-manager.d.ts","sourceRoot":"","sources":["../../src/services/project-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAStD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAgBhE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACz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