Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(channel-reader): link the Profile UI from the unresolved-sender notice
Jose Ramirez604b320ef12e
diff --git a/channel-reader/README.md b/channel-reader/README.mdindex 21d4538f6..9876dbd72 100644--- a/channel-reader/README.md+++ b/channel-reader/README.md@@ -42,6 +42,7 @@ Reads channel config from `CLERUM_CHANNEL` environment variable. No Kubernetes a| `CLERUM_ENABLE_RESPONSE_ATTACHMENTS` | No | `true` | Enable response attachment delivery. Set to `false` to disable non-workflow response attachments. || `CLERUM_ATTACHMENT_MAX_COUNT` | No | `3` | Max attachments delivered per response || `CLERUM_ATTACHMENT_MAX_BYTES` | No | `52428800` | Max decoded bytes per attachment |+| `CLERUM_PROFILE_UI_URL` | No | - | Base URL of the Profile UI. When set, the unresolved-sender notice links here so users can find their verification code. |Attachment delivery behavior:diff --git a/channel-reader/package-lock.json b/channel-reader/package-lock.jsonindex ad30f5a34..447c2a445 100644--- a/channel-reader/package-lock.json+++ b/channel-reader/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-channel-reader",- "version": "0.1.89",+ "version": "0.1.90","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-channel-reader",- "version": "0.1.89",+ "version": "0.1.90","license": "SEE LICENSE IN LICENSE","dependencies": {"@kubernetes/client-node": "^1.0.0",diff --git a/channel-reader/package.json b/channel-reader/package.jsonindex b3379099d..32c356b42 100644--- a/channel-reader/package.json+++ b/channel-reader/package.json@@ -1,6 +1,6 @@{"name": "clerum-channel-reader",- "version": "0.1.89",+ "version": "0.1.90","description": "Watches CommunicationChannel CRDs and fetches messages from Telegram, Email, and Slack","main": "dist/main.js","engines": {diff --git a/channel-reader/src/config.ts b/channel-reader/src/config.tsindex e43c554a3..66eba8172 100644--- a/channel-reader/src/config.ts+++ b/channel-reader/src/config.ts@@ -23,6 +23,9 @@ export interface Config {// channel-reader must not carry control-api service credentials.notificationDeliveryPollLimit: number+ /** Optional. When set, the unresolved-sender notice links here. */+ profileUiUrl?: string+// Telegram Bot API root. Defaults to Telegram's public API; E2E may point// this at a provider-boundary mock without adding an HTTP ingress to// channel-reader.@@ -136,6 +139,9 @@ export const config: Config = {notificationDeliveryPollLimit: getEnvInt('CLERUM_NOTIFICATION_DELIVERY_POLL_LIMIT', 10),+ /** Optional. When set, the unresolved-sender notice links here. */+ profileUiUrl: getEnv('CLERUM_PROFILE_UI_URL'),+telegramApiRoot: getEnv('CLERUM_TELEGRAM_API_ROOT'),telegramStartupStabilityMs: getEnvInt('CLERUM_TELEGRAM_STARTUP_STABILITY_MS', 1000),telegramShutdownGraceMs: getEnvInt('CLERUM_TELEGRAM_SHUTDOWN_GRACE_MS', 750),diff --git a/channel-reader/src/main.ts b/channel-reader/src/main.tsindex 19aff3f16..3b335a34c 100644--- a/channel-reader/src/main.ts+++ b/channel-reader/src/main.ts@@ -1569,7 +1569,9 @@ export class ChannelReader {const adapter = this.adapterForMessage(msg)if (!adapter?.sendEphemeral) return- await adapter.sendEphemeral(channelId, userId, UNRESOLVED_NOTICE_COPY)+ const profileUrl = config.profileUiUrl?.trim()+ const content = profileUrl ? `${UNRESOLVED_NOTICE_COPY} ${profileUrl}` : UNRESOLVED_NOTICE_COPY+ await adapter.sendEphemeral(channelId, userId, content)}private pendingApprovalChannelScope(msg: Message): string {diff --git a/channel-reader/test/unresolvedSenderNotice.test.ts b/channel-reader/test/unresolvedSenderNotice.test.tsindex d11faa77c..151e65d2d 100644--- a/channel-reader/test/unresolvedSenderNotice.test.ts+++ b/channel-reader/test/unresolvedSenderNotice.test.ts@@ -10,6 +10,7 @@ const mockCfg = vi.hoisted(() => ({namespace: '',pollIntervalSeconds: 1,devChannelConfig: undefined,+ profileUiUrl: undefined as string | undefined,}))vi.mock('../src/config', () => ({@@ -87,6 +88,7 @@ interface BuildReaderOptions {reason?: 'unresolved' | 'error'medium?: 'slack' | 'telegram'ephemeralThrows?: boolean+ profileUiUrl?: string}/**@@ -103,6 +105,9 @@ function buildReader(options: BuildReaderOptions = {}) {// would silently turn the absent-reason case into the unresolved case.const reason: 'unresolved' | 'error' | undefined ='reason' in options ? options.reason : 'unresolved'+ // Reset on every call (not just when passed) so state never leaks between+ // tests that share this hoisted mock config.+ mockCfg.profileUiUrl = options.profileUiUrlconst sendEphemeral = vi.fn(async (_channelId: string, _userId: string, _content: string) => {if (ephemeralThrows) throw new Error('user_not_in_channel')@@ -267,3 +272,22 @@ describe('unresolved sender notice', () => {expect(sendEphemeral).not.toHaveBeenCalled()})})++describe('unresolved notice link', () => {+ it('appends the profile URL when configured', async () => {+ const { deliver, sendEphemeral } = buildReader({ profileUiUrl: 'https://profile.example.com' })+ await deliver('C1', 'U1')+ expect(sendEphemeral.mock.calls[0][2]).toContain('https://profile.example.com')+ })++ it('sends the copy unchanged when no profile URL is configured', async () => {+ const { deliver, sendEphemeral } = buildReader({ profileUiUrl: undefined })+ await deliver('C1', 'U1')+ const text = sendEphemeral.mock.calls[0][2]+ expect(text).toBe(+ "I can't accept messages from this Slack account. If you haven't linked it yet, " ++ 'do that in your evenfire profile. If you think you should already have access, contact your admin.'+ )+ expect(text).not.toContain('undefined')+ })+})