@fileverse/api 0.0.21 → 0.0.23
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/dist/cli/index.js +33 -41
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/index.js +17 -127
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +116 -330
- package/dist/index.js.map +1 -1
- package/dist/worker.js +85 -258
- package/dist/worker.js.map +1 -1
- package/package.json +6 -5
- package/public/guide.md +286 -0
- package/public/llm.txt +239 -499
- package/dist/cloudflare.js +0 -18259
- package/dist/cloudflare.js.map +0 -1
package/public/llm.txt
CHANGED
|
@@ -1,621 +1,361 @@
|
|
|
1
|
-
# Fileverse API - AI Agent Guide
|
|
1
|
+
# Fileverse API Service - AI Agent Guide
|
|
2
2
|
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
**Skill Name**: fileverse-api
|
|
6
|
-
|
|
7
|
-
## How to use this document
|
|
8
|
-
|
|
9
|
-
Fetch this via GET {SERVER_URL}/llm.txt. Use it to discover the server URL, decide API vs CLI mode, then follow the relevant section below.
|
|
10
|
-
|
|
11
|
-
## Integration checklist
|
|
12
|
-
|
|
13
|
-
1. Get server URL (from the URL you used to fetch this doc, minus /llm.txt) and apiKey (see API Key Configuration).
|
|
14
|
-
2. Try GET {SERVER_URL}/ping. If you get 200 and {"reply":"pong"}, use API mode; otherwise use CLI mode.
|
|
15
|
-
3. In API mode: every request must include apiKey as a query parameter; the path is complete before any query string.
|
|
16
|
-
4. For create/update: extract ddocId from response.data.ddocId (not from the top level of the response).
|
|
17
|
-
5. After create or update, poll GET /api/ddocs/{ddocId}?apiKey=... until syncStatus is "synced" or "failed", then show the link if synced.
|
|
18
|
-
|
|
19
|
-
## Server URL
|
|
20
|
-
|
|
21
|
-
If you fetched this document from a URL (e.g., http://localhost:8001/llm.txt):
|
|
22
|
-
- Your server URL is that URL without the /llm.txt suffix
|
|
23
|
-
- Example: http://localhost:8001/llm.txt → Server URL is http://localhost:8001
|
|
24
|
-
|
|
25
|
-
If this document was provided another way, ask the user for their server URL.
|
|
26
|
-
|
|
27
|
-
## API Key Configuration
|
|
28
|
-
|
|
29
|
-
Before starting, check for stored credentials:
|
|
30
|
-
|
|
31
|
-
1. Look for config file at: ~/.fileverseapirc
|
|
32
|
-
2. If found with valid apiKey, use it automatically
|
|
33
|
-
3. If not found or missing apiKey:
|
|
34
|
-
- Ask user for their Fileverse API key
|
|
35
|
-
- Offer to save it: "Would you like me to save this API key for future sessions?"
|
|
36
|
-
- If yes, create/update ~/.fileverseapirc with JSON: {"apiKey": "...", "serverUrl": "..."}
|
|
37
|
-
|
|
38
|
-
## Connection Strategy
|
|
39
|
-
|
|
40
|
-
After getting the server URL:
|
|
41
|
-
|
|
42
|
-
1. **Try API first**: Attempt GET {SERVER_URL}/ping
|
|
43
|
-
2. **If successful** (response: {"reply":"pong"}) → Use API Mode
|
|
44
|
-
3. **If connection fails** (timeout, refused, unreachable) → Switch to CLI Mode
|
|
45
|
-
|
|
46
|
-
In API mode, every request must include apiKey as a query parameter; the path is complete before any query string.
|
|
47
|
-
|
|
48
|
-
When switching to CLI mode, inform the user:
|
|
49
|
-
"I can't reach your server directly (localhost isn't accessible from here). I'll help you using CLI commands instead - just run them and share the output with me."
|
|
3
|
+
> This service allows you to sync your local .md files to https://ddocs.new, an alternate document editor that's end-to-end encrypted and fully private. Documents created on ddocs.new are commonly called **ddocs** or **fileverse docs**. Each document has a unique randomly generated `ddocId` that can be used to read, edit, or delete a document.
|
|
50
4
|
|
|
51
5
|
---
|
|
52
6
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## All API endpoints
|
|
56
|
-
|
|
57
|
-
| Method | Path | Auth | Key params/body |
|
|
58
|
-
|--------|------|------|-----------------|
|
|
59
|
-
| GET | /ping | No | - |
|
|
60
|
-
| GET | /api/ddocs | apiKey | limit, skip |
|
|
61
|
-
| GET | /api/ddocs/{ddocId} | apiKey | - |
|
|
62
|
-
| POST | /api/ddocs | apiKey | JSON: {title, content} or form-data: file |
|
|
63
|
-
| PUT | /api/ddocs/{ddocId} | apiKey | JSON: {title?, content?} or form-data: file |
|
|
64
|
-
| DELETE | /api/ddocs/{ddocId} | apiKey | - |
|
|
65
|
-
| GET | /api/folders | apiKey | limit, skip |
|
|
66
|
-
| POST | /api/folders | apiKey | body: see Create Folder |
|
|
67
|
-
| GET | /api/folders/{folderRef}/{folderId} | apiKey | - |
|
|
68
|
-
| GET | /api/search | apiKey | q (required), limit, skip |
|
|
69
|
-
| GET | /api/events/failed | apiKey | - |
|
|
70
|
-
| POST | /api/events/retry-failed | apiKey | - |
|
|
71
|
-
| POST | /api/events/{id}/retry | apiKey | - |
|
|
72
|
-
|
|
73
|
-
## All ddctl commands
|
|
74
|
-
|
|
75
|
-
| Command | Purpose | Key options |
|
|
76
|
-
|---------|---------|-------------|
|
|
77
|
-
| ddctl list | List ddocs | -l/--limit, -s/--skip |
|
|
78
|
-
| ddctl get <ddocId> | Get document metadata | - |
|
|
79
|
-
| ddctl view <ddocId> | View content preview | -n/--lines (default 10) |
|
|
80
|
-
| ddctl create <filepath> | Create from file | title = filename; file cannot be empty |
|
|
81
|
-
| ddctl update <ddocId> | Update ddoc | -f/--file <path> or opens editor |
|
|
82
|
-
| ddctl download <ddocId> | Download to file | -o/--output <filename> |
|
|
83
|
-
| ddctl delete <ddocIds...> | Delete one or more | space-separated ids |
|
|
84
|
-
| ddctl events list-failed | List failed worker events | - |
|
|
85
|
-
| ddctl events retry <eventId> | Retry one failed event | - |
|
|
86
|
-
| ddctl events retry-all | Retry all failed events | - |
|
|
7
|
+
## Agents - Setup (Device)
|
|
87
8
|
|
|
88
|
-
|
|
9
|
+
There are different ways to connect to the Fileverse APIs. You need to get the `<SERVER_URL>` from the user.
|
|
89
10
|
|
|
90
|
-
|
|
11
|
+
### MCP
|
|
91
12
|
|
|
92
|
-
The
|
|
13
|
+
The fastest way to start is by adding the Fileverse MCP server to your client.
|
|
93
14
|
|
|
94
|
-
|
|
15
|
+
#### Claude Code
|
|
95
16
|
|
|
96
|
-
|
|
17
|
+
```bash
|
|
18
|
+
claude mcp add --transport http fileverse-api <SERVER_URL>
|
|
19
|
+
```
|
|
97
20
|
|
|
98
|
-
|
|
21
|
+
#### Cursor
|
|
99
22
|
|
|
100
|
-
Add to your
|
|
23
|
+
Add this to your `~/.cursor/config/mcp.json`:
|
|
101
24
|
|
|
102
25
|
```json
|
|
103
26
|
{
|
|
104
27
|
"mcpServers": {
|
|
105
28
|
"fileverse-api": {
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"FILEVERSE_API_KEY": "your-api-key",
|
|
109
|
-
"FILEVERSE_SERVER_URL": "http://localhost:8001"
|
|
110
|
-
}
|
|
29
|
+
"type": "streamable-http",
|
|
30
|
+
"url": "<SERVER_URL>"
|
|
111
31
|
}
|
|
112
32
|
}
|
|
113
33
|
}
|
|
114
34
|
```
|
|
115
35
|
|
|
116
|
-
|
|
36
|
+
#### Windsurf
|
|
117
37
|
|
|
118
|
-
|
|
38
|
+
Add this to your MCP config:
|
|
119
39
|
|
|
120
|
-
|
|
121
|
-
|------|-------------|
|
|
122
|
-
| fileverse_list_documents | List documents with pagination |
|
|
123
|
-
| fileverse_get_document | Get a single document by ddocId |
|
|
124
|
-
| fileverse_create_document | Create document and wait for sync (returns link) |
|
|
125
|
-
| fileverse_update_document | Update document and wait for sync (returns link) |
|
|
126
|
-
| fileverse_delete_document | Delete a document |
|
|
127
|
-
| fileverse_search_documents | Search documents by text query |
|
|
128
|
-
| fileverse_get_sync_status | Check sync status and link of a document |
|
|
129
|
-
| fileverse_retry_failed_events | Retry all failed blockchain sync events |
|
|
130
|
-
|
|
131
|
-
Create and update tools automatically poll until blockchain sync completes, so the agent does not need to implement polling logic.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
# Response Schemas
|
|
136
|
-
|
|
137
|
-
## Document
|
|
138
|
-
|
|
139
|
-
Fields returned by GET /api/ddocs/{ddocId} and in list/search results:
|
|
140
|
-
|
|
141
|
-
```
|
|
40
|
+
```json
|
|
142
41
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
onchainVersion: number, // Version published to blockchain
|
|
150
|
-
isDeleted: number, // 0 = active, 1 = deleted
|
|
151
|
-
onChainFileId: number | null,
|
|
152
|
-
portalAddress: string,
|
|
153
|
-
createdAt: string, // ISO timestamp
|
|
154
|
-
updatedAt: string // ISO timestamp
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"fileverse-api": {
|
|
44
|
+
"type": "streamable-http",
|
|
45
|
+
"url": "<SERVER_URL>"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
155
48
|
}
|
|
156
49
|
```
|
|
157
50
|
|
|
158
|
-
|
|
51
|
+
Note: if for some reason MCP is not supported you can fallback to API and check the documentation on the guide.md for exact API Docs.
|
|
159
52
|
|
|
160
|
-
|
|
53
|
+
---
|
|
161
54
|
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
ddocs: Document[],
|
|
165
|
-
total: number,
|
|
166
|
-
hasNext: boolean
|
|
167
|
-
}
|
|
168
|
-
```
|
|
55
|
+
## Agents - Setup (Browser)
|
|
169
56
|
|
|
170
|
-
|
|
57
|
+
### MCP
|
|
171
58
|
|
|
172
|
-
|
|
59
|
+
#### ChatGPT
|
|
173
60
|
|
|
174
|
-
|
|
175
|
-
{
|
|
176
|
-
nodes: Document[], // Note: "nodes" not "ddocs"
|
|
177
|
-
total: number,
|
|
178
|
-
hasNext: boolean
|
|
179
|
-
}
|
|
180
|
-
```
|
|
61
|
+
ChatGPT supports MCP connectors via **Developer Mode** (available for Pro, Plus, Team, Enterprise, and Edu users).
|
|
181
62
|
|
|
182
|
-
|
|
63
|
+
**Setup steps:**
|
|
183
64
|
|
|
184
|
-
|
|
65
|
+
1. Open ChatGPT > Settings > Apps > Advanced > toggle Developer Mode on
|
|
66
|
+
2. Go to Settings > Apps > click Create
|
|
67
|
+
3. Fill in:
|
|
68
|
+
- Name: Fileverse API
|
|
69
|
+
- Server URL: `https://<your-server-url>/` (e.g. `https://abc123.ngrok.app/mcp`)
|
|
70
|
+
4. Check **"I trust this provider"**
|
|
71
|
+
5. Click **Create**
|
|
185
72
|
|
|
186
|
-
|
|
187
|
-
{
|
|
188
|
-
message: string,
|
|
189
|
-
data: Document // Extract ddocId from data.ddocId
|
|
190
|
-
}
|
|
191
|
-
```
|
|
73
|
+
**Using in a chat:**
|
|
192
74
|
|
|
193
|
-
|
|
75
|
+
1. Start a new chat
|
|
76
|
+
2. Ask it to create a .md file and store it on Fileverse
|
|
194
77
|
|
|
195
|
-
|
|
78
|
+
#### Claude (Web)
|
|
196
79
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
fileId: string,
|
|
203
|
-
portalAddress: string,
|
|
204
|
-
status: "pending" | "processing" | "processed" | "failed",
|
|
205
|
-
retryCount: number,
|
|
206
|
-
lastError: string | null,
|
|
207
|
-
userOpHash: string | null
|
|
208
|
-
}
|
|
209
|
-
```
|
|
80
|
+
1. Open Claude > Settings > Connector > Add Custom Connector
|
|
81
|
+
2. Fill in:
|
|
82
|
+
- Name: Fileverse API
|
|
83
|
+
- Server URL: `https://<your-server-url>/` (e.g. `https://abc123.ngrok.app/`)
|
|
84
|
+
3. Click **Add**
|
|
210
85
|
|
|
211
86
|
---
|
|
212
87
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Use this when you cannot reach the user's server (localhost, firewall, etc.).
|
|
216
|
-
You generate commands, user runs them and shares output with you.
|
|
217
|
-
|
|
218
|
-
## Installation and invocation
|
|
88
|
+
## MCP Tools Reference
|
|
219
89
|
|
|
220
|
-
|
|
90
|
+
The Fileverse MCP server exposes **8 tools**. All tools return JSON responses.
|
|
221
91
|
|
|
222
|
-
|
|
223
|
-
npm install -g @fileverse/api
|
|
224
|
-
npx @fileverse/api --apiKey <key> --rpcUrl <url>
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
The package exposes the ddctl binary. After npm install -g @fileverse/api, run ddctl <command>. Without global install: npx -p @fileverse/api ddctl <command>.
|
|
228
|
-
|
|
229
|
-
## CLI Commands Reference
|
|
230
|
-
|
|
231
|
-
### List Documents
|
|
232
|
-
```bash
|
|
233
|
-
ddctl list
|
|
234
|
-
ddctl list -l 10 -s 20
|
|
235
|
-
ddctl list --limit 10 --skip 20
|
|
236
|
-
```
|
|
92
|
+
### fileverse_list_documents
|
|
237
93
|
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
ddctl get <ddocId>
|
|
241
|
-
```
|
|
242
|
-
Shows metadata including the link (if synced to blockchain).
|
|
94
|
+
List documents stored in Fileverse. Returns an array of documents with their metadata and sync status.
|
|
243
95
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
```
|
|
250
|
-
Default preview is 10 lines.
|
|
96
|
+
**Parameters:**
|
|
97
|
+
| Name | Type | Required | Description |
|
|
98
|
+
|--------|--------|----------|--------------------------------------------|
|
|
99
|
+
| limit | number | No | Maximum number of documents to return (default: 10) |
|
|
100
|
+
| skip | number | No | Number of documents to skip (for pagination) |
|
|
251
101
|
|
|
252
|
-
|
|
253
|
-
```
|
|
254
|
-
|
|
102
|
+
**Returns:**
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"ddocs": [{ "ddocId": "...", "title": "...", "content": "...", "syncStatus": "synced", "link": "..." }],
|
|
106
|
+
"total": 42,
|
|
107
|
+
"hasNext": true
|
|
108
|
+
}
|
|
255
109
|
```
|
|
256
|
-
Creates document from file. Title is derived from filename. File content cannot be empty.
|
|
257
110
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
ddctl update <ddocId>
|
|
263
|
-
```
|
|
264
|
-
Without --file opens in editor (uses EDITOR env or vi).
|
|
111
|
+
**Usage notes:**
|
|
112
|
+
- Use `skip` and `limit` to paginate through large document sets
|
|
113
|
+
- Check `hasNext` to determine if more documents are available
|
|
114
|
+
- Documents are returned with full metadata including `syncStatus` and `link`
|
|
265
115
|
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
ddctl download <ddocId>
|
|
269
|
-
ddctl download <ddocId> -o myfile.md
|
|
270
|
-
ddctl download <ddocId> --output myfile.md
|
|
271
|
-
```
|
|
272
|
-
Output supports markdown.
|
|
116
|
+
---
|
|
273
117
|
|
|
274
|
-
###
|
|
275
|
-
```bash
|
|
276
|
-
ddctl delete <ddocId>
|
|
277
|
-
ddctl delete <id1> <id2> <id3>
|
|
278
|
-
```
|
|
279
|
-
One or more space-separated ddoc IDs.
|
|
118
|
+
### fileverse_get_document
|
|
280
119
|
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
ddctl events list-failed
|
|
284
|
-
ddctl events retry <eventId>
|
|
285
|
-
ddctl events retry-all
|
|
286
|
-
```
|
|
287
|
-
If sync is stuck, run ddctl events list-failed then ddctl events retry <id> or ddctl events retry-all.
|
|
120
|
+
Get a single document by its `ddocId`. Returns the full document including content, sync status, and blockchain link.
|
|
288
121
|
|
|
289
|
-
|
|
122
|
+
**Parameters:**
|
|
123
|
+
| Name | Type | Required | Description |
|
|
124
|
+
|--------|--------|----------|----------------------------|
|
|
125
|
+
| ddocId | string | Yes | The unique document identifier |
|
|
290
126
|
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
|
|
127
|
+
**Returns:**
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"ddocId": "abc123",
|
|
131
|
+
"title": "My Document",
|
|
132
|
+
"content": "# Hello World\n\nThis is my document.",
|
|
133
|
+
"syncStatus": "synced",
|
|
134
|
+
"link": "https://ddocs.new/d/abc123#encryptionKey",
|
|
135
|
+
"localVersion": 3,
|
|
136
|
+
"onchainVersion": 3,
|
|
137
|
+
"createdAt": "2025-01-01T00:00:00.000Z",
|
|
138
|
+
"updatedAt": "2025-01-02T00:00:00.000Z"
|
|
139
|
+
}
|
|
295
140
|
```
|
|
296
|
-
Repeat get until syncStatus is "synced"; then the link field shows the public URL.
|
|
297
141
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
ddctl view <ddocId>
|
|
302
|
-
ddctl update <ddocId> --file updated.md
|
|
303
|
-
ddctl get <ddocId>
|
|
304
|
-
```
|
|
142
|
+
**Usage notes:**
|
|
143
|
+
- The `link` field is only available when `syncStatus` is `"synced"`
|
|
144
|
+
- The link contains an encryption key fragment after `#` for end-to-end encryption
|
|
305
145
|
|
|
306
146
|
---
|
|
307
147
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
Use this when GET /ping succeeds. You make HTTP requests directly to the server.
|
|
311
|
-
|
|
312
|
-
## Authentication & URL Construction
|
|
313
|
-
|
|
314
|
-
CRITICAL: The apiKey is a query parameter that goes at the END of the URL, after the complete path.
|
|
315
|
-
|
|
316
|
-
URL Structure: {SERVER_URL}{PATH}?apiKey={API_KEY}&{OTHER_PARAMS}
|
|
317
|
-
|
|
318
|
-
Step-by-step URL construction:
|
|
319
|
-
1. Start with the server URL: http://localhost:8001
|
|
320
|
-
2. Add the complete path: /api/ddocs/abc123
|
|
321
|
-
3. Add ? and the apiKey: ?apiKey=your-key
|
|
322
|
-
4. Add any other params with &: &limit=10
|
|
323
|
-
|
|
324
|
-
CORRECT examples:
|
|
325
|
-
- GET http://localhost:8001/api/ddocs?apiKey=xxx
|
|
326
|
-
- GET http://localhost:8001/api/ddocs/abc123?apiKey=xxx
|
|
327
|
-
- PUT http://localhost:8001/api/ddocs/abc123?apiKey=xxx
|
|
328
|
-
- GET http://localhost:8001/api/ddocs?apiKey=xxx&limit=10&skip=0
|
|
329
|
-
|
|
330
|
-
WRONG (do NOT do this):
|
|
331
|
-
- GET http://localhost:8001/api/ddocs?apiKey=xxx/abc123 ← WRONG: path after query param
|
|
332
|
-
- GET http://localhost:8001/api?apiKey=xxx/ddocs/abc123 ← WRONG: path after query param
|
|
333
|
-
|
|
334
|
-
The query string (?apiKey=...) must ALWAYS come after the full path is complete.
|
|
335
|
-
|
|
336
|
-
## Common mistakes
|
|
337
|
-
|
|
338
|
-
- Putting path segments after ?apiKey=... (wrong).
|
|
339
|
-
- Forgetting that create/update return data.ddocId, not top-level ddocId; always use response.data.ddocId.
|
|
340
|
-
- Not polling after create/update until syncStatus is "synced" or "failed".
|
|
341
|
-
|
|
342
|
-
## Important: Sync Status Polling
|
|
343
|
-
|
|
344
|
-
When you create or update a document, it syncs to blockchain asynchronously:
|
|
345
|
-
|
|
346
|
-
- **pending**: Saved locally, blockchain sync in progress
|
|
347
|
-
- **synced**: Published to blockchain (link field available)
|
|
348
|
-
- **failed**: Sync failed
|
|
148
|
+
### fileverse_create_document
|
|
349
149
|
|
|
350
|
-
|
|
150
|
+
Create a new document and wait for blockchain sync. Returns the document with its sync status and public link once synced.
|
|
351
151
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
6. If "failed", inform user of sync failure
|
|
152
|
+
**Parameters:**
|
|
153
|
+
| Name | Type | Required | Description |
|
|
154
|
+
|---------|--------|----------|------------------------------------------|
|
|
155
|
+
| title | string | Yes | Document title |
|
|
156
|
+
| content | string | Yes | Document content (plain text or markdown) |
|
|
358
157
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
## API Reference
|
|
362
|
-
|
|
363
|
-
Base: {SERVER_URL}
|
|
364
|
-
|
|
365
|
-
### Health Check (No Auth)
|
|
366
|
-
GET /ping
|
|
367
|
-
Response: {"reply":"pong"}
|
|
368
|
-
|
|
369
|
-
### List Documents
|
|
370
|
-
GET /api/ddocs?apiKey={API_KEY}&limit=10&skip=0
|
|
371
|
-
|
|
372
|
-
Response:
|
|
373
|
-
{
|
|
374
|
-
"ddocs": [...],
|
|
375
|
-
"total": 100,
|
|
376
|
-
"hasNext": true
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
### Get Document
|
|
380
|
-
GET /api/ddocs/{ddocId}?apiKey={API_KEY}
|
|
381
|
-
|
|
382
|
-
Response:
|
|
158
|
+
**Returns:**
|
|
159
|
+
```json
|
|
383
160
|
{
|
|
384
|
-
"ddocId": "
|
|
385
|
-
"title": "
|
|
161
|
+
"ddocId": "newDoc123",
|
|
162
|
+
"title": "My New Document",
|
|
386
163
|
"content": "...",
|
|
387
|
-
"syncStatus": "
|
|
388
|
-
"link": "https
|
|
389
|
-
...
|
|
164
|
+
"syncStatus": "synced",
|
|
165
|
+
"link": "https://ddocs.new/d/newDoc123#encryptionKey"
|
|
390
166
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
### Create Document (JSON - recommended for AI agents)
|
|
394
|
-
POST /api/ddocs?apiKey={API_KEY}
|
|
395
|
-
Content-Type: application/json
|
|
396
|
-
|
|
397
|
-
{ "title": "Document Title", "content": "Document content here..." }
|
|
398
|
-
|
|
399
|
-
Response: 201 with { "message": "...", "data": { "ddocId": "...", "title": "...", "syncStatus": "...", ... } }
|
|
400
|
-
Extract ddocId from response.data.ddocId. Then poll GET /api/ddocs/{ddocId} until syncStatus is "synced", then show the link.
|
|
167
|
+
```
|
|
401
168
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
169
|
+
**Usage notes:**
|
|
170
|
+
- This tool **blocks** until the document is synced to the blockchain (up to 60 seconds)
|
|
171
|
+
- Content supports full markdown syntax
|
|
172
|
+
- The returned `link` is a shareable, encrypted URL to view the document on ddocs.new
|
|
173
|
+
- If sync takes too long, the tool returns with `syncStatus: "pending"` - use `fileverse_get_sync_status` to poll later
|
|
405
174
|
|
|
406
|
-
|
|
175
|
+
---
|
|
407
176
|
|
|
408
|
-
|
|
177
|
+
### fileverse_update_document
|
|
409
178
|
|
|
410
|
-
|
|
411
|
-
PUT /api/ddocs/{ddocId}?apiKey={API_KEY}
|
|
412
|
-
Content-Type: application/json
|
|
179
|
+
Update an existing document's title and/or content, then wait for blockchain sync.
|
|
413
180
|
|
|
414
|
-
|
|
181
|
+
**Parameters:**
|
|
182
|
+
| Name | Type | Required | Description |
|
|
183
|
+
|---------|--------|----------|----------------------------|
|
|
184
|
+
| ddocId | string | Yes | The unique document identifier |
|
|
185
|
+
| title | string | No | New document title |
|
|
186
|
+
| content | string | No | New document content |
|
|
415
187
|
|
|
416
|
-
|
|
188
|
+
At least one of `title` or `content` must be provided.
|
|
417
189
|
|
|
418
|
-
|
|
419
|
-
Poll until synced, then show the link.
|
|
190
|
+
**Returns:** Updated document object with sync status and link.
|
|
420
191
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
192
|
+
**Usage notes:**
|
|
193
|
+
- This tool **blocks** until the update is synced to the blockchain (up to 60 seconds)
|
|
194
|
+
- Only provided fields are updated; omitted fields remain unchanged
|
|
195
|
+
- Each update increments the `localVersion`
|
|
424
196
|
|
|
425
|
-
|
|
197
|
+
---
|
|
426
198
|
|
|
427
|
-
|
|
199
|
+
### fileverse_delete_document
|
|
428
200
|
|
|
429
|
-
|
|
430
|
-
DELETE /api/ddocs/{ddocId}?apiKey={API_KEY}
|
|
201
|
+
Delete a document by its `ddocId`.
|
|
431
202
|
|
|
432
|
-
|
|
433
|
-
|
|
203
|
+
**Parameters:**
|
|
204
|
+
| Name | Type | Required | Description |
|
|
205
|
+
|--------|--------|----------|--------------------------------------|
|
|
206
|
+
| ddocId | string | Yes | The unique document identifier to delete |
|
|
434
207
|
|
|
435
|
-
|
|
208
|
+
**Returns:**
|
|
209
|
+
```json
|
|
436
210
|
{
|
|
437
|
-
"
|
|
438
|
-
"
|
|
439
|
-
"hasNext": true
|
|
211
|
+
"message": "Document deleted successfully",
|
|
212
|
+
"data": { "ddocId": "abc123", "..." }
|
|
440
213
|
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Usage notes:**
|
|
217
|
+
- Deletion is permanent
|
|
218
|
+
- The document's blockchain record will also be updated
|
|
441
219
|
|
|
442
|
-
|
|
443
|
-
POST /api/folders?apiKey={API_KEY}
|
|
444
|
-
Content-Type: application/json
|
|
220
|
+
---
|
|
445
221
|
|
|
446
|
-
|
|
447
|
-
Typically used for sync/on-chain integration, not ad-hoc folder creation by agents.
|
|
222
|
+
### fileverse_search_documents
|
|
448
223
|
|
|
449
|
-
|
|
450
|
-
GET /api/folders/{folderRef}/{folderId}?apiKey={API_KEY}
|
|
451
|
-
Both folderRef and folderId are required.
|
|
224
|
+
Search documents by text query. Returns matching documents ranked by relevance.
|
|
452
225
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
226
|
+
**Parameters:**
|
|
227
|
+
| Name | Type | Required | Description |
|
|
228
|
+
|-------|--------|----------|---------------------------------|
|
|
229
|
+
| query | string | Yes | Search query string |
|
|
230
|
+
| limit | number | No | Maximum number of results (default: 10) |
|
|
231
|
+
| skip | number | No | Number of results to skip |
|
|
456
232
|
|
|
457
|
-
|
|
233
|
+
**Returns:**
|
|
234
|
+
```json
|
|
458
235
|
{
|
|
459
|
-
"nodes": [...],
|
|
460
|
-
"total":
|
|
461
|
-
"hasNext":
|
|
236
|
+
"nodes": [{ "ddocId": "...", "title": "...", "content": "...", "syncStatus": "..." }],
|
|
237
|
+
"total": 5,
|
|
238
|
+
"hasNext": false
|
|
462
239
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
### List Failed Events
|
|
466
|
-
GET /api/events/failed?apiKey={API_KEY}
|
|
467
|
-
|
|
468
|
-
Response: array of events (e.g. _id, fileId, portalAddress, type, timestamp, lastError).
|
|
469
|
-
|
|
470
|
-
### Retry All Failed Events
|
|
471
|
-
POST /api/events/retry-failed?apiKey={API_KEY}
|
|
472
|
-
|
|
473
|
-
Response: { "retried": number }
|
|
474
|
-
|
|
475
|
-
### Retry One Failed Event
|
|
476
|
-
POST /api/events/{id}/retry?apiKey={API_KEY}
|
|
477
|
-
|
|
478
|
-
Response: { "ok": true } or 404 if event not found or not in failed state.
|
|
479
|
-
|
|
480
|
-
## OpenAPI Specification
|
|
240
|
+
```
|
|
481
241
|
|
|
482
|
-
|
|
242
|
+
**Usage notes:**
|
|
243
|
+
- Searches across document titles and content
|
|
244
|
+
- Results are ranked by relevance
|
|
245
|
+
- Use `skip` and `limit` for pagination
|
|
483
246
|
|
|
484
247
|
---
|
|
485
248
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
## Recipe 1: Publish a local file to blockchain
|
|
489
|
-
|
|
490
|
-
1. Read the file content from the local filesystem
|
|
491
|
-
2. POST /api/ddocs?apiKey={API_KEY} with JSON body: {"title": "<filename>", "content": "<file content>"}
|
|
492
|
-
3. Extract ddocId from response.data.ddocId
|
|
493
|
-
4. Poll GET /api/ddocs/{ddocId}?apiKey={API_KEY} every 5 seconds
|
|
494
|
-
5. When syncStatus is "synced", show: "Published! [View Document](link)"
|
|
495
|
-
6. If syncStatus is "failed", show: "Saved locally but blockchain sync failed. Run retry."
|
|
249
|
+
### fileverse_get_sync_status
|
|
496
250
|
|
|
497
|
-
|
|
251
|
+
Check the sync status of a document. Returns the current syncStatus and blockchain link if synced.
|
|
498
252
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
5. Show the updated link
|
|
253
|
+
**Parameters:**
|
|
254
|
+
| Name | Type | Required | Description |
|
|
255
|
+
|--------|--------|----------|----------------------------|
|
|
256
|
+
| ddocId | string | Yes | The unique document identifier |
|
|
504
257
|
|
|
505
|
-
|
|
258
|
+
**Returns:**
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"ddocId": "abc123",
|
|
262
|
+
"syncStatus": "synced",
|
|
263
|
+
"link": "https://ddocs.new/d/abc123#encryptionKey",
|
|
264
|
+
"localVersion": 3,
|
|
265
|
+
"onchainVersion": 3
|
|
266
|
+
}
|
|
267
|
+
```
|
|
506
268
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
5. Report: server status, number of documents, number of failed events (and if retried)
|
|
269
|
+
**Usage notes:**
|
|
270
|
+
- `syncStatus` can be: `"pending"`, `"synced"`, or `"failed"`
|
|
271
|
+
- Use this to poll for sync completion after create/update operations
|
|
272
|
+
- `localVersion` vs `onchainVersion` shows if there are unsynced changes
|
|
512
273
|
|
|
513
274
|
---
|
|
514
275
|
|
|
515
|
-
|
|
276
|
+
### fileverse_retry_failed_events
|
|
516
277
|
|
|
517
|
-
|
|
278
|
+
Retry all failed blockchain sync events. Use this when documents are stuck in `"failed"` sync status.
|
|
518
279
|
|
|
519
|
-
|
|
280
|
+
**Parameters:** None
|
|
520
281
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
Publish a file to Fileverse API blockchain storage.
|
|
527
|
-
|
|
528
|
-
Steps:
|
|
529
|
-
1. Read credentials from ~/.fileverseapirc (JSON with apiKey and serverUrl fields)
|
|
530
|
-
2. Read the file at: $ARGUMENTS
|
|
531
|
-
3. POST to {serverUrl}/api/ddocs?apiKey={apiKey} with JSON body:
|
|
532
|
-
Content-Type: application/json
|
|
533
|
-
{"title": "<filename without extension>", "content": "<file contents>"}
|
|
534
|
-
4. Extract ddocId from response.data.ddocId
|
|
535
|
-
5. Poll GET {serverUrl}/api/ddocs/{ddocId}?apiKey={apiKey} every 5 seconds until syncStatus is "synced" or "failed"
|
|
536
|
-
6. If synced: show "Published! Link: {link}"
|
|
537
|
-
7. If failed: show "Saved locally but blockchain sync failed"
|
|
282
|
+
**Returns:**
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"retried": 3
|
|
286
|
+
}
|
|
538
287
|
```
|
|
539
288
|
|
|
540
|
-
Usage
|
|
289
|
+
**Usage notes:**
|
|
290
|
+
- Call this when you notice documents with `syncStatus: "failed"`
|
|
291
|
+
- Returns the count of events that were retried
|
|
292
|
+
- Events have a maximum of 10 retry attempts before being permanently marked as failed
|
|
293
|
+
- Failed events are typically caused by blockchain rate limits or transient network errors
|
|
541
294
|
|
|
542
|
-
|
|
295
|
+
---
|
|
543
296
|
|
|
544
|
-
|
|
297
|
+
## Document Sync Lifecycle
|
|
545
298
|
|
|
546
|
-
|
|
547
|
-
List all documents in Fileverse API.
|
|
299
|
+
Understanding the sync lifecycle helps agents work effectively:
|
|
548
300
|
|
|
549
|
-
Steps:
|
|
550
|
-
1. Read credentials from ~/.fileverseapirc (JSON with apiKey and serverUrl fields)
|
|
551
|
-
2. GET {serverUrl}/api/ddocs?apiKey={apiKey}&limit=50
|
|
552
|
-
3. Display results as a table with columns: ddocId, title, syncStatus, link, updatedAt
|
|
553
|
-
4. Show total count and whether more documents exist (hasNext)
|
|
554
301
|
```
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
### fileverse-search.md
|
|
559
|
-
|
|
560
|
-
Create `.claude/commands/fileverse-search.md`:
|
|
561
|
-
|
|
562
|
-
```markdown
|
|
563
|
-
Search for documents in Fileverse API.
|
|
564
|
-
|
|
565
|
-
Steps:
|
|
566
|
-
1. Read credentials from ~/.fileverseapirc (JSON with apiKey and serverUrl fields)
|
|
567
|
-
2. GET {serverUrl}/api/search?apiKey={apiKey}&q=$ARGUMENTS
|
|
568
|
-
3. Display matching documents with: ddocId, title, syncStatus, link
|
|
569
|
-
4. Show total matches found
|
|
302
|
+
Create/Update → syncStatus: "pending" → blockchain sync → syncStatus: "synced"
|
|
303
|
+
→ syncStatus: "failed" (retry with fileverse_retry_failed_events)
|
|
570
304
|
```
|
|
571
305
|
|
|
572
|
-
|
|
306
|
+
1. **pending** - Document saved locally, waiting for blockchain sync
|
|
307
|
+
2. **synced** - Document is on-chain and has a shareable `link`
|
|
308
|
+
3. **failed** - Sync failed (rate limit, network error). Use `fileverse_retry_failed_events` to retry
|
|
573
309
|
|
|
574
|
-
|
|
310
|
+
The `create` and `update` tools automatically poll for up to 60 seconds. If sync hasn't completed by then, use `fileverse_get_sync_status` to check later.
|
|
575
311
|
|
|
576
|
-
|
|
312
|
+
---
|
|
577
313
|
|
|
578
|
-
|
|
579
|
-
Check the sync status of a Fileverse API document.
|
|
314
|
+
## Constraints & Limits
|
|
580
315
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
- Last Updated
|
|
590
|
-
4. If status is "failed", suggest running: POST {serverUrl}/api/events/retry-failed?apiKey={apiKey}
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
Usage: `/fileverse-status <ddocId>`
|
|
316
|
+
| Constraint | Value |
|
|
317
|
+
|--------------------------|------------------------|
|
|
318
|
+
| Max file upload size | 10 MB |
|
|
319
|
+
| Default page size | 10 documents |
|
|
320
|
+
| Sync polling timeout | 60 seconds |
|
|
321
|
+
| Sync poll interval | 3 seconds |
|
|
322
|
+
| Max event retries | 10 attempts |
|
|
323
|
+
| Worker concurrency | 5 concurrent events |
|
|
594
324
|
|
|
595
325
|
---
|
|
596
326
|
|
|
597
|
-
|
|
327
|
+
## Agents - Use
|
|
598
328
|
|
|
599
|
-
|
|
600
|
-
- **syncStatus**: pending → synced (success) or failed
|
|
601
|
-
- **link**: Public URL to view document (only available when synced)
|
|
602
|
-
- **localVersion**: Increments on each edit
|
|
603
|
-
- **onchainVersion**: Version on blockchain
|
|
329
|
+
### Common Patterns
|
|
604
330
|
|
|
605
|
-
|
|
331
|
+
**Creating documents from local files:**
|
|
332
|
+
- "Upload this README to a ddoc"
|
|
333
|
+
- "Sync my notes.md to Fileverse"
|
|
334
|
+
- "Create a ddoc from this file"
|
|
606
335
|
|
|
607
|
-
**
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
**500 Server Error**: Internal error, retry or inform user
|
|
336
|
+
**Generating new content:**
|
|
337
|
+
- "Create a ddoc that explains this codebase"
|
|
338
|
+
- "Write a design doc for [feature] and save it as a ddoc"
|
|
339
|
+
- "Create a ddoc summarizing today's meeting notes"
|
|
612
340
|
|
|
613
|
-
|
|
341
|
+
**Managing existing documents:**
|
|
342
|
+
- "List all my ddocs"
|
|
343
|
+
- "Search my ddocs for anything about authentication"
|
|
344
|
+
- "Update my project roadmap ddoc with the latest changes"
|
|
345
|
+
- "Delete the old draft ddoc"
|
|
346
|
+
- "What's the sync status of my latest document?"
|
|
347
|
+
|
|
348
|
+
**Sharing:**
|
|
349
|
+
- "Create a ddoc and give me the link"
|
|
350
|
+
- "Get the shareable link for my [document name] ddoc"
|
|
351
|
+
|
|
352
|
+
### Best Practices for Agents
|
|
614
353
|
|
|
615
|
-
|
|
354
|
+
1. **Always return the link** - After creating or updating a document, return the `link` field to the user so they can view/share it
|
|
355
|
+
2. **Use search before creating** - If the user wants to update something, search first to find the existing document instead of creating a duplicate
|
|
356
|
+
3. **Handle sync failures** - If a document's `syncStatus` is `"failed"`, call `fileverse_retry_failed_events` and inform the user
|
|
357
|
+
4. **Paginate large result sets** - Use `skip` and `limit` when listing documents to avoid loading everything at once
|
|
358
|
+
5. **Use markdown** - Content supports full markdown. Format documents with proper headings, lists, code blocks, and tables
|
|
359
|
+
6. **Check sync status** - If create/update returns with `syncStatus: "pending"`, poll with `fileverse_get_sync_status` until it's `"synced"` before giving the user the link
|
|
360
|
+
7. **Create a skill** - It's recommended for LLMs to create a skill/shortcut for common Fileverse operations to make it easier for users to interact with the API (e.g., `/ddoc create`, `/ddoc list`)
|
|
616
361
|
|
|
617
|
-
- **SSE for Sync Status**: Real-time sync status push via GET /api/ddocs/:ddocId/stream to eliminate polling
|
|
618
|
-
- **Batch Operations**: POST /api/ddocs/bulk for creating/updating/deleting multiple documents at once
|
|
619
|
-
- **Partial Responses**: ?fields=ddocId,syncStatus,link for requesting only specific fields
|
|
620
|
-
- **TypeScript SDK**: Typed client library with built-in sync polling at @fileverse/api/client
|
|
621
|
-
- **Webhook Callbacks**: Register a URL to be notified when sync completes instead of polling
|