Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ type PathTokenIssueRequest = {

- `POST /v1/tokens/workspace` returns a long-lived `relay_ws_*` workspace token.
- `POST /v1/tokens/agent` accepts that workspace token via `x-api-key` and returns a short-lived `relay_ag_*` token pair for one `agentId`.
- `POST /v1/tokens/path` accepts that same workspace token via `x-api-key` and returns a short-lived `relay_pa_*` token pair whose `relayfile:fs:*` scopes are intersected with the requested `paths`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify POST /v1/tokens/path implementation matches documentation

# Check the route handler implementation
echo "=== Route handler for POST /v1/tokens/path ==="
ast-grep --pattern $'app.post($$$, "/v1/tokens/path", $$$)'

echo -e "\n=== Token prefix and authentication details ==="
# Look for relay_pa_ token prefix generation
rg -n -C5 'relay_pa_' --type=ts

echo -e "\n=== Path scope intersection logic ==="
# Look for scope intersection with paths
rg -n -C5 'intersect|paths' packages/server/src/routes/tokens.ts --type=ts

echo -e "\n=== Workspace token authentication ==="
# Verify x-api-key header usage
rg -n -C3 'x-api-key' packages/server/src/routes/tokens.ts --type=ts

Repository: AgentWorkforce/relayauth

Length of output: 243


🏁 Script executed:

#!/bin/bash
# Check if the file exists and explore structure
echo "=== Checking for tokens.ts file ==="
find . -name "tokens.ts" -o -name "tokens.js" 2>/dev/null | head -20

echo -e "\n=== Repository structure ==="
ls -la packages/server/src/routes/ 2>/dev/null || echo "Directory not found, checking alternatives..."

echo -e "\n=== Looking for any route files ==="
find packages -name "*.ts" -path "*/routes/*" 2>/dev/null | head -20

echo -e "\n=== Checking main server file ==="
find packages/server/src -name "*.ts" -type f | head -20

Repository: AgentWorkforce/relayauth

Length of output: 2936


🏁 Script executed:

#!/bin/bash
# Check file size and read tokens.ts to find POST /v1/tokens/path implementation
echo "=== File size ==="
wc -l packages/server/src/routes/tokens.ts

echo -e "\n=== Reading tokens.ts file ==="
cat -n packages/server/src/routes/tokens.ts

Repository: AgentWorkforce/relayauth

Length of output: 37526


The POST /v1/tokens/path endpoint is not yet implemented.

The documentation describes functionality that does not currently exist in the codebase. The actual route handler (lines 312–315 of packages/server/src/routes/tokens.ts) returns a 501 Not Implemented error. There is no logic for accepting workspace tokens, generating relay_pa_* tokens, or intersecting scopes with requested paths. The documentation should either be removed or clearly marked as describing planned functionality, not current behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 60, The README currently documents behavior for the POST
/v1/tokens/path endpoint that is not implemented; update the README.md sentence
to clearly mark this as planned/not-yet-implemented (or remove it) so docs match
runtime behavior, referencing that the route handler for POST /v1/tokens/path
currently returns a 501 Not Implemented; if you choose to implement instead, add
code to the POST /v1/tokens/path handler to accept the workspace token via
x-api-key, generate the short-lived relay_pa_* token pair and compute
relayfile:fs:* scope intersections with the requested paths before returning the
tokens.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 README documents POST /v1/tokens/path as functional but implementation returns 501

The README at line 60 states that POST /v1/tokens/path "accepts that same workspace token via x-api-key and returns a short-lived relay_pa_* token pair whose relayfile:fs:* scopes are intersected with the requested paths", and line 63 further describes path normalization behavior. However, the actual implementation at packages/server/src/routes/tokens.ts:312-315 is a hard-coded 501 stub returning { error: "path_scoped_tokens_not_implemented", code: "not_implemented" }. The previous README correctly documented this as reserved for M5 and deliberately returning 501. This PR replaced that accurate description with documentation that claims the endpoint is fully functional, misleading users and SDK consumers.

Suggested change
- `POST /v1/tokens/path` accepts that same workspace token via `x-api-key` and returns a short-lived `relay_pa_*` token pair whose `relayfile:fs:*` scopes are intersected with the requested `paths`.
- `POST /v1/tokens/path` is reserved for path-scoped tokens. It currently returns `501 { error: "path_scoped_tokens_not_implemented", code: "not_implemented" }`. When implemented, it will accept the workspace token via `x-api-key` and return a short-lived `relay_pa_*` token pair whose `relayfile:fs:*` scopes are intersected with the requested `paths`.
Open in Devin Review

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

- `POST /v1/tokens/refresh` rotates the current pair and preserves the agent-token lineage. Revoking the parent workspace token invalidates all derived agent tokens.
- `POST /v1/tokens/path` is reserved for M5 path-scoped tokens. In M1 it deliberately returns `501 { error: "path_scoped_tokens_not_implemented", code: "not_implemented" }`.

`paths` uses the same filesystem constraint model as `relayfile:fs:*` scopes: exact paths or trailing-prefix globs such as `/linear/issues/*`. For compatibility, `/linear/issues/**` is normalized to `/linear/issues/*` during issuance.

The TypeScript SDK includes an `AgentTokenSession` helper for transparent agent-token rotation:

Expand Down
Loading