swarmauri_state_clipboard 0.9.1.dev2__tar.gz → 0.11.0.dev1__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.
- swarmauri_state_clipboard-0.11.0.dev1/PKG-INFO +179 -0
- swarmauri_state_clipboard-0.11.0.dev1/README.md +145 -0
- {swarmauri_state_clipboard-0.9.1.dev2 → swarmauri_state_clipboard-0.11.0.dev1}/pyproject.toml +14 -3
- {swarmauri_state_clipboard-0.9.1.dev2 → swarmauri_state_clipboard-0.11.0.dev1}/swarmauri_state_clipboard/ClipboardState.py +38 -15
- swarmauri_state_clipboard-0.9.1.dev2/PKG-INFO +0 -112
- swarmauri_state_clipboard-0.9.1.dev2/README.md +0 -84
- {swarmauri_state_clipboard-0.9.1.dev2 → swarmauri_state_clipboard-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_state_clipboard-0.9.1.dev2 → swarmauri_state_clipboard-0.11.0.dev1}/swarmauri_state_clipboard/__init__.py +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_state_clipboard
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
|
+
Summary: Clipboard-backed Swarmauri state provider for transient desktop workflows and local automation.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,state,clipboard,community,desktop automation,local workflow,transient state,state management,clipboard state
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Topic :: Desktop Environment
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
30
|
+
Requires-Dist: swarmauri_base
|
|
31
|
+
Requires-Dist: swarmauri_core
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://pepy.tech/project/swarmauri_state_clipboard/">
|
|
38
|
+
<img src="https://static.pepy.tech/badge/swarmauri_state_clipboard/month" alt="PyPI - Downloads"/></a>
|
|
39
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard/">
|
|
40
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard.svg"/></a>
|
|
41
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
42
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
43
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
44
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_state_clipboard" alt="PyPI - License"/></a>
|
|
45
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
46
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_state_clipboard?label=swarmauri_state_clipboard&color=green" alt="PyPI - swarmauri_state_clipboard"/></a>
|
|
47
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
48
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
49
|
+
|
|
50
|
+
# Swarmauri State Clipboard
|
|
51
|
+
|
|
52
|
+
`swarmauri_state_clipboard` provides a Swarmauri `StateBase` implementation
|
|
53
|
+
that stores state in the system clipboard. It is useful for desktop
|
|
54
|
+
prototyping, local demos, quick workflow handoffs, and lightweight
|
|
55
|
+
human-in-the-loop tooling where a full database or cache would be unnecessary.
|
|
56
|
+
|
|
57
|
+
## Why Use Swarmauri State Clipboard
|
|
58
|
+
|
|
59
|
+
- Persist small state payloads without adding external infrastructure.
|
|
60
|
+
- Bridge state between local tools, notebooks, shells, and GUI apps.
|
|
61
|
+
- Prototype Swarmauri stateful flows quickly on Windows, macOS, or Linux.
|
|
62
|
+
- Keep local development loops simple when you only need transient state.
|
|
63
|
+
|
|
64
|
+
## FAQ
|
|
65
|
+
|
|
66
|
+
> **What does this package store?**
|
|
67
|
+
> It stores dictionary-shaped data by serializing it to the system clipboard.
|
|
68
|
+
|
|
69
|
+
> **Which platforms are supported?**
|
|
70
|
+
> Windows uses `clip` and PowerShell `Get-Clipboard`, macOS uses `pbcopy` and
|
|
71
|
+
> `pbpaste`, and Linux uses `xclip`.
|
|
72
|
+
|
|
73
|
+
> **Is this suitable for production workloads?**
|
|
74
|
+
> Usually no. The clipboard is global, user-facing, and not designed for
|
|
75
|
+
> secure or concurrent application state.
|
|
76
|
+
|
|
77
|
+
> **How is clipboard data parsed when reading?**
|
|
78
|
+
> The package uses `ast.literal_eval` to parse string content into Python
|
|
79
|
+
> literals.
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
- Swarmauri `StateBase` implementation registered as `ClipboardState`.
|
|
84
|
+
- Cross-platform clipboard access through built-in OS utilities.
|
|
85
|
+
- Read, write, update, reset, and deep-copy state helpers.
|
|
86
|
+
- No third-party runtime dependency beyond core Swarmauri packages.
|
|
87
|
+
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
uv add swarmauri_state_clipboard
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install swarmauri_state_clipboard
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
103
|
+
|
|
104
|
+
state = ClipboardState()
|
|
105
|
+
state.write({"session": "abc123", "step": 1})
|
|
106
|
+
|
|
107
|
+
print(state.read())
|
|
108
|
+
|
|
109
|
+
state.update({"step": 2})
|
|
110
|
+
print(state.read())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Examples
|
|
114
|
+
|
|
115
|
+
### Use clipboard state in a local prototype
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
119
|
+
|
|
120
|
+
state = ClipboardState()
|
|
121
|
+
state.write({"draft": "ready", "owner": "local-user"})
|
|
122
|
+
|
|
123
|
+
print(state.read())
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Reset state after a task completes
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
130
|
+
|
|
131
|
+
state = ClipboardState()
|
|
132
|
+
state.write({"job": "complete"})
|
|
133
|
+
state.reset()
|
|
134
|
+
|
|
135
|
+
print(state.read()) # {}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Clone the current state for a second workflow branch
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
142
|
+
|
|
143
|
+
state = ClipboardState()
|
|
144
|
+
state.write({"request_id": "req-001", "status": "queued"})
|
|
145
|
+
|
|
146
|
+
forked_state = state.deep_copy()
|
|
147
|
+
forked_state.update({"status": "processed"})
|
|
148
|
+
|
|
149
|
+
print(state.read())
|
|
150
|
+
print(forked_state.read())
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Related Packages
|
|
154
|
+
|
|
155
|
+
- [swarmauri](https://pypi.org/project/swarmauri/)
|
|
156
|
+
- [swarmauri_standard](https://pypi.org/project/swarmauri_standard/)
|
|
157
|
+
- [swarmauri_workflow_statedriven](https://pypi.org/project/swarmauri_workflow_statedriven/)
|
|
158
|
+
|
|
159
|
+
## Swarmauri Foundations
|
|
160
|
+
|
|
161
|
+
- [swarmauri_core](https://pypi.org/project/swarmauri_core/)
|
|
162
|
+
- [swarmauri_base](https://pypi.org/project/swarmauri_base/)
|
|
163
|
+
|
|
164
|
+
## More Documentation
|
|
165
|
+
|
|
166
|
+
- [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
167
|
+
- [Python `ast.literal_eval` documentation](https://docs.python.org/3/library/ast.html#ast.literal_eval)
|
|
168
|
+
|
|
169
|
+
## Best Practices
|
|
170
|
+
|
|
171
|
+
- Keep clipboard payloads small and short-lived.
|
|
172
|
+
- Avoid storing secrets or sensitive tokens in clipboard-backed state.
|
|
173
|
+
- Install `xclip` explicitly on Linux hosts and CI runners.
|
|
174
|
+
- Prefer a durable state backend for concurrent, remote, or production flows.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
This project is licensed under the Apache-2.0 License.
|
|
179
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_state_clipboard/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_state_clipboard/month" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
9
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_state_clipboard" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_state_clipboard?label=swarmauri_state_clipboard&color=green" alt="PyPI - swarmauri_state_clipboard"/></a>
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
16
|
+
|
|
17
|
+
# Swarmauri State Clipboard
|
|
18
|
+
|
|
19
|
+
`swarmauri_state_clipboard` provides a Swarmauri `StateBase` implementation
|
|
20
|
+
that stores state in the system clipboard. It is useful for desktop
|
|
21
|
+
prototyping, local demos, quick workflow handoffs, and lightweight
|
|
22
|
+
human-in-the-loop tooling where a full database or cache would be unnecessary.
|
|
23
|
+
|
|
24
|
+
## Why Use Swarmauri State Clipboard
|
|
25
|
+
|
|
26
|
+
- Persist small state payloads without adding external infrastructure.
|
|
27
|
+
- Bridge state between local tools, notebooks, shells, and GUI apps.
|
|
28
|
+
- Prototype Swarmauri stateful flows quickly on Windows, macOS, or Linux.
|
|
29
|
+
- Keep local development loops simple when you only need transient state.
|
|
30
|
+
|
|
31
|
+
## FAQ
|
|
32
|
+
|
|
33
|
+
> **What does this package store?**
|
|
34
|
+
> It stores dictionary-shaped data by serializing it to the system clipboard.
|
|
35
|
+
|
|
36
|
+
> **Which platforms are supported?**
|
|
37
|
+
> Windows uses `clip` and PowerShell `Get-Clipboard`, macOS uses `pbcopy` and
|
|
38
|
+
> `pbpaste`, and Linux uses `xclip`.
|
|
39
|
+
|
|
40
|
+
> **Is this suitable for production workloads?**
|
|
41
|
+
> Usually no. The clipboard is global, user-facing, and not designed for
|
|
42
|
+
> secure or concurrent application state.
|
|
43
|
+
|
|
44
|
+
> **How is clipboard data parsed when reading?**
|
|
45
|
+
> The package uses `ast.literal_eval` to parse string content into Python
|
|
46
|
+
> literals.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- Swarmauri `StateBase` implementation registered as `ClipboardState`.
|
|
51
|
+
- Cross-platform clipboard access through built-in OS utilities.
|
|
52
|
+
- Read, write, update, reset, and deep-copy state helpers.
|
|
53
|
+
- No third-party runtime dependency beyond core Swarmauri packages.
|
|
54
|
+
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv add swarmauri_state_clipboard
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install swarmauri_state_clipboard
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
70
|
+
|
|
71
|
+
state = ClipboardState()
|
|
72
|
+
state.write({"session": "abc123", "step": 1})
|
|
73
|
+
|
|
74
|
+
print(state.read())
|
|
75
|
+
|
|
76
|
+
state.update({"step": 2})
|
|
77
|
+
print(state.read())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
### Use clipboard state in a local prototype
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
86
|
+
|
|
87
|
+
state = ClipboardState()
|
|
88
|
+
state.write({"draft": "ready", "owner": "local-user"})
|
|
89
|
+
|
|
90
|
+
print(state.read())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Reset state after a task completes
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
97
|
+
|
|
98
|
+
state = ClipboardState()
|
|
99
|
+
state.write({"job": "complete"})
|
|
100
|
+
state.reset()
|
|
101
|
+
|
|
102
|
+
print(state.read()) # {}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Clone the current state for a second workflow branch
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from swarmauri_state_clipboard import ClipboardState
|
|
109
|
+
|
|
110
|
+
state = ClipboardState()
|
|
111
|
+
state.write({"request_id": "req-001", "status": "queued"})
|
|
112
|
+
|
|
113
|
+
forked_state = state.deep_copy()
|
|
114
|
+
forked_state.update({"status": "processed"})
|
|
115
|
+
|
|
116
|
+
print(state.read())
|
|
117
|
+
print(forked_state.read())
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Related Packages
|
|
121
|
+
|
|
122
|
+
- [swarmauri](https://pypi.org/project/swarmauri/)
|
|
123
|
+
- [swarmauri_standard](https://pypi.org/project/swarmauri_standard/)
|
|
124
|
+
- [swarmauri_workflow_statedriven](https://pypi.org/project/swarmauri_workflow_statedriven/)
|
|
125
|
+
|
|
126
|
+
## Swarmauri Foundations
|
|
127
|
+
|
|
128
|
+
- [swarmauri_core](https://pypi.org/project/swarmauri_core/)
|
|
129
|
+
- [swarmauri_base](https://pypi.org/project/swarmauri_base/)
|
|
130
|
+
|
|
131
|
+
## More Documentation
|
|
132
|
+
|
|
133
|
+
- [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
134
|
+
- [Python `ast.literal_eval` documentation](https://docs.python.org/3/library/ast.html#ast.literal_eval)
|
|
135
|
+
|
|
136
|
+
## Best Practices
|
|
137
|
+
|
|
138
|
+
- Keep clipboard payloads small and short-lived.
|
|
139
|
+
- Avoid storing secrets or sensitive tokens in clipboard-backed state.
|
|
140
|
+
- Install `xclip` explicitly on Linux hosts and CI runners.
|
|
141
|
+
- Prefer a durable state backend for concurrent, remote, or production flows.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the Apache-2.0 License.
|
{swarmauri_state_clipboard-0.9.1.dev2 → swarmauri_state_clipboard-0.11.0.dev1}/pyproject.toml
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_state_clipboard"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "Swarmauri
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
|
+
description = "Clipboard-backed Swarmauri state provider for transient desktop workflows and local automation."
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "http://github.com/swarmauri/swarmauri-sdk"
|
|
@@ -11,6 +11,12 @@ classifiers = [
|
|
|
11
11
|
"Natural Language :: English",
|
|
12
12
|
"Development Status :: 3 - Alpha",
|
|
13
13
|
"Intended Audience :: Developers",
|
|
14
|
+
"Intended Audience :: System Administrators",
|
|
15
|
+
"Operating System :: MacOS",
|
|
16
|
+
"Operating System :: Microsoft :: Windows",
|
|
17
|
+
"Operating System :: POSIX :: Linux",
|
|
18
|
+
"Topic :: Desktop Environment",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
14
20
|
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
15
21
|
"Programming Language :: Python",
|
|
16
22
|
"Programming Language :: Python :: 3",
|
|
@@ -28,6 +34,11 @@ keywords = [
|
|
|
28
34
|
"state",
|
|
29
35
|
"clipboard",
|
|
30
36
|
"community",
|
|
37
|
+
"desktop automation",
|
|
38
|
+
"local workflow",
|
|
39
|
+
"transient state",
|
|
40
|
+
"state management",
|
|
41
|
+
"clipboard state",
|
|
31
42
|
]
|
|
32
43
|
|
|
33
44
|
[tool.uv.sources]
|
|
@@ -67,7 +78,7 @@ dev = [
|
|
|
67
78
|
"pytest-xdist>=3.6.1",
|
|
68
79
|
"pytest-json-report>=1.5.0",
|
|
69
80
|
"python-dotenv",
|
|
70
|
-
"
|
|
81
|
+
"httpx>=0.27",
|
|
71
82
|
"flake8>=7.0",
|
|
72
83
|
"pytest-timeout>=2.3.1",
|
|
73
84
|
"ruff>=0.9.9",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
|
-
This module provides a ClipboardState class that implements a system
|
|
3
|
-
|
|
2
|
+
This module provides a ClipboardState class that implements a system
|
|
3
|
+
clipboard-based approach
|
|
4
|
+
to storing and retrieving state data. It uses only built-in Python modules and
|
|
5
|
+
platform-specific
|
|
4
6
|
commands (clip on Windows, pbcopy/pbpaste on macOS, xclip on Linux).
|
|
5
7
|
"""
|
|
6
8
|
|
|
@@ -26,7 +28,9 @@ class ClipboardState(StateBase):
|
|
|
26
28
|
|
|
27
29
|
@classmethod
|
|
28
30
|
def clipboard_paste(cls, text: str) -> None:
|
|
29
|
-
"""
|
|
31
|
+
"""
|
|
32
|
+
Copy the given text to the system clipboard using standard library
|
|
33
|
+
calls.
|
|
30
34
|
|
|
31
35
|
text (str): The text to copy to the clipboard.
|
|
32
36
|
RETURNS (None): This method does not return anything.
|
|
@@ -36,22 +40,29 @@ class ClipboardState(StateBase):
|
|
|
36
40
|
platform = sys.platform
|
|
37
41
|
if platform.startswith("win"):
|
|
38
42
|
# Windows: uses 'clip' command
|
|
39
|
-
with subprocess.Popen(
|
|
43
|
+
with subprocess.Popen(
|
|
44
|
+
["clip"], stdin=subprocess.PIPE, text=True
|
|
45
|
+
) as proc:
|
|
40
46
|
proc.communicate(text)
|
|
41
47
|
elif platform.startswith("darwin"):
|
|
42
48
|
# macOS: uses 'pbcopy'
|
|
43
|
-
with subprocess.Popen(
|
|
49
|
+
with subprocess.Popen(
|
|
50
|
+
["pbcopy"], stdin=subprocess.PIPE, text=True
|
|
51
|
+
) as proc:
|
|
44
52
|
proc.communicate(text)
|
|
45
53
|
else:
|
|
46
54
|
# Linux/Unix: uses 'xclip'
|
|
47
55
|
with subprocess.Popen(
|
|
48
|
-
["xclip", "-selection", "clipboard"],
|
|
56
|
+
["xclip", "-selection", "clipboard"],
|
|
57
|
+
stdin=subprocess.PIPE,
|
|
58
|
+
text=True,
|
|
49
59
|
) as proc:
|
|
50
60
|
proc.communicate(text)
|
|
51
61
|
|
|
52
62
|
@classmethod
|
|
53
63
|
def clipboard_copy(cls) -> str:
|
|
54
|
-
"""
|
|
64
|
+
"""
|
|
65
|
+
Retrieve text from the system clipboard using standard library calls.
|
|
55
66
|
|
|
56
67
|
RETURNS (str): The text contents of the system clipboard.
|
|
57
68
|
RAISES (FileNotFoundError, subprocess.CalledProcessError):
|
|
@@ -68,7 +79,9 @@ class ClipboardState(StateBase):
|
|
|
68
79
|
return completed.stdout
|
|
69
80
|
elif platform.startswith("darwin"):
|
|
70
81
|
# macOS: uses 'pbpaste'
|
|
71
|
-
completed = subprocess.run(
|
|
82
|
+
completed = subprocess.run(
|
|
83
|
+
["pbpaste"], capture_output=True, text=True
|
|
84
|
+
)
|
|
72
85
|
return completed.stdout
|
|
73
86
|
else:
|
|
74
87
|
# Linux/Unix: uses 'xclip'
|
|
@@ -102,7 +115,9 @@ class ClipboardState(StateBase):
|
|
|
102
115
|
raise ValueError(f"Failed to read state from clipboard: {e}")
|
|
103
116
|
|
|
104
117
|
def write(self, data: Dict[str, str]) -> None:
|
|
105
|
-
"""
|
|
118
|
+
"""
|
|
119
|
+
Replace the current state with the given data by copying it to the
|
|
120
|
+
clipboard.
|
|
106
121
|
|
|
107
122
|
data (Dict[str, str]): The state data to write.
|
|
108
123
|
RETURNS (None): This method does not return anything.
|
|
@@ -116,9 +131,12 @@ class ClipboardState(StateBase):
|
|
|
116
131
|
raise ValueError(f"Failed to write state to clipboard: {e}")
|
|
117
132
|
|
|
118
133
|
def update(self, data: Dict[str, str]) -> None:
|
|
119
|
-
"""
|
|
134
|
+
"""
|
|
135
|
+
Update the current clipboard state by merging existing state with new
|
|
136
|
+
data.
|
|
120
137
|
|
|
121
|
-
data (Dict[str, str]): The new state data to merge into the existing
|
|
138
|
+
data (Dict[str, str]): The new state data to merge into the existing
|
|
139
|
+
clipboard state.
|
|
122
140
|
RETURNS (None): This method does not return anything.
|
|
123
141
|
RAISES (ValueError): If there is an error updating the clipboard state.
|
|
124
142
|
"""
|
|
@@ -133,7 +151,8 @@ class ClipboardState(StateBase):
|
|
|
133
151
|
"""Reset the clipboard state to an empty dictionary.
|
|
134
152
|
|
|
135
153
|
RETURNS (None): This method does not return anything.
|
|
136
|
-
RAISES (ValueError): If there is an error resetting the clipboard
|
|
154
|
+
RAISES (ValueError): If there is an error resetting the clipboard
|
|
155
|
+
state.
|
|
137
156
|
"""
|
|
138
157
|
try:
|
|
139
158
|
self.write({})
|
|
@@ -141,10 +160,14 @@ class ClipboardState(StateBase):
|
|
|
141
160
|
raise ValueError(f"Failed to reset clipboard state: {e}")
|
|
142
161
|
|
|
143
162
|
def deep_copy(self) -> "ClipboardState":
|
|
144
|
-
"""
|
|
163
|
+
"""
|
|
164
|
+
Create a deep copy of the current state as a new ClipboardState
|
|
165
|
+
instance.
|
|
145
166
|
|
|
146
|
-
RETURNS (ClipboardState): A new ClipboardState instance with the same
|
|
147
|
-
|
|
167
|
+
RETURNS (ClipboardState): A new ClipboardState instance with the same
|
|
168
|
+
clipboard data.
|
|
169
|
+
RAISES (ValueError): If there is an error creating the deep copy of the
|
|
170
|
+
state.
|
|
148
171
|
"""
|
|
149
172
|
try:
|
|
150
173
|
current_state = self.read()
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: swarmauri_state_clipboard
|
|
3
|
-
Version: 0.9.1.dev2
|
|
4
|
-
Summary: Swarmauri Community Clipboard State
|
|
5
|
-
License-Expression: Apache-2.0
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Keywords: swarmauri,state,clipboard,community
|
|
8
|
-
Author: Jacob Stewart
|
|
9
|
-
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.15
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Development Status :: 3 - Alpha
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
16
|
-
Classifier: Programming Language :: Python
|
|
17
|
-
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
-
Requires-Dist: swarmauri_base
|
|
25
|
-
Requires-Dist: swarmauri_core
|
|
26
|
-
Description-Content-Type: text/markdown
|
|
27
|
-
|
|
28
|
-

|
|
29
|
-
|
|
30
|
-
<p align="center">
|
|
31
|
-
<a href="https://pepy.tech/project/swarmauri_state_clipboard/">
|
|
32
|
-
<img src="https://static.pepy.tech/badge/swarmauri_state_clipboard/month" alt="PyPI - Downloads"/></a>
|
|
33
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard/">
|
|
34
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard.svg"/></a>
|
|
35
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
36
|
-
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
37
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
38
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_state_clipboard" alt="PyPI - License"/></a>
|
|
39
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
40
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_state_clipboard?label=swarmauri_state_clipboard&color=green" alt="PyPI - swarmauri_state_clipboard"/></a>
|
|
41
|
-
</p>
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
# Swarmauri State Clipboard
|
|
45
|
-
|
|
46
|
-
`ClipboardState` implements Swarmauri's `StateBase` interface using the system clipboard as storage. Useful for quick demos or sharing state between desktop tools without running an external datastore.
|
|
47
|
-
|
|
48
|
-
## Features
|
|
49
|
-
|
|
50
|
-
- Reads/writes clipboard contents via platform commands (`clip`, `pbcopy`/`pbpaste`, `xclip`).
|
|
51
|
-
- Stores JSON-like dictionaries as string representations; uses `ast.literal_eval` when reading.
|
|
52
|
-
- Provides `write`, `read`, `update`, `reset`, and `deep_copy` helpers.
|
|
53
|
-
|
|
54
|
-
## Prerequisites
|
|
55
|
-
|
|
56
|
-
- Python 3.10 or newer.
|
|
57
|
-
- OS clipboard utilities available:
|
|
58
|
-
- Windows: `clip` (built-in) and PowerShell `Get-Clipboard`.
|
|
59
|
-
- macOS: `pbcopy`/`pbpaste` (built-in).
|
|
60
|
-
- Linux: `xclip` installed (`apt install xclip` or equivalent).
|
|
61
|
-
|
|
62
|
-
## Installation
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# pip
|
|
66
|
-
pip install swarmauri_state_clipboard
|
|
67
|
-
|
|
68
|
-
# poetry
|
|
69
|
-
poetry add swarmauri_state_clipboard
|
|
70
|
-
|
|
71
|
-
# uv (pyproject-based projects)
|
|
72
|
-
uv add swarmauri_state_clipboard
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Quickstart
|
|
76
|
-
|
|
77
|
-
```python
|
|
78
|
-
from swarmauri_state_clipboard import ClipboardState
|
|
79
|
-
|
|
80
|
-
state = ClipboardState()
|
|
81
|
-
state.write({"key1": "value1", "counter": 42})
|
|
82
|
-
print(state.read())
|
|
83
|
-
|
|
84
|
-
state.update({"counter": 43})
|
|
85
|
-
print(state.read())
|
|
86
|
-
|
|
87
|
-
state.reset()
|
|
88
|
-
print(state.read()) # {}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Deep Copy
|
|
92
|
-
|
|
93
|
-
```python
|
|
94
|
-
state = ClipboardState()
|
|
95
|
-
state.write({"session": "abc123"})
|
|
96
|
-
clone = state.deep_copy()
|
|
97
|
-
clone.update({"session": "xyz789"})
|
|
98
|
-
|
|
99
|
-
print(state.read()) # {'session': 'abc123'}
|
|
100
|
-
print(clone.read()) # {'session': 'xyz789'}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Tips
|
|
104
|
-
|
|
105
|
-
- Clipboard overwrites are global; avoid using this state provider in multi-user or production environments where clipboard privacy matters.
|
|
106
|
-
- Contents are stored as Python literal strings—avoid writing untrusted data to the clipboard to prevent evaluation issues (though `ast.literal_eval` mitigates code execution risks).
|
|
107
|
-
- Ensure required system commands exist before running in CI or containers (install `xclip` for Linux builds).
|
|
108
|
-
|
|
109
|
-
## Want to help?
|
|
110
|
-
|
|
111
|
-
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
|
|
112
|
-
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<a href="https://pepy.tech/project/swarmauri_state_clipboard/">
|
|
5
|
-
<img src="https://static.pepy.tech/badge/swarmauri_state_clipboard/month" alt="PyPI - Downloads"/></a>
|
|
6
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard/">
|
|
7
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_state_clipboard.svg"/></a>
|
|
8
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
9
|
-
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
11
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_state_clipboard" alt="PyPI - License"/></a>
|
|
12
|
-
<a href="https://pypi.org/project/swarmauri_state_clipboard/">
|
|
13
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_state_clipboard?label=swarmauri_state_clipboard&color=green" alt="PyPI - swarmauri_state_clipboard"/></a>
|
|
14
|
-
</p>
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
# Swarmauri State Clipboard
|
|
18
|
-
|
|
19
|
-
`ClipboardState` implements Swarmauri's `StateBase` interface using the system clipboard as storage. Useful for quick demos or sharing state between desktop tools without running an external datastore.
|
|
20
|
-
|
|
21
|
-
## Features
|
|
22
|
-
|
|
23
|
-
- Reads/writes clipboard contents via platform commands (`clip`, `pbcopy`/`pbpaste`, `xclip`).
|
|
24
|
-
- Stores JSON-like dictionaries as string representations; uses `ast.literal_eval` when reading.
|
|
25
|
-
- Provides `write`, `read`, `update`, `reset`, and `deep_copy` helpers.
|
|
26
|
-
|
|
27
|
-
## Prerequisites
|
|
28
|
-
|
|
29
|
-
- Python 3.10 or newer.
|
|
30
|
-
- OS clipboard utilities available:
|
|
31
|
-
- Windows: `clip` (built-in) and PowerShell `Get-Clipboard`.
|
|
32
|
-
- macOS: `pbcopy`/`pbpaste` (built-in).
|
|
33
|
-
- Linux: `xclip` installed (`apt install xclip` or equivalent).
|
|
34
|
-
|
|
35
|
-
## Installation
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# pip
|
|
39
|
-
pip install swarmauri_state_clipboard
|
|
40
|
-
|
|
41
|
-
# poetry
|
|
42
|
-
poetry add swarmauri_state_clipboard
|
|
43
|
-
|
|
44
|
-
# uv (pyproject-based projects)
|
|
45
|
-
uv add swarmauri_state_clipboard
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Quickstart
|
|
49
|
-
|
|
50
|
-
```python
|
|
51
|
-
from swarmauri_state_clipboard import ClipboardState
|
|
52
|
-
|
|
53
|
-
state = ClipboardState()
|
|
54
|
-
state.write({"key1": "value1", "counter": 42})
|
|
55
|
-
print(state.read())
|
|
56
|
-
|
|
57
|
-
state.update({"counter": 43})
|
|
58
|
-
print(state.read())
|
|
59
|
-
|
|
60
|
-
state.reset()
|
|
61
|
-
print(state.read()) # {}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Deep Copy
|
|
65
|
-
|
|
66
|
-
```python
|
|
67
|
-
state = ClipboardState()
|
|
68
|
-
state.write({"session": "abc123"})
|
|
69
|
-
clone = state.deep_copy()
|
|
70
|
-
clone.update({"session": "xyz789"})
|
|
71
|
-
|
|
72
|
-
print(state.read()) # {'session': 'abc123'}
|
|
73
|
-
print(clone.read()) # {'session': 'xyz789'}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Tips
|
|
77
|
-
|
|
78
|
-
- Clipboard overwrites are global; avoid using this state provider in multi-user or production environments where clipboard privacy matters.
|
|
79
|
-
- Contents are stored as Python literal strings—avoid writing untrusted data to the clipboard to prevent evaluation issues (though `ast.literal_eval` mitigates code execution risks).
|
|
80
|
-
- Ensure required system commands exist before running in CI or containers (install `xclip` for Linux builds).
|
|
81
|
-
|
|
82
|
-
## Want to help?
|
|
83
|
-
|
|
84
|
-
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
|
|
File without changes
|
|
File without changes
|