@storacha/clawracha 0.3.15 → 0.4.0
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.
- package/LICENSE.md +204 -0
- package/README.md +117 -110
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +3 -3
- package/dist/handlers/apply.d.ts +3 -11
- package/dist/handlers/apply.d.ts.map +1 -1
- package/dist/handlers/apply.js +5 -32
- package/dist/handlers/process.d.ts +3 -7
- package/dist/handlers/process.d.ts.map +1 -1
- package/dist/handlers/process.js +30 -60
- package/dist/handlers/remote.d.ts +1 -3
- package/dist/handlers/remote.d.ts.map +1 -1
- package/dist/handlers/remote.js +4 -34
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/mdsync/index.d.ts +2 -2
- package/dist/mdsync/index.d.ts.map +1 -1
- package/dist/mdsync/index.js +8 -17
- package/dist/plugin.js +2 -2
- package/dist/sync.d.ts +20 -10
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +76 -108
- package/dist/types/index.d.ts +11 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/config.d.ts +26 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +89 -0
- package/dist/utils/contentfetcher.d.ts +6 -0
- package/dist/utils/contentfetcher.d.ts.map +1 -0
- package/dist/utils/contentfetcher.js +58 -0
- package/dist/utils/crypto.d.ts +0 -6
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +0 -45
- package/dist/utils/differ.d.ts.map +1 -1
- package/dist/utils/differ.js +6 -0
- package/dist/utils/encoder.d.ts +2 -15
- package/dist/utils/encoder.d.ts.map +1 -1
- package/dist/utils/encoder.js +8 -49
- package/dist/utils/tempcar.d.ts +1 -1
- package/dist/utils/tempcar.d.ts.map +1 -1
- package/dist/utils/tempcar.js +4 -2
- package/package.json +3 -2
package/LICENSE.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
The contents of this repository are Copyright (c) corresponding authors and
|
|
2
|
+
contributors, licensed under the `Permissive License Stack` meaning either of:
|
|
3
|
+
|
|
4
|
+
- Apache-2.0 Software License: https://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
([...4tr2kfsq](https://dweb.link/ipfs/bafkreiankqxazcae4onkp436wag2lj3ccso4nawxqkkfckd6cg4tr2kfsq))
|
|
6
|
+
|
|
7
|
+
- MIT Software License: https://opensource.org/licenses/MIT
|
|
8
|
+
([...vljevcba](https://dweb.link/ipfs/bafkreiepofszg4gfe2gzuhojmksgemsub2h4uy2gewdnr35kswvljevcba))
|
|
9
|
+
|
|
10
|
+
You may not use the contents of this repository except in compliance
|
|
11
|
+
with one of the listed Licenses. For an extended clarification of the
|
|
12
|
+
intent behind the choice of Licensing please refer to
|
|
13
|
+
https://protocol.ai/blog/announcing-the-permissive-license-stack/
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the terms listed in this notice is distributed on
|
|
17
|
+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
18
|
+
either express or implied. See each License for the specific language
|
|
19
|
+
governing permissions and limitations under that License.
|
|
20
|
+
|
|
21
|
+
<!--- SPDX-License-Identifier: Apache-2.0 OR MIT -->
|
|
22
|
+
|
|
23
|
+
`SPDX-License-Identifier: Apache-2.0 OR MIT`
|
|
24
|
+
|
|
25
|
+
Verbatim copies of both licenses are included below:
|
|
26
|
+
|
|
27
|
+
<details><summary>Apache-2.0 Software License</summary>
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Apache License
|
|
31
|
+
Version 2.0, January 2004
|
|
32
|
+
http://www.apache.org/licenses/
|
|
33
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
34
|
+
1. Definitions.
|
|
35
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
36
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
37
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
38
|
+
the copyright owner that is granting the License.
|
|
39
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
40
|
+
other entities that control, are controlled by, or are under common
|
|
41
|
+
control with that entity. For the purposes of this definition,
|
|
42
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
43
|
+
direction or management of such entity, whether by contract or
|
|
44
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
45
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
46
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
47
|
+
exercising permissions granted by this License.
|
|
48
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
49
|
+
including but not limited to software source code, documentation
|
|
50
|
+
source, and configuration files.
|
|
51
|
+
"Object" form shall mean any form resulting from mechanical
|
|
52
|
+
transformation or translation of a Source form, including but
|
|
53
|
+
not limited to compiled object code, generated documentation,
|
|
54
|
+
and conversions to other media types.
|
|
55
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
56
|
+
Object form, made available under the License, as indicated by a
|
|
57
|
+
copyright notice that is included in or attached to the work
|
|
58
|
+
(an example is provided in the Appendix below).
|
|
59
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
60
|
+
form, that is based on (or derived from) the Work and for which the
|
|
61
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
62
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
63
|
+
of this License, Derivative Works shall not include works that remain
|
|
64
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
65
|
+
the Work and Derivative Works thereof.
|
|
66
|
+
"Contribution" shall mean any work of authorship, including
|
|
67
|
+
the original version of the Work and any modifications or additions
|
|
68
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
69
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
70
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
71
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
72
|
+
means any form of electronic, verbal, or written communication sent
|
|
73
|
+
to the Licensor or its representatives, including but not limited to
|
|
74
|
+
communication on electronic mailing lists, source code control systems,
|
|
75
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
76
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
77
|
+
excluding communication that is conspicuously marked or otherwise
|
|
78
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
79
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
80
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
81
|
+
subsequently incorporated within the Work.
|
|
82
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
83
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
84
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
85
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
86
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
87
|
+
Work and such Derivative Works in Source or Object form.
|
|
88
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
89
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
90
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
91
|
+
(except as stated in this section) patent license to make, have made,
|
|
92
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
93
|
+
where such license applies only to those patent claims licensable
|
|
94
|
+
by such Contributor that are necessarily infringed by their
|
|
95
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
96
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
97
|
+
institute patent litigation against any entity (including a
|
|
98
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
99
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
100
|
+
or contributory patent infringement, then any patent licenses
|
|
101
|
+
granted to You under this License for that Work shall terminate
|
|
102
|
+
as of the date such litigation is filed.
|
|
103
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
104
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
105
|
+
modifications, and in Source or Object form, provided that You
|
|
106
|
+
meet the following conditions:
|
|
107
|
+
(a) You must give any other recipients of the Work or
|
|
108
|
+
Derivative Works a copy of this License; and
|
|
109
|
+
(b) You must cause any modified files to carry prominent notices
|
|
110
|
+
stating that You changed the files; and
|
|
111
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
112
|
+
that You distribute, all copyright, patent, trademark, and
|
|
113
|
+
attribution notices from the Source form of the Work,
|
|
114
|
+
excluding those notices that do not pertain to any part of
|
|
115
|
+
the Derivative Works; and
|
|
116
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
117
|
+
distribution, then any Derivative Works that You distribute must
|
|
118
|
+
include a readable copy of the attribution notices contained
|
|
119
|
+
within such NOTICE file, excluding those notices that do not
|
|
120
|
+
pertain to any part of the Derivative Works, in at least one
|
|
121
|
+
of the following places: within a NOTICE text file distributed
|
|
122
|
+
as part of the Derivative Works; within the Source form or
|
|
123
|
+
documentation, if provided along with the Derivative Works; or,
|
|
124
|
+
within a display generated by the Derivative Works, if and
|
|
125
|
+
wherever such third-party notices normally appear. The contents
|
|
126
|
+
of the NOTICE file are for informational purposes only and
|
|
127
|
+
do not modify the License. You may add Your own attribution
|
|
128
|
+
notices within Derivative Works that You distribute, alongside
|
|
129
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
130
|
+
that such additional attribution notices cannot be construed
|
|
131
|
+
as modifying the License.
|
|
132
|
+
You may add Your own copyright statement to Your modifications and
|
|
133
|
+
may provide additional or different license terms and conditions
|
|
134
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
135
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
136
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
137
|
+
the conditions stated in this License.
|
|
138
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
139
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
140
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
141
|
+
this License, without any additional terms or conditions.
|
|
142
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
143
|
+
the terms of any separate license agreement you may have executed
|
|
144
|
+
with Licensor regarding such Contributions.
|
|
145
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
146
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
147
|
+
except as required for reasonable and customary use in describing the
|
|
148
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
149
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
150
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
151
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
152
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
153
|
+
implied, including, without limitation, any warranties or conditions
|
|
154
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
155
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
156
|
+
appropriateness of using or redistributing the Work and assume any
|
|
157
|
+
risks associated with Your exercise of permissions under this License.
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
170
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
171
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
172
|
+
or other liability obligations and/or rights consistent with this
|
|
173
|
+
License. However, in accepting such obligations, You may act only
|
|
174
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
175
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
176
|
+
defend, and hold each Contributor harmless for any liability
|
|
177
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
178
|
+
of your accepting any such warranty or additional liability.
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
</details>
|
|
183
|
+
|
|
184
|
+
<details><summary>MIT Software License</summary>
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
188
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
189
|
+
in the Software without restriction, including without limitation the rights
|
|
190
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
191
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
192
|
+
furnished to do so, subject to the following conditions:
|
|
193
|
+
The above copyright notice and this permission notice shall be included in
|
|
194
|
+
all copies or substantial portions of the Software.
|
|
195
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
196
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
197
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
198
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
199
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
200
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
201
|
+
THE SOFTWARE.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
</details>
|
package/README.md
CHANGED
|
@@ -1,172 +1,179 @@
|
|
|
1
1
|
# @storacha/clawracha
|
|
2
2
|
|
|
3
|
-
OpenClaw
|
|
3
|
+
Sync [OpenClaw](https://github.com/openclaw/openclaw) agent workspaces to [Storacha](https://storacha.network) — decentralized, encrypted, multi-device.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
No servers. No accounts to share. Just UCAN delegations and content-addressed data.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## What It Does
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Clawracha watches your agent's workspace for file changes and syncs them to a Storacha Space via [UCN Pail](https://github.com/storacha/ucn) — a CRDT key-value store backed by merkle clocks. Multiple devices can sync the same workspace without conflicts.
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
11
|
+
- **Regular files** → content-addressed via UnixFS, stored as CIDs
|
|
12
|
+
- **Markdown files** → CRDT merge via [md-merge](https://github.com/storacha/md-merge) — concurrent edits merge automatically, no conflicts
|
|
13
|
+
- **Private spaces** → end-to-end encrypted via KMS before upload
|
|
14
|
+
- **Multi-device** → delegation bundles let you grant access to other devices
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### 1. Install
|
|
17
19
|
|
|
18
20
|
```bash
|
|
19
|
-
|
|
21
|
+
# In your OpenClaw project
|
|
22
|
+
pnpm add @storacha/clawracha
|
|
20
23
|
```
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
Add to your OpenClaw config (`openclaw.config.json` or equivalent):
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"plugins": {
|
|
30
|
+
"clawracha": {
|
|
31
|
+
"enabled": true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
### 2. Initialize
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
Generate an agent identity for your workspace:
|
|
29
40
|
|
|
30
41
|
```bash
|
|
31
|
-
openclaw clawracha init --agent
|
|
42
|
+
openclaw clawracha init --agent myagent
|
|
32
43
|
```
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Step 2: Choose your path
|
|
45
|
+
This creates a `.storacha/config.json` in the agent's workspace with a fresh Ed25519 keypair.
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
### 3. Set Up a New Workspace
|
|
39
48
|
|
|
40
49
|
```bash
|
|
41
|
-
openclaw clawracha setup
|
|
50
|
+
openclaw clawracha setup --agent myagent
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
This will:
|
|
54
|
+
1. Ask for your Storacha email (sends a confirmation link)
|
|
55
|
+
2. Wait for email confirmation and payment plan verification
|
|
56
|
+
3. Ask you to choose **Public** or **Private (encrypted)** access
|
|
57
|
+
4. Create a new Storacha Space
|
|
58
|
+
5. Generate delegations (upload, name, plan)
|
|
59
|
+
6. Do an initial sync of existing workspace files
|
|
60
|
+
7. Start watching for changes
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
### 4. Add Another Device
|
|
63
|
+
|
|
64
|
+
On the **existing device** (the one already set up):
|
|
47
65
|
|
|
48
66
|
```bash
|
|
49
|
-
openclaw clawracha
|
|
67
|
+
openclaw clawracha grant did:key:z6Mk... --agent myagent
|
|
50
68
|
```
|
|
51
69
|
|
|
52
|
-
|
|
70
|
+
This outputs a delegation bundle (a base64 string). Copy it.
|
|
53
71
|
|
|
54
|
-
|
|
72
|
+
On the **new device**:
|
|
55
73
|
|
|
56
74
|
```bash
|
|
57
|
-
openclaw clawracha
|
|
75
|
+
openclaw clawracha init --agent myagent
|
|
76
|
+
openclaw clawracha join <paste-bundle-here> --agent myagent
|
|
58
77
|
```
|
|
59
78
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
### Check status
|
|
79
|
+
The new device pulls all existing files and starts syncing.
|
|
63
80
|
|
|
64
|
-
|
|
65
|
-
openclaw clawracha status --agent <id>
|
|
66
|
-
```
|
|
81
|
+
### Interactive Setup
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
Don't want to remember the steps? Use the guided flow:
|
|
69
84
|
|
|
70
85
|
```bash
|
|
71
|
-
openclaw
|
|
86
|
+
openclaw clawracha onboard --agent myagent
|
|
72
87
|
```
|
|
73
88
|
|
|
74
|
-
|
|
89
|
+
This walks you through init → setup/join interactively.
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
Workspace Files UCN Pail KV Store
|
|
78
|
-
================ ================
|
|
79
|
-
/AGENTS.md ────► "AGENTS.md" → bafk...xyz
|
|
80
|
-
/SOUL.md ────► "SOUL.md" → bafk...abc
|
|
81
|
-
/memory/2026-02-10.md ────► "memory/2026-02-10.md" → bafk...123
|
|
82
|
-
```
|
|
91
|
+
## CLI Commands
|
|
83
92
|
|
|
84
|
-
|
|
93
|
+
All commands require `--agent <id>` to specify which agent workspace to operate on.
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
| Command | Description |
|
|
96
|
+
|---------|-------------|
|
|
97
|
+
| `init --agent <id>` | Generate agent identity (Ed25519 keypair) |
|
|
98
|
+
| `setup --agent <id>` | Create a new Storacha Space via login |
|
|
99
|
+
| `join <bundle> --agent <id>` | Join an existing workspace from a delegation bundle |
|
|
100
|
+
| `grant <DID> --agent <id>` | Create a delegation bundle for another device |
|
|
101
|
+
| `status --agent <id>` | Show sync status (delegations, space, running state) |
|
|
102
|
+
| `inspect --agent <id>` | Debug internal state (pail entries, pending ops, revisions) |
|
|
103
|
+
| `onboard --agent <id>` | Interactive guided setup |
|
|
92
104
|
|
|
93
|
-
|
|
105
|
+
### Grant Options
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
enabled: true
|
|
102
|
-
config:
|
|
103
|
-
watchPatterns:
|
|
104
|
-
- "**/*.md"
|
|
105
|
-
ignorePatterns:
|
|
106
|
-
- ".git"
|
|
107
|
-
- "node_modules"
|
|
108
|
-
- ".storacha"
|
|
107
|
+
```bash
|
|
108
|
+
# Output bundle as base64 to stdout (default)
|
|
109
|
+
openclaw clawracha grant did:key:z6Mk... --agent myagent
|
|
110
|
+
|
|
111
|
+
# Write bundle to a file instead
|
|
112
|
+
openclaw clawracha grant did:key:z6Mk... --agent myagent -o bundle.car
|
|
109
113
|
```
|
|
110
114
|
|
|
111
115
|
## Agent Tools
|
|
112
116
|
|
|
113
|
-
|
|
117
|
+
When the plugin is running, agents get two MCP tools:
|
|
114
118
|
|
|
115
|
-
-
|
|
116
|
-
-
|
|
119
|
+
- **`storacha_sync_status`** — Check current sync state (running, last sync, entry count, pending changes)
|
|
120
|
+
- **`storacha_sync_now`** — Trigger an immediate sync cycle
|
|
117
121
|
|
|
118
|
-
##
|
|
122
|
+
## How Sync Works
|
|
119
123
|
|
|
124
|
+
1. **File watcher** (chokidar) detects changes in the workspace
|
|
125
|
+
2. Changed files are encoded:
|
|
126
|
+
- Regular files → UnixFS DAG blocks
|
|
127
|
+
- Markdown files → CRDT entry via md-merge (RGA tree + event history)
|
|
128
|
+
- Private spaces → encrypted before encoding
|
|
129
|
+
3. Changes become pail operations (put/del)
|
|
130
|
+
4. Operations are batched into a UCN revision and published
|
|
131
|
+
5. All blocks are packed into a CAR file and uploaded to Storacha
|
|
132
|
+
6. Remote changes from other devices are pulled, diffed, and applied locally
|
|
133
|
+
|
|
134
|
+
See [docs/architecture.md](docs/architecture.md) for the full technical deep-dive and [docs/reference.md](docs/reference.md) for hidden features, edge cases, and troubleshooting.
|
|
135
|
+
|
|
136
|
+
## Configuration
|
|
137
|
+
|
|
138
|
+
In your OpenClaw plugin config:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"plugins": {
|
|
143
|
+
"clawracha": {
|
|
144
|
+
"enabled": true,
|
|
145
|
+
"watchPatterns": ["**/*"],
|
|
146
|
+
"ignorePatterns": [".git", "node_modules", ".storacha"]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
120
150
|
```
|
|
121
|
-
┌─────────────────────────────────────────────────────────┐
|
|
122
|
-
│ OpenClaw Agent Workspace │
|
|
123
|
-
│ ┌─────────────────┐ ┌─────────────────┐ │
|
|
124
|
-
│ │ Workspace │◄───►│ File Watcher │ │
|
|
125
|
-
│ │ *.md files │ │ (chokidar) │ │
|
|
126
|
-
│ └─────────────────┘ └────────┬────────┘ │
|
|
127
|
-
│ │ │ │
|
|
128
|
-
│ ▼ ▼ │
|
|
129
|
-
│ ┌─────────────────┐ ┌─────────────────┐ │
|
|
130
|
-
│ │ .storacha/ │ │ Sync Engine │ │
|
|
131
|
-
│ │ ├─ config.json │◄───►│ (UCN Pail) │ │
|
|
132
|
-
│ │ └─ blocks/ │ └────────┬────────┘ │
|
|
133
|
-
│ └─────────────────┘ │ │
|
|
134
|
-
└───────────────────────────────────┼─────────────────────┘
|
|
135
|
-
│
|
|
136
|
-
▼ publish/resolve
|
|
137
|
-
┌───────────────────────────────────────────────────────┐
|
|
138
|
-
│ Storacha Network │
|
|
139
|
-
│ ┌───────────────────┐ ┌───────────────────────────┐ │
|
|
140
|
-
│ │ UCN Rendezvous │ │ Storage Nodes │ │
|
|
141
|
-
│ │ (clock/head) │ │ (blob storage) │ │
|
|
142
|
-
│ └───────────────────┘ └───────────────────────────┘ │
|
|
143
|
-
└───────────────────────────────────────────────────────┘
|
|
144
|
-
```
|
|
145
151
|
|
|
146
|
-
|
|
152
|
+
| Option | Default | Description |
|
|
153
|
+
|--------|---------|-------------|
|
|
154
|
+
| `enabled` | `false` | Enable/disable the sync plugin |
|
|
155
|
+
| `watchPatterns` | `["**/*"]` | Glob patterns for files to sync |
|
|
156
|
+
| `ignorePatterns` | `[".git", "node_modules", ".storacha"]` | Glob patterns to exclude |
|
|
157
|
+
|
|
158
|
+
## Public vs Private Spaces
|
|
159
|
+
|
|
160
|
+
During setup, you choose the access type:
|
|
147
161
|
|
|
148
|
-
|
|
162
|
+
- **Public** — Files are stored as plaintext on IPFS/Filecoin. Anyone with the CID can access them.
|
|
163
|
+
- **Private (encrypted)** — Files are encrypted via Storacha's KMS before upload. Only devices with the proper delegations can decrypt.
|
|
149
164
|
|
|
150
|
-
-
|
|
151
|
-
- `blocks/` - Local block cache (NOT synced)
|
|
165
|
+
Private spaces use `@storacha/encrypt-upload-client` with Google KMS for key management. The plan delegation grants KMS access, and decrypt delegations are scoped per-CID with 15-minute expiry.
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
## Requirements
|
|
154
168
|
|
|
155
|
-
|
|
169
|
+
- Node.js ≥ 20
|
|
170
|
+
- OpenClaw ≥ 2026.0.0
|
|
171
|
+
- A [Storacha account](https://console.storacha.network) with an active payment plan
|
|
156
172
|
|
|
157
|
-
|
|
173
|
+
## Docs
|
|
158
174
|
|
|
159
|
-
- [
|
|
160
|
-
- [
|
|
161
|
-
- [x] File encoder (UnixFS)
|
|
162
|
-
- [x] Differ (local ↔ pail)
|
|
163
|
-
- [x] Sync engine (UCN Pail batch)
|
|
164
|
-
- [x] File watcher
|
|
165
|
-
- [x] OpenClaw plugin integration
|
|
166
|
-
- [ ] CAR upload to Storacha
|
|
167
|
-
- [ ] Remote file download/apply
|
|
168
|
-
- [ ] Encryption (encrypt-upload-client)
|
|
169
|
-
- [ ] Full test coverage
|
|
175
|
+
- **[Architecture Guide](docs/architecture.md)** — How it works under the hood (sync lifecycle, CRDT merge, blockstore tiers, encryption, delegation model)
|
|
176
|
+
- **[Reference](docs/reference.md)** — `.clawrachaignore`, `inspect` command, delegation encoding, troubleshooting
|
|
170
177
|
|
|
171
178
|
## License
|
|
172
179
|
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EACV,YAAY,EAEZ,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoB3C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAS9B;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,GACpD,OAAO,CAAC,IAAI,CAAC,CAqCf;AAID,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACvC,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GACnE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAID,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBnE;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACvC,aAAa,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,GACrD,OAAO,CAAC,WAAW,CAAC,CAsGtB;AA2BD,wBAAsB,MAAM,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACvC,aAAa,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,GACrD,OAAO,CAAC,UAAU,CAAC,CAkErB;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,MAAM,IAAI,MAAM,EAAE,GACnC,OAAO,CAAC,UAAU,CAAC,CAyDrB"}
|
package/dist/commands.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as path from "node:path";
|
|
|
9
9
|
import { SyncEngine } from "./sync.js";
|
|
10
10
|
import { FileWatcher } from "./watcher.js";
|
|
11
11
|
import { encodeDelegation, decodeDelegation, } from "./utils/delegation.js";
|
|
12
|
-
import { createStorachaClient } from "./utils/
|
|
12
|
+
import { createStorachaClient } from "./utils/config.js";
|
|
13
13
|
import { createDelegationBundle, extractDelegationBundle, } from "./utils/bundle.js";
|
|
14
14
|
import { Agent, Name } from "@storacha/ucn/pail";
|
|
15
15
|
import { extract } from "@storacha/client/delegation";
|
|
@@ -72,8 +72,8 @@ export async function startWorkspaceSync(workspace, agentId, pluginConfig, initi
|
|
|
72
72
|
if (!deviceConfig || !deviceConfig.setupComplete) {
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
const engine =
|
|
76
|
-
await engine.
|
|
75
|
+
const engine = await SyncEngine.fromConfig(workspace, deviceConfig);
|
|
76
|
+
await engine.start();
|
|
77
77
|
const watcher = new FileWatcher({
|
|
78
78
|
workspace,
|
|
79
79
|
config: {
|
package/dist/handlers/apply.d.ts
CHANGED
|
@@ -4,17 +4,9 @@
|
|
|
4
4
|
* Cycle: operation → publish → return value.
|
|
5
5
|
* Bootstraps with v0Put when no current value exists.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
import type { Block } from "multiformats";
|
|
7
|
+
import type { ValueView, RevisionResult, BlockFetcher } from "@storacha/ucn/pail/api";
|
|
9
8
|
import type { PailOp } from "../types/index.js";
|
|
10
|
-
|
|
11
|
-
export interface ApplyResult {
|
|
12
|
-
current: ValueView | null;
|
|
13
|
-
event: EventBlock | null;
|
|
14
|
-
revisionBlocks: Block[];
|
|
9
|
+
export declare function applyPendingOps(blocks: BlockFetcher, current: ValueView | null, pendingOps: PailOp[]): Promise<RevisionResult & {
|
|
15
10
|
remainingOps: PailOp[];
|
|
16
|
-
}
|
|
17
|
-
export declare function applyPendingOps(blocks: WorkspaceBlockstore, name: NameView, current: ValueView | null, pendingOps: PailOp[], options?: {
|
|
18
|
-
remotes?: ClockConnection[];
|
|
19
|
-
}): Promise<ApplyResult>;
|
|
11
|
+
}>;
|
|
20
12
|
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/handlers/apply.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/handlers/apply.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,SAAS,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,cAAc,GAAG;IAAE,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA4BtD"}
|
package/dist/handlers/apply.js
CHANGED
|
@@ -6,39 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Revision } from "@storacha/ucn/pail";
|
|
8
8
|
import * as Batch from "@storacha/ucn/pail/batch";
|
|
9
|
-
|
|
10
|
-
export async function applyPendingOps(blocks, name, current, pendingOps, options) {
|
|
11
|
-
const revisionBlocks = [];
|
|
9
|
+
export async function applyPendingOps(blocks, current, pendingOps) {
|
|
12
10
|
let ops = [...pendingOps];
|
|
13
|
-
// Local cache so each step can read blocks produced by previous steps
|
|
14
|
-
const cache = new MemoryBlockstore();
|
|
15
|
-
const fetcher = withCache(blocks, cache);
|
|
16
|
-
const accumulate = (additions) => {
|
|
17
|
-
for (const block of additions) {
|
|
18
|
-
cache.put(block);
|
|
19
|
-
}
|
|
20
|
-
revisionBlocks.push(...additions);
|
|
21
|
-
};
|
|
22
11
|
if (!current) {
|
|
23
12
|
const firstPut = ops.find((op) => op.type === "put" && op.value);
|
|
24
13
|
if (firstPut?.value) {
|
|
25
|
-
const result = await Revision.v0Put(
|
|
26
|
-
accumulate(result.additions);
|
|
27
|
-
const pubResult = await Revision.publish(fetcher, name, result.revision, {
|
|
28
|
-
remotes: options?.remotes,
|
|
29
|
-
});
|
|
30
|
-
accumulate(pubResult.additions);
|
|
31
|
-
current = pubResult.value;
|
|
14
|
+
const result = await Revision.v0Put(blocks, firstPut.key, firstPut.value);
|
|
32
15
|
return {
|
|
33
|
-
|
|
34
|
-
event: result.revision.event,
|
|
35
|
-
revisionBlocks,
|
|
16
|
+
...result,
|
|
36
17
|
remainingOps: ops.filter((op) => op !== firstPut),
|
|
37
18
|
};
|
|
38
19
|
}
|
|
39
20
|
throw new Error("No current value or pending puts to initialize with");
|
|
40
21
|
}
|
|
41
|
-
const batcher = await Batch.create(
|
|
22
|
+
const batcher = await Batch.create(blocks, current);
|
|
42
23
|
for (const op of ops) {
|
|
43
24
|
if (op.type === "put" && op.value) {
|
|
44
25
|
await batcher.put(op.key, op.value);
|
|
@@ -48,16 +29,8 @@ export async function applyPendingOps(blocks, name, current, pendingOps, options
|
|
|
48
29
|
}
|
|
49
30
|
}
|
|
50
31
|
const result = await batcher.commit();
|
|
51
|
-
accumulate(result.additions);
|
|
52
|
-
const pubResult = await Revision.publish(fetcher, name, result.revision, {
|
|
53
|
-
remotes: options?.remotes,
|
|
54
|
-
});
|
|
55
|
-
accumulate(pubResult.additions);
|
|
56
|
-
current = pubResult.value;
|
|
57
32
|
return {
|
|
58
|
-
|
|
59
|
-
event: result.revision.event,
|
|
60
|
-
revisionBlocks,
|
|
33
|
+
...result,
|
|
61
34
|
remainingOps: [], // All ops were included in the batch, so none remain
|
|
62
35
|
};
|
|
63
36
|
}
|
|
@@ -7,14 +7,10 @@
|
|
|
7
7
|
* When encryptionConfig is provided (private spaces), content is encrypted
|
|
8
8
|
* before upload via encryptToBlockStream.
|
|
9
9
|
*/
|
|
10
|
-
import { CID } from "multiformats/cid";
|
|
11
10
|
import type { BlockFetcher, ValueView } from "@storacha/ucn/pail/api";
|
|
12
11
|
import type { Block } from "multiformats";
|
|
13
|
-
import type { FileChange, PailOp } from "../types/index.js";
|
|
14
|
-
|
|
15
|
-
/** Callback to persist a block to the CAR file for upload. */
|
|
12
|
+
import type { ContentFetcher, Encoder, FileChange, PailOp } from "../types/index.js";
|
|
13
|
+
/** Callback to persist a block (CAR file, local blockstore, etc). */
|
|
16
14
|
export type BlockSink = (block: Block) => Promise<void>;
|
|
17
|
-
|
|
18
|
-
export type BlockStore = (block: Block) => Promise<void>;
|
|
19
|
-
export declare function processChanges(changes: FileChange[], workspace: string, current: ValueView | null, blocks: BlockFetcher, sink: BlockSink, store?: BlockStore, encryptionConfig?: EncryptionConfig, decrypt?: (cid: CID) => Promise<Uint8Array>): Promise<PailOp[]>;
|
|
15
|
+
export declare function processChanges(changes: FileChange[], workspace: string, current: ValueView | null, blocks: BlockFetcher, sink: BlockSink, encoder: Encoder, contentFetcher: ContentFetcher): Promise<PailOp[]>;
|
|
20
16
|
//# sourceMappingURL=process.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/handlers/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/handlers/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,YAAY,EAEZ,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,UAAU,EACV,MAAM,EACP,MAAM,mBAAmB,CAAC;AAK3B,qEAAqE;AACrE,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAqBxD,wBAAsB,cAAc,CAClC,OAAO,EAAE,UAAU,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,SAAS,GAAG,IAAI,EACzB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CAiFnB"}
|