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.
@@ -0,0 +1,35 @@
1
+ """
2
+ Cowork Dash - AI Agent Web Interface
3
+
4
+ A modular Dash application providing a web interface for AI agent interactions
5
+ with filesystem workspace, canvas visualization, and real-time streaming.
6
+
7
+ Features:
8
+ - AI Agent Chat with real-time streaming
9
+ - File Browser with upload/download
10
+ - Canvas for visualizations (DataFrames, charts, diagrams)
11
+ - Real-time updates for thinking and task progress
12
+ - Support for Matplotlib, Plotly, Mermaid diagrams
13
+ - Resizable split-pane interface
14
+
15
+ Usage:
16
+ # Command-line
17
+ $ cowork-dash run --workspace ~/my-workspace
18
+
19
+ # Python API
20
+ from cowork_dash import run_app
21
+
22
+ # With agent instance
23
+ from my_agent import MyAgent
24
+ agent = MyAgent()
25
+ run_app(agent, workspace="~/my-workspace")
26
+ """
27
+
28
+ __version__ = "0.1.1"
29
+ __author__ = "Kedar Dabhadkar"
30
+ __license__ = "MIT"
31
+
32
+ # Export main API
33
+ from .app import run_app
34
+
35
+ __all__ = ["run_app", "__version__"]
@@ -0,0 +1,9 @@
1
+ """
2
+ Allow running as: python -m cowork_dash
3
+ """
4
+
5
+ from .cli import main
6
+ import sys
7
+
8
+ if __name__ == "__main__":
9
+ sys.exit(main())
cowork_dash/agent.py ADDED
@@ -0,0 +1,117 @@
1
+ import uuid
2
+ from deepagents import create_deep_agent
3
+ from langgraph.checkpoint.memory import InMemorySaver
4
+ from deepagents.backends import FilesystemBackend
5
+
6
+ from cowork_dash.tools import (
7
+ add_to_canvas,
8
+ create_cell,
9
+ insert_cell,
10
+ modify_cell,
11
+ delete_cell,
12
+ execute_cell,
13
+ execute_all_cells,
14
+ get_script,
15
+ get_variables,
16
+ reset_notebook,
17
+ get_notebook_canvas_items,
18
+ clear_notebook_canvas_items,
19
+ bash,
20
+ )
21
+
22
+ SYSTEM_PROMPT = """You are a helpful AI assistant with access to a filesystem workspace and a Python code execution environment.
23
+ 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.
24
+
25
+ ## Capabilities
26
+
27
+ ### Filesystem
28
+ You can browse, read, create, and modify files to help users with their tasks.
29
+
30
+ ### Bash Commands
31
+ - `bash(command, timeout=60)` - Execute shell commands in the workspace directory
32
+ - Use for: git operations, file management, installing packages, running scripts
33
+ - Returns stdout, stderr, and exit code
34
+
35
+ ### Python Code Execution (Jupyter-like)
36
+ You have tools to write and execute Python code interactively, similar to a Jupyter notebook:
37
+
38
+ **Creating and Managing Cells:**
39
+ - `create_cell(code, cell_type="code")` - Add a new cell to the end of the script
40
+ - `insert_cell(index, code, cell_type="code")` - Insert a cell at a specific position
41
+ - `modify_cell(cell_index, new_code)` - Fix or update code in an existing cell
42
+ - `delete_cell(cell_index)` - Remove a cell from the script
43
+
44
+ **Executing Code:**
45
+ - `execute_cell(cell_index)` - Run a single cell and see its output
46
+ - `execute_all_cells()` - Run all cells in order
47
+
48
+ **Reviewing State:**
49
+ - `get_script()` - See all cells and the complete script
50
+ - `get_variables()` - See what variables are currently defined
51
+ - `reset_notebook()` - Clear everything and start fresh
52
+
53
+ **Key Features:**
54
+ - Variables persist across cells - define `x` in cell 0, use it in cell 1
55
+ - Common imports (pandas, numpy, matplotlib, plotly) are pre-loaded
56
+ - Captures stdout, stderr, and return values
57
+ - Shows detailed error tracebacks when code fails
58
+
59
+ ### Canvas Visualization
60
+ - `add_to_canvas(content)` - Display DataFrames, charts, images, or markdown for the user (use as a tool directly)
61
+ - Inside notebook cells, `add_to_canvas()` is also available - call it in your code to add visualizations
62
+ - `get_notebook_canvas_items()` - Retrieve canvas items generated by executed cells
63
+ - `clear_notebook_canvas_items()` - Clear collected canvas items
64
+
65
+ **Important:** When creating charts in notebook cells:
66
+ 1. Create the figure in a cell and call `add_to_canvas(fig)` within the same cell
67
+ 2. The execution result will include `canvas_items` showing what was added
68
+ 3. Charts are automatically saved to the `.canvas/` directory
69
+
70
+ ## Workflow Guidelines
71
+
72
+ ### For Code Tasks
73
+ Work iteratively like a human using Jupyter:
74
+ 1. Create a cell with your initial code
75
+ 2. Execute it to see the result
76
+ 3. If there's an error, read the traceback carefully
77
+ 4. Modify the cell to fix the issue
78
+ 5. Re-execute and repeat until it works
79
+ 6. Move on to the next step
80
+
81
+ ### For Analysis Tasks
82
+ 1. Start by exploring the data (load, inspect shape/columns/types)
83
+ 2. Build up your analysis step by step in separate cells
84
+ 3. Use `add_to_canvas()` to show important results to the user
85
+ 4. Keep cells focused on single tasks for easier debugging
86
+
87
+ ### General
88
+ 1. Use write_todos to track your progress and next steps
89
+ 2. Use think_tool to reason through complex problems
90
+ 3. Be proactive in exploring the filesystem when relevant
91
+ 4. Provide clear, helpful responses
92
+
93
+ The workspace is your sandbox - feel free to create files, organize content, and help users manage their projects."""
94
+
95
+ backend = FilesystemBackend(root_dir=str("./"), virtual_mode=True)
96
+
97
+ agent = create_deep_agent(
98
+ system_prompt=SYSTEM_PROMPT,
99
+ backend=backend,
100
+ tools=[
101
+ add_to_canvas,
102
+ bash,
103
+ create_cell,
104
+ insert_cell,
105
+ modify_cell,
106
+ delete_cell,
107
+ execute_cell,
108
+ execute_all_cells,
109
+ get_script,
110
+ get_variables,
111
+ reset_notebook,
112
+ get_notebook_canvas_items,
113
+ clear_notebook_canvas_items,
114
+ ],
115
+ # interrupt_on=dict(bash=True),
116
+ checkpointer=InMemorySaver()
117
+ )