cowork-dash 0.1.9__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 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)` - Display DataFrames, charts, images, or markdown for the user (use as a tool directly)
62
- - Inside notebook cells, `add_to_canvas()` is also available - call it in your code to add visualizations
63
- - `get_notebook_canvas_items()` - Retrieve canvas items generated by executed cells
64
- - `clear_notebook_canvas_items()` - Clear collected canvas items
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 in a cell and call `add_to_canvas(fig)` within the same cell
68
- 2. The execution result will include `canvas_items` showing what was added
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
- get_notebook_canvas_items,
114
- clear_notebook_canvas_items,
134
+ display_inline,
135
+ think_tool
115
136
  ]
116
137
 
117
138
  # Global agent for physical filesystem mode