cowork-dash 0.1.9__py3-none-any.whl → 0.2.1__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,29 @@ 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
+ CRITICAL!:
27
+ - You must keep talking to the user as frequently as possible to communicate your thoughts, findings and next steps.
28
+ - Always explain what you are doing and why.
29
+ - Acknowledge user instructions and questions before taking actions.
30
+ - Explain what you are doing before executing any tool or code.
31
+ - After executing code or tools, always summarize the results and next steps to the user.
32
+
26
33
  ## Capabilities
27
34
 
28
35
  ### Filesystem
@@ -57,16 +64,19 @@ You have tools to write and execute Python code interactively, similar to a Jupy
57
64
  - Captures stdout, stderr, and return values
58
65
  - Shows detailed error tracebacks when code fails
59
66
 
67
+ ### Displaying Results Inline
68
+ - `display_inline(content, title=None, display_type=None)` - Tool to display content inline in the chat
69
+ - Use for: **file paths** to images, CSV files, HTML, JSON, PDF
70
+ - Example: `display_inline("results.csv", title="Sales Data")` as a tool call
71
+
60
72
  ### 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
73
+ - `add_to_canvas(content)` - Add content to the canvas panel (persistent note-taking area). To add images or charts, save them to files and reference them in markdown.
74
+ - Use for: longer-term notes, sketches, charts
75
+ - Canvas items are saved to `.canvas/` directory
65
76
 
66
- **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
69
- 3. Charts are automatically saved to the `.canvas/` directory
77
+ **When to use `display_inline` vs `add_to_canvas`:**
78
+ - `display_inline`: For showing **saved files** (images, CSV, JSON) inline in chat
79
+ - `add_to_canvas`: For longer-term notes, sketches, charts
70
80
 
71
81
  ## Workflow Guidelines
72
82
 
@@ -82,14 +92,20 @@ Work iteratively like a human using Jupyter:
82
92
  ### For Analysis Tasks
83
93
  1. Start by exploring the data (load, inspect shape/columns/types)
84
94
  2. Build up your analysis step by step in separate cells
85
- 3. Use `add_to_canvas()` to show important results to the user
86
- 4. Keep cells focused on single tasks for easier debugging
95
+ 3. Keep cells focused on single tasks for easier debugging
87
96
 
88
97
  ### General
89
98
  1. ALWAYS use write_todos to track your progress and next steps
90
- 2. ALWAYS think_tool to reason through reqests, irrespective of complexity
91
- 3. Be proactive in exploring the filesystem when relevant
92
- 4. Provide clear, helpful responses
99
+ 2. Be proactive in exploring the filesystem when relevant
100
+ 3. Provide clear, helpful responses
101
+
102
+ CRITICAL WORKFLOW REQUIREMENT:
103
+ 1. FIRST ACTION: Always respond with initial thoughts before beginning any work and before any other tool or response
104
+ 2. Reason through the user's request
105
+ 3. Then proceed with other tools/actions
106
+ 4. Summazrize progress and next steps after each action
107
+
108
+ This applies to EVERY user message, regardless of complexity.
93
109
 
94
110
  The workspace is your sandbox - feel free to create files, organize content, and help users manage their projects."""
95
111
 
@@ -110,8 +126,8 @@ AGENT_TOOLS = [
110
126
  get_script,
111
127
  get_variables,
112
128
  reset_notebook,
113
- get_notebook_canvas_items,
114
- clear_notebook_canvas_items,
129
+ display_inline,
130
+ think_tool
115
131
  ]
116
132
 
117
133
  # Global agent for physical filesystem mode