Add send-email action with per-user permission model #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Add email sending support with a runtime-toggleable permission model. The human user controls which
(agent, recipient, topic)combinations are allowed. Once granted, emails on that combination flow without queue interaction.New actions
send-emailauto-accept(permission check is inside the handler)to,subject,body,topicmail_perm_store.check(caller, to, topic)before sending. Throws if not permitted.set-mail-permissionauto-accepttarget_user,to,topic,allow(bool)canApproveincludestarget_user— enforced in the handler viacheck_can_approve. Agent calling this gets an immediate error, not a queue entry (prevents social-engineering).get-mail-permissionsauto-accepttarget_user(optional)Permission data shape (
mail-permissions.json)All three fields must match exactly. No wildcards in v1. Persisted to disk on every mutation, loaded at startup. Path configured via
--mail-perms <path>orCONDUIT_MAIL_PERMSenv var. If not set, runs in-memory-only with a startup warning.SMTP config (in
secrets.json)Optional key — if absent,
send-emailfails with'SMTP not configured'.Handler context threading
Current handler signature:
handler(params)New signature:
handler(params, ctx)wherectx = { caller, users, mail_perm_store, mailer_send }Existing handlers ignore
ctx, so this is backwards-compatible. Both handler call sites inindex.mjs(auto-accept and queue-approval) change todef.handler(params, ctx).New files
server/mailer.mjs— nodemailer transport wrapper,create_mailer(smtp_config)returns asend(to, subject, body)async fnserver/mail_perms.mjs— permission store,load_mail_perms(path)returns store withcheck,add,remove,listModified files
server/index.mjs— add--mail-permsarg, buildctx, thread into handlersserver/actions.mjs— add 3 new actions, importcheck_can_approvefrom./auth.mjsserver/secrets.mjs— returnsmtpalongsideuserssecrets.example.json— addsmtpblockpackage.json— addnodemailerdependencyImplementation order
nodemailertopackage.jsonserver/mailer.mjsserver/mail_perms.mjsserver/secrets.mjsto returnsmtpserver/index.mjs—--mail-perms, buildctx, change call sitesserver/actions.mjssecrets.example.json