Skip to content

docs: update examples with ecosystem integration#25

Merged
khaliqgant merged 5 commits intomainfrom
feat/update-examples
Mar 29, 2026
Merged

docs: update examples with ecosystem integration#25
khaliqgant merged 5 commits intomainfrom
feat/update-examples

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Mar 29, 2026

Adds example 06 (WritebackConsumer), docker prereqs, shared type imports.


Open with Devin

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

docker/seed.sh Outdated
Comment on lines +16 to +31
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/docs/welcome.md" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '# Welcome
Your relayfile workspace is running.
Write files here and agents will see them instantly.'

curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/github/repos/demo/pulls/1/metadata.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '{"number":1,"title":"Add quickstart","state":"open","author":"dev"}'

curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/config/agents.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '{"agents":[{"name":"dev-agent","scopes":["fs:read","fs:write"]}]}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 seed.sh curl requests don't match the server's API contract — no files get seeded

The three curl -X PUT commands in seed.sh fail silently because they violate three requirements of the PUT /v1/workspaces/{id}/fs/file endpoint:

  1. Missing X-Correlation-Id header — the server rejects requests without this header with 400 (internal/httpapi/server.go:232-235).
  2. Missing If-Match header — the write handler requires it (internal/httpapi/server.go:1455-1459), returning 412 without it. The SDK sends "If-Match": input.baseRevision (e.g. "*" for create-or-overwrite) at packages/sdk/typescript/src/client.ts:321.
  3. Wrong body format — the handler expects a JSON body with {"contentType":…, "content":…, "encoding":…, "semantics":…} (internal/httpapi/server.go:1476-1483), but the script sends raw content with Content-Type: application/octet-stream.

Since curl returns exit code 0 for HTTP 4xx errors (no --fail flag), set -e doesn't catch the failures. The script prints a token and appears to succeed, but ws_demo contains no files. Every curl example in docker/README.md will get 404s.

Example fix for one of the PUT requests
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/docs/welcome.md" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Correlation-Id: seed-welcome" \
  -H "If-Match: *" \
  -d '{"contentType":"text/markdown","content":"# Welcome\nYour relayfile workspace is running."}'
Suggested change
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/docs/welcome.md" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '# Welcome
Your relayfile workspace is running.
Write files here and agents will see them instantly.'
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/github/repos/demo/pulls/1/metadata.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '{"number":1,"title":"Add quickstart","state":"open","author":"dev"}'
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/config/agents.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
-d '{"agents":[{"name":"dev-agent","scopes":["fs:read","fs:write"]}]}'
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/docs/welcome.md" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "X-Correlation-Id: seed-welcome" \
-H "If-Match: *" \
-d '{"contentType":"text/markdown","content":"# Welcome\nYour relayfile workspace is running.\nWrite files here and agents will see them instantly."}'
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/github/repos/demo/pulls/1/metadata.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "X-Correlation-Id: seed-pr" \
-H "If-Match: *" \
-d '{"contentType":"application/json","content":"{\"number\":1,\"title\":\"Add quickstart\",\"state\":\"open\",\"author\":\"dev\"}"}'
curl -sS -X PUT "$RELAYFILE/v1/workspaces/$WS/fs/file?path=/config/agents.json" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "X-Correlation-Id: seed-config" \
-H "If-Match: *" \
-d '{"contentType":"application/json","content":"{\"agents\":[{\"name\":\"dev-agent\",\"scopes\":[\"fs:read\",\"fs:write\"]}]}"}'
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

khaliqgant and others added 5 commits March 29, 2026 23:36
Five runnable TypeScript examples covering the core relayfile SDK:
- 01: read files (listTree, readFile, queryFiles)
- 02: write files (writeFile, bulkWrite, optimistic locking)
- 03: webhook ingestion (ingestWebhook, computeCanonicalPath)
- 04: realtime events (getEvents polling with cursors)
- 05: scoped agent permissions (path-restricted tokens, 403 handling)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@khaliqgant khaliqgant force-pushed the feat/update-examples branch from 1155bf2 to fdcfd3d Compare March 29, 2026 21:37
@khaliqgant khaliqgant merged commit 7ee4277 into main Mar 29, 2026
6 checks passed
@khaliqgant khaliqgant deleted the feat/update-examples branch March 29, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant