Skip to content

fix(build): let an agent directory's auth.ts export authorizeApproval / authorizeSession - #661

Merged
LinuxDevil merged 1 commit into
mainfrom
fix/build-authorize-hooks
Oct 16, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
fix/build-authorize-hooks

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

Problem

An agent directory built with lousho build <dir> --target=node-server (or docker) always used the default access rules. With per-user tokens in auth.ts, a manager approving alice's paused claim got 403 LOUSHO_APPROVAL_FORBIDDEN, while alice could approve her own. The generated server passed only auth/schedules/channels to createDeployedServer(), which already accepts authorizeApproval / authorizeSession.

Fix

  • auth.ts may export functions named authorizeApproval and authorizeSession next to its default auth list (default export unchanged). A non-function under those names fails the load with LOUSHO_AGENT_DIR_INVALID.
  • resolveAgentDir() returns them on ResolvedAgentDir.
  • The node-server entry (also used by docker) passes them to createDeployedServer().
  • Not wired: cloudflare-worker (it does not use auth.ts at all, only LOUSHO_API_TOKEN) and lousho dev (no route auth, so there is no principal to check). The docs say so.
  • Docs: auth.md (node server + auth.ts, who may use a session, who may decide an approval, with a manager-approval example for agent directories), agent-directories.md, deployment.md; CHANGELOG; llms.txt regenerated; api report updated.

Verification

  • New e2e src/deploy/adapters/node-server-approvals.test.ts: builds a fixture agent dir (alice/bob/manager tokens, both rules exported), runs dist/server.js; alice self-approve 403, manager approve 200 and run finishes; bob reading alice's session 403, manager 200. Fails on main's wiring, passes with the fix.
  • loadAuth.test.ts covers the named exports and rejects a non-function.
  • tsc --noEmit, npm run lint, npm run build, docs snippet check, vitest run src/agentDir src/deploy src/server all pass.

🤖 Generated with Claude Code

@LinuxDevil
LinuxDevil force-pushed the fix/build-authorize-hooks branch 3 times, most recently from f35c995 to 796d2e1 Compare October 16, 2026 21:00
… / authorizeSession

A node-server / docker build of an agent directory always used the default
access rules, so a manager could not decide another user's paused approval
(403 LOUSHO_APPROVAL_FORBIDDEN) while the user could approve their own.
auth.ts may now export functions named authorizeApproval and
authorizeSession next to its default auth list; resolveAgentDir() returns
them and the built server passes them to createDeployedServer().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LinuxDevil
LinuxDevil force-pushed the fix/build-authorize-hooks branch from 796d2e1 to 2e1e870 Compare October 16, 2026 21:58
@LinuxDevil
LinuxDevil merged commit e2f748d into main Oct 16, 2026
2 checks passed
@LinuxDevil
LinuxDevil deleted the fix/build-authorize-hooks branch October 16, 2026 22:12
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