cowork-dash 0.1.2__py3-none-any.whl
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.
- cowork_dash/__init__.py +35 -0
- cowork_dash/__main__.py +9 -0
- cowork_dash/agent.py +117 -0
- cowork_dash/app.py +1776 -0
- cowork_dash/assets/app.js +237 -0
- cowork_dash/assets/favicon.svg +1 -0
- cowork_dash/assets/styles.css +915 -0
- cowork_dash/canvas.py +318 -0
- cowork_dash/cli.py +273 -0
- cowork_dash/components.py +568 -0
- cowork_dash/config.py +91 -0
- cowork_dash/file_utils.py +226 -0
- cowork_dash/layout.py +250 -0
- cowork_dash/tools.py +699 -0
- cowork_dash-0.1.2.dist-info/METADATA +238 -0
- cowork_dash-0.1.2.dist-info/RECORD +19 -0
- cowork_dash-0.1.2.dist-info/WHEEL +4 -0
- cowork_dash-0.1.2.dist-info/entry_points.txt +2 -0
- cowork_dash-0.1.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Theme handling - sync mermaid with DMC color scheme
|
|
2
|
+
(function initTheme() {
|
|
3
|
+
function updateMermaidTheme(theme) {
|
|
4
|
+
if (typeof mermaid !== 'undefined') {
|
|
5
|
+
mermaid.initialize({
|
|
6
|
+
startOnLoad: false,
|
|
7
|
+
theme: theme === 'dark' ? 'dark' : 'default',
|
|
8
|
+
securityLevel: 'loose',
|
|
9
|
+
logLevel: 'error'
|
|
10
|
+
});
|
|
11
|
+
// Re-render any existing mermaid diagrams
|
|
12
|
+
renderMermaid();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Watch for DMC color scheme changes via MutationObserver
|
|
17
|
+
function watchColorScheme() {
|
|
18
|
+
const observer = new MutationObserver(function(mutations) {
|
|
19
|
+
mutations.forEach(function(mutation) {
|
|
20
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'data-mantine-color-scheme') {
|
|
21
|
+
const scheme = document.documentElement.getAttribute('data-mantine-color-scheme');
|
|
22
|
+
updateMermaidTheme(scheme);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
observer.observe(document.documentElement, {
|
|
28
|
+
attributes: true,
|
|
29
|
+
attributeFilter: ['data-mantine-color-scheme']
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Initial theme check
|
|
33
|
+
const initialScheme = document.documentElement.getAttribute('data-mantine-color-scheme');
|
|
34
|
+
if (initialScheme) {
|
|
35
|
+
updateMermaidTheme(initialScheme);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (document.readyState === 'loading') {
|
|
40
|
+
document.addEventListener('DOMContentLoaded', watchColorScheme);
|
|
41
|
+
} else {
|
|
42
|
+
watchColorScheme();
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
45
|
+
|
|
46
|
+
// Initialize Mermaid
|
|
47
|
+
mermaid.initialize({
|
|
48
|
+
startOnLoad: false,
|
|
49
|
+
theme: 'default',
|
|
50
|
+
securityLevel: 'loose',
|
|
51
|
+
logLevel: 'error'
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Render mermaid diagrams
|
|
55
|
+
async function renderMermaid() {
|
|
56
|
+
const mermaidDivs = document.querySelectorAll('.mermaid-diagram');
|
|
57
|
+
|
|
58
|
+
for (const div of mermaidDivs) {
|
|
59
|
+
if (!div.getAttribute('data-processed')) {
|
|
60
|
+
const code = div.textContent.trim();
|
|
61
|
+
div.setAttribute('data-processed', 'true');
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
// Clear the div and create unique ID
|
|
65
|
+
const id = 'mermaid-' + Math.random().toString(36).substr(2, 9);
|
|
66
|
+
div.innerHTML = '';
|
|
67
|
+
|
|
68
|
+
// Render mermaid
|
|
69
|
+
const { svg } = await mermaid.render(id, code);
|
|
70
|
+
div.innerHTML = svg;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('Mermaid rendering error:', error);
|
|
73
|
+
div.innerHTML = '<div style="color: #d93025; padding: 20px; text-align: left;">' +
|
|
74
|
+
'<strong>Mermaid Syntax Error:</strong><br>' +
|
|
75
|
+
'<code style="font-size: 12px;">' + error.message + '</code><br><br>' +
|
|
76
|
+
'<details><summary style="cursor: pointer;">View Code</summary>' +
|
|
77
|
+
'<pre style="background: #f5f5f5; padding: 10px; margin-top: 10px; overflow: auto;">' +
|
|
78
|
+
code + '</pre></details></div>';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Run mermaid on load and when content changes
|
|
85
|
+
window.addEventListener('load', renderMermaid);
|
|
86
|
+
|
|
87
|
+
// Use MutationObserver to detect when canvas content changes
|
|
88
|
+
// Check if observer already exists to prevent redeclaration errors
|
|
89
|
+
if (typeof window.mermaidObserver === 'undefined') {
|
|
90
|
+
window.mermaidObserver = new MutationObserver(function(mutations) {
|
|
91
|
+
renderMermaid();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Start observing once the canvas is available - retry until found
|
|
95
|
+
function attachMermaidObserver() {
|
|
96
|
+
const canvasContent = document.getElementById('canvas-content');
|
|
97
|
+
if (canvasContent) {
|
|
98
|
+
window.mermaidObserver.observe(canvasContent, { childList: true, subtree: true });
|
|
99
|
+
console.log('Mermaid observer attached to canvas-content');
|
|
100
|
+
// Run initial render in case content is already there
|
|
101
|
+
renderMermaid();
|
|
102
|
+
} else {
|
|
103
|
+
// Retry after a short delay
|
|
104
|
+
setTimeout(attachMermaidObserver, 500);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
attachMermaidObserver();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Auto-scroll chat messages to bottom
|
|
111
|
+
(function initChatAutoScroll() {
|
|
112
|
+
let chatMessages = null;
|
|
113
|
+
|
|
114
|
+
function scrollToBottom() {
|
|
115
|
+
if (chatMessages) {
|
|
116
|
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function setupAutoScroll() {
|
|
121
|
+
chatMessages = document.getElementById('chat-messages');
|
|
122
|
+
if (!chatMessages) {
|
|
123
|
+
setTimeout(setupAutoScroll, 500);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Watch for changes to chat messages
|
|
128
|
+
const observer = new MutationObserver(function(mutations) {
|
|
129
|
+
// Small delay to ensure DOM is updated
|
|
130
|
+
setTimeout(scrollToBottom, 50);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
observer.observe(chatMessages, {
|
|
134
|
+
childList: true,
|
|
135
|
+
subtree: true
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
console.log('Chat auto-scroll initialized');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (document.readyState === 'loading') {
|
|
142
|
+
document.addEventListener('DOMContentLoaded', setupAutoScroll);
|
|
143
|
+
} else {
|
|
144
|
+
setupAutoScroll();
|
|
145
|
+
}
|
|
146
|
+
})();
|
|
147
|
+
|
|
148
|
+
// Resizable split pane - improved reliability
|
|
149
|
+
(function initResizablePanes() {
|
|
150
|
+
let isResizing = false;
|
|
151
|
+
let container, chatPanel, resizeHandle, sidebar;
|
|
152
|
+
|
|
153
|
+
function findElements() {
|
|
154
|
+
container = document.getElementById('main-container');
|
|
155
|
+
chatPanel = document.getElementById('chat-panel');
|
|
156
|
+
resizeHandle = document.getElementById('resize-handle');
|
|
157
|
+
sidebar = document.getElementById('sidebar-panel');
|
|
158
|
+
|
|
159
|
+
return !!(resizeHandle && chatPanel && sidebar && container);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function handleMouseDown(e) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
isResizing = true;
|
|
166
|
+
document.body.style.cursor = 'col-resize';
|
|
167
|
+
document.body.style.userSelect = 'none';
|
|
168
|
+
|
|
169
|
+
// Add a semi-transparent overlay to prevent interference
|
|
170
|
+
const overlay = document.createElement('div');
|
|
171
|
+
overlay.id = 'resize-overlay';
|
|
172
|
+
overlay.style.cssText = 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999; cursor: col-resize;';
|
|
173
|
+
document.body.appendChild(overlay);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function handleMouseMove(e) {
|
|
177
|
+
if (!isResizing) return;
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
|
|
180
|
+
const containerRect = container.getBoundingClientRect();
|
|
181
|
+
const containerWidth = containerRect.width;
|
|
182
|
+
const offsetX = e.clientX - containerRect.left;
|
|
183
|
+
const chatWidth = (offsetX / containerWidth) * 100;
|
|
184
|
+
|
|
185
|
+
// Constrain between 30% and 70%
|
|
186
|
+
if (chatWidth >= 30 && chatWidth <= 70) {
|
|
187
|
+
chatPanel.style.flex = `0 0 ${chatWidth}%`;
|
|
188
|
+
sidebar.style.flex = `0 0 ${100 - chatWidth}%`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function handleMouseUp() {
|
|
193
|
+
if (isResizing) {
|
|
194
|
+
isResizing = false;
|
|
195
|
+
document.body.style.cursor = '';
|
|
196
|
+
document.body.style.userSelect = '';
|
|
197
|
+
|
|
198
|
+
// Remove the overlay
|
|
199
|
+
const overlay = document.getElementById('resize-overlay');
|
|
200
|
+
if (overlay) {
|
|
201
|
+
overlay.remove();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function setupResizing() {
|
|
207
|
+
if (!findElements()) {
|
|
208
|
+
console.log('Resize elements not found, retrying...');
|
|
209
|
+
setTimeout(setupResizing, 500);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Remove any existing listeners to prevent duplicates
|
|
214
|
+
resizeHandle.removeEventListener('mousedown', handleMouseDown);
|
|
215
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
216
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
217
|
+
|
|
218
|
+
// Add event listeners
|
|
219
|
+
resizeHandle.addEventListener('mousedown', handleMouseDown);
|
|
220
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
221
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
222
|
+
|
|
223
|
+
console.log('Resize functionality initialized');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Initialize on load and after a short delay to ensure DOM is ready
|
|
227
|
+
if (document.readyState === 'loading') {
|
|
228
|
+
document.addEventListener('DOMContentLoaded', setupResizing);
|
|
229
|
+
} else {
|
|
230
|
+
setupResizing();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Also try after window load
|
|
234
|
+
window.addEventListener('load', function() {
|
|
235
|
+
setTimeout(setupResizing, 100);
|
|
236
|
+
});
|
|
237
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="1255" height="1255" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="2481" y="563" width="1255" height="1255"/></clipPath></defs><g clip-path="url(#clip0)" transform="translate(-2481 -563)"><path d="M2481 1190.5C2481 843.941 2761.94 563 3108.5 563 3455.06 563 3736 843.941 3736 1190.5 3736 1537.06 3455.06 1818 3108.5 1818 2761.94 1818 2481 1537.06 2481 1190.5Z" fill="#616161" fill-rule="evenodd"/><path d="M3047.5 863 3047.5 863C3096.43 1037.37 3217.21 1182.01 3379 1260L3379 1260C3217.21 1337.99 3096.43 1482.62 3047.5 1657L3047.5 1657C2998.54 1482.64 2877.78 1338.01 2716 1260L2716 1260C2877.78 1181.99 2998.54 1037.36 3047.5 863Z" fill="#FFFFFF" fill-rule="evenodd"/><path d="M3353 743 3353 743C3374.85 824.038 3428.77 891.257 3501 927.5L3501 927.5C3428.77 963.743 3374.85 1030.96 3353 1112L3353 1112C3331.14 1030.97 3277.23 963.752 3205 927.5L3205 927.5C3277.23 891.248 3331.14 824.032 3353 743Z" fill="#FFFFFF" fill-rule="evenodd"/></g></svg>
|