cowork-dash 0.1.8__py3-none-any.whl → 0.2.0__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/agent.py +32 -11
- cowork_dash/app.py +888 -81
- cowork_dash/assets/app.js +34 -0
- cowork_dash/assets/styles.css +788 -697
- cowork_dash/canvas.py +8 -0
- cowork_dash/cli.py +9 -0
- cowork_dash/components.py +398 -55
- cowork_dash/config.py +12 -1
- cowork_dash/file_utils.py +65 -9
- cowork_dash/layout.py +2 -2
- cowork_dash/sandbox.py +361 -0
- cowork_dash/tools.py +734 -79
- {cowork_dash-0.1.8.dist-info → cowork_dash-0.2.0.dist-info}/METADATA +1 -1
- cowork_dash-0.2.0.dist-info/RECORD +23 -0
- cowork_dash-0.1.8.dist-info/RECORD +0 -22
- {cowork_dash-0.1.8.dist-info → cowork_dash-0.2.0.dist-info}/WHEEL +0 -0
- {cowork_dash-0.1.8.dist-info → cowork_dash-0.2.0.dist-info}/entry_points.txt +0 -0
- {cowork_dash-0.1.8.dist-info → cowork_dash-0.2.0.dist-info}/licenses/LICENSE +0 -0
cowork_dash/agent.py
CHANGED
|
@@ -7,22 +7,24 @@ from langgraph.checkpoint.memory import InMemorySaver
|
|
|
7
7
|
from cowork_dash.tools import (
|
|
8
8
|
add_to_canvas,
|
|
9
9
|
bash,
|
|
10
|
-
clear_notebook_canvas_items,
|
|
11
10
|
create_cell,
|
|
12
11
|
delete_cell,
|
|
13
12
|
execute_all_cells,
|
|
14
13
|
execute_cell,
|
|
15
|
-
get_notebook_canvas_items,
|
|
16
14
|
get_script,
|
|
17
15
|
get_variables,
|
|
18
16
|
insert_cell,
|
|
19
17
|
modify_cell,
|
|
20
18
|
reset_notebook,
|
|
19
|
+
display_inline,
|
|
20
|
+
think_tool
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
SYSTEM_PROMPT = """You are a helpful AI assistant with access to a filesystem workspace and a Python code execution environment.
|
|
24
24
|
You have access to a canvas, which is a markdown file located at `.canvas/canvas.md` in the workspace. This allows you to sketch out ideas, document your work, and present results to the user.
|
|
25
25
|
|
|
26
|
+
ALWAYS use think_tool to reason through user requests, irrespective of complexity. Use it regularly. Human sees your thought process.
|
|
27
|
+
|
|
26
28
|
## Capabilities
|
|
27
29
|
|
|
28
30
|
### Filesystem
|
|
@@ -57,15 +59,27 @@ You have tools to write and execute Python code interactively, similar to a Jupy
|
|
|
57
59
|
- Captures stdout, stderr, and return values
|
|
58
60
|
- Shows detailed error tracebacks when code fails
|
|
59
61
|
|
|
62
|
+
### Displaying Results Inline
|
|
63
|
+
- `display_inline(content, title=None, display_type=None)` - Display content inline in the chat
|
|
64
|
+
- Use for: **file paths** to images, DataFrames, CSV files, HTML, JSON, PDF
|
|
65
|
+
- **For matplotlib figures**: Save to file first, then display the file path:
|
|
66
|
+
1. In a cell: `fig.savefig('chart.png', bbox_inches='tight')`
|
|
67
|
+
2. Then call: `display_inline("chart.png", title="My Chart")`
|
|
68
|
+
- Example: `display_inline("results.csv", title="Sales Data")`
|
|
69
|
+
|
|
60
70
|
### Canvas Visualization
|
|
61
|
-
- `add_to_canvas(content)` -
|
|
62
|
-
- Inside notebook cells, `add_to_canvas()`
|
|
63
|
-
- `
|
|
64
|
-
-
|
|
71
|
+
- `add_to_canvas(content)` - Add content to the canvas panel (persistent note-taking area)
|
|
72
|
+
- Inside notebook cells, `add_to_canvas()` handles matplotlib figures directly
|
|
73
|
+
- For matplotlib in cells: `add_to_canvas(fig)` works (auto-converts to image)
|
|
74
|
+
- Canvas items are saved to `.canvas/` directory
|
|
75
|
+
|
|
76
|
+
**When to use `display_inline` vs `add_to_canvas`:**
|
|
77
|
+
- `display_inline`: For showing **saved files** (images, CSV, JSON) inline in chat
|
|
78
|
+
- `add_to_canvas`: Inside notebook cells for **figure objects** (handles conversion)
|
|
65
79
|
|
|
66
80
|
**Important:** When creating charts in notebook cells:
|
|
67
|
-
1. Create the figure
|
|
68
|
-
2. The execution result will
|
|
81
|
+
1. Create the figure and call `add_to_canvas(fig)` in the same cell
|
|
82
|
+
2. The execution result will show `canvas_items` with what was added
|
|
69
83
|
3. Charts are automatically saved to the `.canvas/` directory
|
|
70
84
|
|
|
71
85
|
## Workflow Guidelines
|
|
@@ -87,10 +101,17 @@ Work iteratively like a human using Jupyter:
|
|
|
87
101
|
|
|
88
102
|
### General
|
|
89
103
|
1. ALWAYS use write_todos to track your progress and next steps
|
|
90
|
-
2. ALWAYS think_tool to reason through reqests, irrespective of complexity
|
|
104
|
+
2. ALWAYS use think_tool to reason through reqests, irrespective of complexity. Use it regularly. Human sees your thought process.
|
|
91
105
|
3. Be proactive in exploring the filesystem when relevant
|
|
92
106
|
4. Provide clear, helpful responses
|
|
93
107
|
|
|
108
|
+
CRITICAL WORKFLOW REQUIREMENT:
|
|
109
|
+
1. FIRST ACTION: Always call think_tool before any other tool or response
|
|
110
|
+
2. Use it to reason through the user's request
|
|
111
|
+
3. Then proceed with other tools/actions
|
|
112
|
+
|
|
113
|
+
This applies to EVERY user message, regardless of complexity.
|
|
114
|
+
|
|
94
115
|
The workspace is your sandbox - feel free to create files, organize content, and help users manage their projects."""
|
|
95
116
|
|
|
96
117
|
# Get workspace root from environment variable or default to current directory
|
|
@@ -110,8 +131,8 @@ AGENT_TOOLS = [
|
|
|
110
131
|
get_script,
|
|
111
132
|
get_variables,
|
|
112
133
|
reset_notebook,
|
|
113
|
-
|
|
114
|
-
|
|
134
|
+
display_inline,
|
|
135
|
+
think_tool
|
|
115
136
|
]
|
|
116
137
|
|
|
117
138
|
# Global agent for physical filesystem mode
|