agent-workspace 2026.6.15a4__tar.gz
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.
- agent_workspace-2026.6.15a4/PKG-INFO +11 -0
- agent_workspace-2026.6.15a4/agent_workspace/__init__.py +46 -0
- agent_workspace-2026.6.15a4/agent_workspace/_agent_workspace.pyi +80 -0
- agent_workspace-2026.6.15a4/agent_workspace/py.typed +0 -0
- agent_workspace-2026.6.15a4/pyproject.toml +34 -0
- agent_workspace-2026.6.15a4/rust/Cargo.lock +2425 -0
- agent_workspace-2026.6.15a4/rust/Cargo.toml +55 -0
- agent_workspace-2026.6.15a4/rust/README.md +375 -0
- agent_workspace-2026.6.15a4/rust/data/.gitkeep +0 -0
- agent_workspace-2026.6.15a4/rust/data/docs/a.txt +1 -0
- agent_workspace-2026.6.15a4/rust/data/docs/a.txt.meta.yaml +7 -0
- agent_workspace-2026.6.15a4/rust/data/docs/demo.txt +1 -0
- agent_workspace-2026.6.15a4/rust/data/docs/demo.txt.meta.yaml +7 -0
- agent_workspace-2026.6.15a4/rust/data/other/b.txt +1 -0
- agent_workspace-2026.6.15a4/rust/data/other/b.txt.meta.yaml +7 -0
- agent_workspace-2026.6.15a4/rust/data/tmp/config.yaml +4 -0
- agent_workspace-2026.6.15a4/rust/data/tmp/data/api/xxx.md +1 -0
- agent_workspace-2026.6.15a4/rust/data/tmp/data/api/xxx.md.meta.yaml +7 -0
- agent_workspace-2026.6.15a4/rust/data/tmp/data/api/yyy.md +1 -0
- agent_workspace-2026.6.15a4/rust/data/tmp/data/api/yyy.md.meta.yaml +7 -0
- agent_workspace-2026.6.15a4/rust/src/cli.rs +187 -0
- agent_workspace-2026.6.15a4/rust/src/commands/init.rs +144 -0
- agent_workspace-2026.6.15a4/rust/src/commands/list.rs +71 -0
- agent_workspace-2026.6.15a4/rust/src/commands/mod.rs +5 -0
- agent_workspace-2026.6.15a4/rust/src/commands/read.rs +56 -0
- agent_workspace-2026.6.15a4/rust/src/commands/remove.rs +6 -0
- agent_workspace-2026.6.15a4/rust/src/commands/write.rs +44 -0
- agent_workspace-2026.6.15a4/rust/src/config/load.rs +168 -0
- agent_workspace-2026.6.15a4/rust/src/config/mod.rs +48 -0
- agent_workspace-2026.6.15a4/rust/src/config/raw.rs +58 -0
- agent_workspace-2026.6.15a4/rust/src/config/templates.rs +14 -0
- agent_workspace-2026.6.15a4/rust/src/error.rs +38 -0
- agent_workspace-2026.6.15a4/rust/src/lib.rs +13 -0
- agent_workspace-2026.6.15a4/rust/src/lock.rs +50 -0
- agent_workspace-2026.6.15a4/rust/src/main.rs +8 -0
- agent_workspace-2026.6.15a4/rust/src/mcp/mod.rs +15 -0
- agent_workspace-2026.6.15a4/rust/src/mcp/protocol.rs +92 -0
- agent_workspace-2026.6.15a4/rust/src/mcp/server.rs +231 -0
- agent_workspace-2026.6.15a4/rust/src/mcp/tools.rs +190 -0
- agent_workspace-2026.6.15a4/rust/src/metadata.rs +130 -0
- agent_workspace-2026.6.15a4/rust/src/paths/metadata_name.rs +32 -0
- agent_workspace-2026.6.15a4/rust/src/paths/mod.rs +12 -0
- agent_workspace-2026.6.15a4/rust/src/paths/normalize.rs +44 -0
- agent_workspace-2026.6.15a4/rust/src/paths/resolve.rs +116 -0
- agent_workspace-2026.6.15a4/rust/src/paths/scope_prefix.rs +47 -0
- agent_workspace-2026.6.15a4/rust/src/python.rs +267 -0
- agent_workspace-2026.6.15a4/rust/src/ranges.rs +145 -0
- agent_workspace-2026.6.15a4/rust/src/scoping.rs +115 -0
- agent_workspace-2026.6.15a4/rust/src/storage/file.rs +320 -0
- agent_workspace-2026.6.15a4/rust/src/storage/handle.rs +103 -0
- agent_workspace-2026.6.15a4/rust/src/storage/mod.rs +38 -0
- agent_workspace-2026.6.15a4/rust/src/storage/mysql/connection.rs +164 -0
- agent_workspace-2026.6.15a4/rust/src/storage/mysql/mod.rs +212 -0
- agent_workspace-2026.6.15a4/rust/src/storage/scoped.rs +65 -0
- agent_workspace-2026.6.15a4/rust/tests/integration.rs +390 -0
- agent_workspace-2026.6.15a4/rust/tests/mysql_integration.rs +194 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-workspace
|
|
3
|
+
Version: 2026.6.15a4
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Summary: Restricted file-operation workspace for AI agents (Python bindings over the Rust core)
|
|
8
|
+
Keywords: agent,workspace,mcp,filesystem
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Project-URL: Repository, https://github.com/dropxhq/agent-workspace
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""agent-workspace: restricted file-operation workspace for AI agents.
|
|
2
|
+
|
|
3
|
+
Native bindings over the Rust core. All paths are workspace-relative and
|
|
4
|
+
cannot escape the configured workspace root.
|
|
5
|
+
|
|
6
|
+
Example
|
|
7
|
+
-------
|
|
8
|
+
>>> import agent_workspace as ws
|
|
9
|
+
>>> ws.init("./my-workspace") # writes config.yaml + data/
|
|
10
|
+
>>> w = ws.Workspace("./my-workspace/config.yaml")
|
|
11
|
+
>>> w.write("docs/a.txt", "hello\\n", created_by="me", desc="demo")
|
|
12
|
+
>>> w.read("docs/a.txt")
|
|
13
|
+
'hello\\n'
|
|
14
|
+
>>> report = w.list()
|
|
15
|
+
>>> report.file_count
|
|
16
|
+
1
|
|
17
|
+
>>> w.remove("docs/a.txt")
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from ._agent_workspace import (
|
|
21
|
+
FileMeta,
|
|
22
|
+
InvalidPathError,
|
|
23
|
+
InvalidRangesError,
|
|
24
|
+
ListReport,
|
|
25
|
+
LockConflictError,
|
|
26
|
+
NotFoundError,
|
|
27
|
+
PathEscapeError,
|
|
28
|
+
Workspace,
|
|
29
|
+
WorkspaceError,
|
|
30
|
+
__version__,
|
|
31
|
+
init,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"Workspace",
|
|
36
|
+
"ListReport",
|
|
37
|
+
"FileMeta",
|
|
38
|
+
"init",
|
|
39
|
+
"WorkspaceError",
|
|
40
|
+
"InvalidPathError",
|
|
41
|
+
"PathEscapeError",
|
|
42
|
+
"NotFoundError",
|
|
43
|
+
"LockConflictError",
|
|
44
|
+
"InvalidRangesError",
|
|
45
|
+
"__version__",
|
|
46
|
+
]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
__version__: str
|
|
4
|
+
|
|
5
|
+
class FileMeta:
|
|
6
|
+
"""Metadata for a single workspace file."""
|
|
7
|
+
|
|
8
|
+
relative_path: str
|
|
9
|
+
created_by: str
|
|
10
|
+
desc: str
|
|
11
|
+
created_at: str # RFC 3339 timestamp
|
|
12
|
+
updated_at: str # RFC 3339 timestamp
|
|
13
|
+
size_bytes: int
|
|
14
|
+
sha256: Optional[str]
|
|
15
|
+
|
|
16
|
+
class ListReport:
|
|
17
|
+
"""Result of :meth:`Workspace.list`."""
|
|
18
|
+
|
|
19
|
+
scope: Optional[str]
|
|
20
|
+
file_count: int
|
|
21
|
+
total_size_bytes: int
|
|
22
|
+
files: list[FileMeta]
|
|
23
|
+
|
|
24
|
+
class Workspace:
|
|
25
|
+
"""A handle to a workspace backend, scoped to an optional user/session.
|
|
26
|
+
|
|
27
|
+
All paths are workspace-relative and cannot escape the workspace root.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
config_path: str
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
config_path: Optional[str] = ...,
|
|
35
|
+
*,
|
|
36
|
+
user_id: Optional[str] = ...,
|
|
37
|
+
session_id: Optional[str] = ...,
|
|
38
|
+
) -> None:
|
|
39
|
+
"""Open a workspace.
|
|
40
|
+
|
|
41
|
+
:param config_path: path to ``config.yaml``. If ``None``, resolves via
|
|
42
|
+
``AGENT_WORKSPACE_CONFIG`` or ``./config.yaml``.
|
|
43
|
+
:param user_id: optional scoping segment.
|
|
44
|
+
:param session_id: optional scoping segment (combined with ``user_id``).
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def read(self, path: str, ranges: Optional[str] = ...) -> str:
|
|
48
|
+
"""Read a file. ``ranges`` is a 1-indexed, comma-separated spec
|
|
49
|
+
(e.g. ``"1-10,20-30"``); when given, only those lines are returned."""
|
|
50
|
+
|
|
51
|
+
def write(
|
|
52
|
+
self,
|
|
53
|
+
path: str,
|
|
54
|
+
content: str,
|
|
55
|
+
*,
|
|
56
|
+
created_by: str,
|
|
57
|
+
desc: str,
|
|
58
|
+
ranges: Optional[str] = ...,
|
|
59
|
+
) -> None:
|
|
60
|
+
"""Write ``content`` to ``path``. With ``ranges`` (a single
|
|
61
|
+
``"START-END"``), replaces those lines instead of overwriting."""
|
|
62
|
+
|
|
63
|
+
def list(self, scope: Optional[str] = ...) -> ListReport:
|
|
64
|
+
"""List files, optionally restricted to a subdirectory ``scope``."""
|
|
65
|
+
|
|
66
|
+
def remove(self, path: str) -> None:
|
|
67
|
+
"""Remove a file and its metadata."""
|
|
68
|
+
|
|
69
|
+
def init(target: Optional[str] = ..., *, backend: str = ...) -> None:
|
|
70
|
+
"""Initialize a new workspace (writes ``config.yaml``; for the file backend
|
|
71
|
+
also creates ``data/``). ``backend`` is ``"file"`` (default) or ``"mysql"``."""
|
|
72
|
+
|
|
73
|
+
class WorkspaceError(Exception):
|
|
74
|
+
"""Base class for all workspace errors."""
|
|
75
|
+
|
|
76
|
+
class InvalidPathError(WorkspaceError): ...
|
|
77
|
+
class PathEscapeError(WorkspaceError): ...
|
|
78
|
+
class NotFoundError(WorkspaceError): ...
|
|
79
|
+
class LockConflictError(WorkspaceError): ...
|
|
80
|
+
class InvalidRangesError(WorkspaceError): ...
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.7,<2"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agent-workspace"
|
|
7
|
+
description = "Restricted file-operation workspace for AI agents (Python bindings over the Rust core)"
|
|
8
|
+
license = { text = "Apache-2.0" }
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
keywords = ["agent", "workspace", "mcp", "filesystem"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Rust",
|
|
13
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
14
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
15
|
+
]
|
|
16
|
+
# Version is sourced from ../rust/Cargo.toml by maturin.
|
|
17
|
+
dynamic = ["version"]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Repository = "https://github.com/dropxhq/agent-workspace"
|
|
21
|
+
|
|
22
|
+
[tool.maturin]
|
|
23
|
+
# Build the PyO3 extension; the `python` cargo feature gates all binding code.
|
|
24
|
+
features = ["python"]
|
|
25
|
+
bindings = "pyo3"
|
|
26
|
+
# Native module lives inside the Python package as `_agent_workspace`.
|
|
27
|
+
module-name = "agent_workspace._agent_workspace"
|
|
28
|
+
# Pure-Python sources (this directory).
|
|
29
|
+
python-source = "."
|
|
30
|
+
manifest-path = "rust/Cargo.toml"
|
|
31
|
+
# Produce version-agnostic abi3 wheels (matches the abi3-py39 cargo feature).
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = ["maturin>=1.7,<2"]
|