cowork-dash 0.1.2__py3-none-any.whl → 0.1.3__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/app.py +71 -25
- cowork_dash/config.py +8 -3
- cowork_dash/layout.py +2 -2
- {cowork_dash-0.1.2.dist-info → cowork_dash-0.1.3.dist-info}/METADATA +1 -1
- {cowork_dash-0.1.2.dist-info → cowork_dash-0.1.3.dist-info}/RECORD +8 -8
- {cowork_dash-0.1.2.dist-info → cowork_dash-0.1.3.dist-info}/WHEEL +0 -0
- {cowork_dash-0.1.2.dist-info → cowork_dash-0.1.3.dist-info}/entry_points.txt +0 -0
- {cowork_dash-0.1.2.dist-info → cowork_dash-0.1.3.dist-info}/licenses/LICENSE +0 -0
cowork_dash/app.py
CHANGED
|
@@ -122,43 +122,83 @@ Examples:
|
|
|
122
122
|
|
|
123
123
|
def load_agent_from_spec(agent_spec: str):
|
|
124
124
|
"""
|
|
125
|
-
Load agent from specification string
|
|
125
|
+
Load agent from specification string.
|
|
126
|
+
|
|
127
|
+
Supports two formats:
|
|
128
|
+
1. File path format: "path/to/file.py:object_name"
|
|
129
|
+
2. Module format: "mypackage.module.submodule.object_name"
|
|
126
130
|
|
|
127
131
|
Args:
|
|
128
|
-
agent_spec: String like "agent.py:agent"
|
|
132
|
+
agent_spec: String like "agent.py:agent", "my_agents.py:custom_agent",
|
|
133
|
+
or "mypackage.agents.my_agent"
|
|
129
134
|
|
|
130
135
|
Returns:
|
|
131
136
|
tuple: (agent_object, error_message)
|
|
132
137
|
"""
|
|
133
138
|
try:
|
|
134
|
-
#
|
|
135
|
-
if ":"
|
|
136
|
-
|
|
139
|
+
# Determine format: file path (contains ":") vs module path (no ":" and no ".py")
|
|
140
|
+
if ":" in agent_spec:
|
|
141
|
+
# File path format: "path/to/file.py:object_name"
|
|
142
|
+
return _load_agent_from_file(agent_spec)
|
|
143
|
+
elif agent_spec.endswith(".py"):
|
|
144
|
+
# Looks like a file path without object name
|
|
145
|
+
return None, f"Invalid agent spec '{agent_spec}'. File path format requires object name: 'path/to/file.py:object_name'"
|
|
146
|
+
else:
|
|
147
|
+
# Module format: "mypackage.module.object_name"
|
|
148
|
+
return _load_agent_from_module(agent_spec)
|
|
149
|
+
|
|
150
|
+
except Exception as e:
|
|
151
|
+
return None, f"Failed to load agent from {agent_spec}: {e}"
|
|
137
152
|
|
|
138
|
-
file_path, object_name = agent_spec.rsplit(":", 1)
|
|
139
|
-
file_path = Path(file_path).resolve()
|
|
140
153
|
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
def _load_agent_from_file(agent_spec: str):
|
|
155
|
+
"""Load agent from file path format: 'path/to/file.py:object_name'"""
|
|
156
|
+
file_path, object_name = agent_spec.rsplit(":", 1)
|
|
157
|
+
file_path = Path(file_path).resolve()
|
|
143
158
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if spec is None or spec.loader is None:
|
|
147
|
-
return None, f"Failed to load module from {file_path}"
|
|
159
|
+
if not file_path.exists():
|
|
160
|
+
return None, f"Agent file not found: {file_path}"
|
|
148
161
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
# Load the module
|
|
163
|
+
spec = importlib.util.spec_from_file_location("custom_agent_module", file_path)
|
|
164
|
+
if spec is None or spec.loader is None:
|
|
165
|
+
return None, f"Failed to load module from {file_path}"
|
|
152
166
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
module = importlib.util.module_from_spec(spec)
|
|
168
|
+
sys.modules["custom_agent_module"] = module
|
|
169
|
+
spec.loader.exec_module(module)
|
|
156
170
|
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
# Get the object
|
|
172
|
+
if not hasattr(module, object_name):
|
|
173
|
+
return None, f"Object '{object_name}' not found in {file_path}"
|
|
174
|
+
|
|
175
|
+
agent = getattr(module, object_name)
|
|
176
|
+
return agent, None
|
|
159
177
|
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
|
|
179
|
+
def _load_agent_from_module(agent_spec: str):
|
|
180
|
+
"""Load agent from module format: 'mypackage.module.object_name'"""
|
|
181
|
+
parts = agent_spec.rsplit(".", 1)
|
|
182
|
+
|
|
183
|
+
if len(parts) < 2:
|
|
184
|
+
return None, f"Invalid module spec '{agent_spec}'. Expected format: 'module.object_name' or 'package.module.object_name'"
|
|
185
|
+
|
|
186
|
+
module_path, object_name = parts
|
|
187
|
+
|
|
188
|
+
try:
|
|
189
|
+
# Import the module
|
|
190
|
+
module = importlib.import_module(module_path)
|
|
191
|
+
except ModuleNotFoundError as e:
|
|
192
|
+
return None, f"Module '{module_path}' not found: {e}"
|
|
193
|
+
except ImportError as e:
|
|
194
|
+
return None, f"Failed to import module '{module_path}': {e}"
|
|
195
|
+
|
|
196
|
+
# Get the object
|
|
197
|
+
if not hasattr(module, object_name):
|
|
198
|
+
return None, f"Object '{object_name}' not found in module '{module_path}'"
|
|
199
|
+
|
|
200
|
+
agent = getattr(module, object_name)
|
|
201
|
+
return agent, None
|
|
162
202
|
|
|
163
203
|
# Module-level configuration (uses config defaults)
|
|
164
204
|
WORKSPACE_ROOT = config.WORKSPACE_ROOT
|
|
@@ -1621,7 +1661,10 @@ def run_app(
|
|
|
1621
1661
|
Args:
|
|
1622
1662
|
agent_instance (object, optional): Agent object instance (Python API only)
|
|
1623
1663
|
workspace (str, optional): Workspace directory path
|
|
1624
|
-
agent_spec (str, optional): Agent specification
|
|
1664
|
+
agent_spec (str, optional): Agent specification (overrides agent_instance).
|
|
1665
|
+
Supports two formats:
|
|
1666
|
+
- File path: "path/to/file.py:object_name"
|
|
1667
|
+
- Module path: "mypackage.module.object_name"
|
|
1625
1668
|
port (int, optional): Port number
|
|
1626
1669
|
host (str, optional): Host to bind to
|
|
1627
1670
|
debug (bool, optional): Debug mode
|
|
@@ -1638,9 +1681,12 @@ def run_app(
|
|
|
1638
1681
|
>>> my_agent = MyAgent()
|
|
1639
1682
|
>>> run_app(my_agent, workspace="~/my-workspace")
|
|
1640
1683
|
|
|
1641
|
-
>>> # Using agent spec
|
|
1684
|
+
>>> # Using agent spec (file path format)
|
|
1642
1685
|
>>> run_app(agent_spec="my_agent.py:agent", port=8080)
|
|
1643
1686
|
|
|
1687
|
+
>>> # Using agent spec (module format)
|
|
1688
|
+
>>> run_app(agent_spec="mypackage.agents.my_agent", port=8080)
|
|
1689
|
+
|
|
1644
1690
|
>>> # Without agent (manual mode)
|
|
1645
1691
|
>>> run_app(workspace="~/my-workspace", debug=True)
|
|
1646
1692
|
"""
|
cowork_dash/config.py
CHANGED
|
@@ -53,11 +53,16 @@ def get_config(key: str, default=None, type_cast=None):
|
|
|
53
53
|
_workspace_path = get_config("workspace_root", default="./")
|
|
54
54
|
WORKSPACE_ROOT = Path(_workspace_path).resolve() if _workspace_path else Path("./").resolve()
|
|
55
55
|
|
|
56
|
-
# Agent specification
|
|
56
|
+
# Agent specification - supports two formats:
|
|
57
|
+
# 1. File path: "path/to/file.py:object_name"
|
|
58
|
+
# 2. Module path: "mypackage.module.object_name"
|
|
57
59
|
# Environment variable: DEEPAGENT_SPEC (or DEEPAGENT_AGENT_SPEC for backwards compatibility)
|
|
58
60
|
# CLI argument: --agent
|
|
59
|
-
# Default:
|
|
60
|
-
#
|
|
61
|
+
# Default: package's built-in agent
|
|
62
|
+
# Examples:
|
|
63
|
+
# - "my_agents.py:agent" (file in current directory)
|
|
64
|
+
# - "/path/to/agent.py:my_agent" (absolute path)
|
|
65
|
+
# - "mypackage.agents.my_agent" (installed Python module)
|
|
61
66
|
_default_agent = str(Path(__file__).parent / "agent.py") + ":agent"
|
|
62
67
|
AGENT_SPEC = get_config("spec", default=None) or get_config("agent_spec", default=None) or _default_agent
|
|
63
68
|
|
cowork_dash/layout.py
CHANGED
|
@@ -100,8 +100,8 @@ Let's get started!"""
|
|
|
100
100
|
], style={"display": "flex", "alignItems": "center"})
|
|
101
101
|
], style={
|
|
102
102
|
"display": "flex", "justifyContent": "space-between",
|
|
103
|
-
"alignItems": "center", "
|
|
104
|
-
"
|
|
103
|
+
"alignItems": "center", "width": "100%",
|
|
104
|
+
"padding": "0 12px",
|
|
105
105
|
})
|
|
106
106
|
], id="header", style={
|
|
107
107
|
"background": "var(--mantine-color-body)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cowork-dash
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: AI Agent Web Interface with Filesystem and Canvas Visualization
|
|
5
5
|
Project-URL: Homepage, https://github.com/dkedar7/cowork-dash
|
|
6
6
|
Project-URL: Documentation, https://github.com/dkedar7/cowork-dash/blob/main/README.md
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
cowork_dash/__init__.py,sha256=37qBKl7g12Zos8GFukXLXligCdpD32e2qe9F8cd8Qdk,896
|
|
2
2
|
cowork_dash/__main__.py,sha256=CCM9VIkWuwh7hwVGNBBgCCbeVAcHj1soyBVXUaPgABk,131
|
|
3
3
|
cowork_dash/agent.py,sha256=dj50jBzP69YgEzEF44IeE8p11X0ap3xKwdITORnpkhs,4318
|
|
4
|
-
cowork_dash/app.py,sha256=
|
|
4
|
+
cowork_dash/app.py,sha256=kMTLzE6FA6cDwuWIxSCB62YZ_Z1an6PaX9sv220o6mI,70709
|
|
5
5
|
cowork_dash/canvas.py,sha256=9X_Z6gOwFwIfBk8rsXi4s1hpKAyaK6wglgZ_1UGjZ3E,11093
|
|
6
6
|
cowork_dash/cli.py,sha256=N9APQlQ-5oahUxMoICpJV1FcmVOFNmJpCfaULDeYhRY,6491
|
|
7
7
|
cowork_dash/components.py,sha256=VDJ_IQ8qW7O3dAMVoz97yzBByRBC7XvpnVmDMCIlEUY,20538
|
|
8
|
-
cowork_dash/config.py,sha256=
|
|
8
|
+
cowork_dash/config.py,sha256=6SfKDJmcK4X2ew4ao53Cg_RKqhDIw5V3BFiaDxbvKsY,3207
|
|
9
9
|
cowork_dash/file_utils.py,sha256=s2-L5wFOE-ChpKaZQwdRUSx5qA96ATR1QtmpkrJXUJY,8542
|
|
10
|
-
cowork_dash/layout.py,sha256=
|
|
10
|
+
cowork_dash/layout.py,sha256=e9E0okLhGf4E-slFjO0udyVD5IrpbVgXS4fXHZsMiXQ,11225
|
|
11
11
|
cowork_dash/tools.py,sha256=6WYK9-s32R5PfZvcpBIR55Z0I6wBgrxJvcxcgfnQ54E,23125
|
|
12
12
|
cowork_dash/assets/app.js,sha256=CIRhskgTn4zPJGfubTYvsZFYSj-0XJNniGlSggy75L4,8162
|
|
13
13
|
cowork_dash/assets/favicon.svg,sha256=MdT50APCvIlWh3HSwW5SNXYWB3q_wKfuLP-JV53SnKg,1065
|
|
14
14
|
cowork_dash/assets/styles.css,sha256=ZiWpULBDO64Hu6bZ5NYFbzDfQ8Ezn66eKjW1LpJ8anM,20621
|
|
15
|
-
cowork_dash-0.1.
|
|
16
|
-
cowork_dash-0.1.
|
|
17
|
-
cowork_dash-0.1.
|
|
18
|
-
cowork_dash-0.1.
|
|
19
|
-
cowork_dash-0.1.
|
|
15
|
+
cowork_dash-0.1.3.dist-info/METADATA,sha256=4UGO7YjH0El6Ta4vEMZSK0bgCSPgy4rqTHfgdYMAvOA,6959
|
|
16
|
+
cowork_dash-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
17
|
+
cowork_dash-0.1.3.dist-info/entry_points.txt,sha256=lL_9XJINiky3nh13tLqWd61LitKbbyh085ROATH9fck,53
|
|
18
|
+
cowork_dash-0.1.3.dist-info/licenses/LICENSE,sha256=2SFXFfIa_c_g_uwY0JApQDXI1mWqEfJeG87Pn4ehLMQ,1072
|
|
19
|
+
cowork_dash-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|