60 Commits

Author SHA1 Message Date
Abhinav Raut c865748ca5 switch to Geist and cache help center pages
Geist replaces Instrument Sans and is served from static/ instead of Google
Fonts, so it works on installs with no internet access.

Public help center pages are cached in Redis via fastcache with ETags, and any
admin write clears the group so edits show up on the next load.
2026-08-20 18:01:42 +05:30
Abhinav Raut a3d29011b6 fix mojibake in incoming quoted-printable emails
enmime's charset detection was overriding the declared UTF-8 charset on long mostly-ASCII bodies, storing accented text as mojibake (issue #512). Parse with detection disabled so the declared charset wins, bump enmime to v2, and swap the abandoned jaytaylor/html2text for its inbucket fork. Pin behavior with charset tests across locales, encodings, and malformed inputs.
2026-08-20 11:40:02 +05:30
Abhinav Raut aa54bfa48d fix slug, locale, theme and embedding bugs in help center
Batch of fixes from a review of the help-center branch.

Slugs. A long title made a slug longer than the 200 char cap, so the
save failed with a slug error on a form that has no slug field. The
"-2" dedup suffix could also push a slug past the cap after validation
ran, which locked the article out of every later edit. Slug generation
now truncates to fit, and collections get the same dedup pass articles
already had. Accented titles kept losing letters, so accents now fold
to their ASCII base. Titles in scripts with no ASCII form still fall
back to a random slug.

Locales. Removing a language from a help center stranded its
collections and articles. They had no admin UI path and no public URL,
but stayed in the AI index. Dropping a language that still holds
content is now rejected. Only languages the help center allows today
are checked, so an existing orphan can still be saved.

Theme. The luminance check only parsed 3 and 6 digit hex while the
sanitizer accepts 4 and 8 digit too, so an 8 digit header colour fell
back to dark text on a dark header. The free text colour fields had no
validation, so a bad value was silently thrown away on save while the
toast said it worked. The article editor was missing --hc-accent-ink,
which made button links invisible while editing.

Embeddings. The chunker changed the text it emits but the fingerprint
did not change, so nothing already indexed was ever re-chunked. The
chunker version now feeds the fingerprint. Deleting a collection or a
help center left the cascaded articles' vectors behind until the next
sweep, so those now clean up on delete.

Public API. The public JSON endpoints returned author name and avatar
even when the theme had authors turned off.

Media and search. Anonymous /uploads requests now hit a rate limit
before the DB lookup, and served files carry a one day cache header.
S3 redirects are no-store because a presigned URL expires. Public
search now enforces the same two character floor the typeahead uses,
so a one character query cannot seq-scan every article body.
2026-08-08 23:24:05 +05:30
Abhinav Raut b4b4251ebd Merge remote-tracking branch 'origin/main' into help-center
# Conflicts:
#	internal/media/media.go
2026-08-04 21:57:26 +05:30
Abhinav Raut 642b5a1942 add tests for the OTP verification email binding 2026-08-02 10:08:09 +05:30
Abhinav Raut baff30fc28 add help center with public pages, admin management and AI article indexing
Agents can now publish a public knowledge base per help center.

Backend:
- new internal/helpcenter package for help centers, collections and articles
- admin JSON API behind a new help_center:manage permission
- public /hc/{slug} pages, JSON API, search and sitemap, all rate limited
- migration v2.7.0 for the new tables

AI:
- published articles with the AI flag on get embedded, so the agent answers
  from them. Unpublishing or clearing the flag removes the embeddings.

Media:
- media rows now carry a private flag. Help article images are public so the
  public pages can serve them without auth, and only agents with
  help_center:manage can upload them.

Frontend:
- admin help center list, tree view and article editor
- the old TextEditor is split into ArticleEditor and ConversationEditor over a
  shared useTextEditor composable, so article-only tools like callouts,
  collapsibles and YouTube embeds stay out of the reply box
2026-07-25 14:19:38 +05:30
Abhinav Raut c030c9ee4b harden AI embedding and agent prompt handling, add tokenizer, and switch to a green theme
Embedding:
- Persist embedding_max_tokens. It was dropped when saving the provider config
  and always reset to the 8192 default, so self-hosted models with a smaller
  limit kept getting rejected.
- Split embedding requests to stay under the provider's item and token caps. A
  large snippet or URL import used to go in one request, hit the cap, fail, and
  get retried every minute forever.
- Skip blank chunks. An empty input string makes the API reject the whole batch.
- Add the tiktoken tokenizer (cl100k_base) with tests for token counting.

Agent prompt:
- Move contact fields, the conversation subject, and custom attributes out of
  the system prompt and into a delimited user-role block, so a crafted name or
  subject can't act as an instruction.

Frontend:
- Switch the primary and sidebar colors to a green theme.
- Show a "summarizing" info toast while the AI summary runs, and add an info
  toast variant.
- Make the snippet content box taller and the snippet dialog wider.
- Drop a hardcoded dark hover color on the scroll-to-bottom button.
2026-07-16 11:20:38 +05:30
Abhinav Raut dad99bf0ee render AI agent replies as markdown and fix assistant identity, handoff, and stats bugs
Replies from the AI agent are now converted from markdown to HTML with
goldmark before queueing, so bold, links, and lists render properly in the
widget, agent app, and email. The prompt now allows simple markdown. Raw
HTML in model output is escaped by goldmark, and both frontends sanitize
on render anyway.

Other fixes bundled in:
- validate avatar type and size before creating or updating an assistant,
  and roll back the assistant if the avatar upload fails after create
- return 404 from agent update and API key endpoints for AI assistant
  identity users, and hide assistants from mention and SLA user pickers
- reserve the autonomous assistant's built-in tool names so custom tools
  cannot shadow them
- apply resolve after the reply is posted so the CSAT survey follows the
  answer instead of preceding it
- unassign the assistant on handoff even when the fallback team is the
  same team
- count reopens by status category instead of status name, and exclude
  CSAT messages from the turn cap
- split oversized wrapper divs into child blocks when chunking KB HTML
  instead of truncating them
- return 404 when soft-deleting an already-deleted agent, and keep AI
  assistants (which have no email) visible in the compact users list
2026-07-12 23:12:44 +05:30
Abhinav Raut 3ba2b8281e Merge remote-tracking branch 'origin/main' into feat/ai-agent 2026-07-12 04:50:24 +05:30
dependabot[bot] 5815342b6f build(deps): bump golang.org/x/crypto from 0.51.0 to 0.52.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.51.0 to 0.52.0.
- [Commits](https://github.com/golang/crypto/compare/v0.51.0...v0.52.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.52.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 20:59:54 +00:00
Abhinav Raut 0ecd783941 add AI copilot backed by a knowledge base and custom tools
Adds two agent-facing AI features: a copilot chat panel in the conversation
sidebar and a generate-reply button in the reply box. Both run an agentic
tool-calling loop whose first tool searches the knowledge base.

Snippets are chunked and embedded on save, then searched in memory with
brute-force cosine similarity (no pgvector). Providers are split into completion
and embedding types. Both are OpenAI-compatible and the API key is encrypted at
rest. Admins can also register custom HTTP tools the model can call.

A new admin AI settings page covers provider config, snippets, and tools. The
v2.6.0 migration and schema add the ai_knowledge_base, embeddings, and ai_tools
tables plus the ai_providers type column.
2026-07-10 15:51:27 +05:30
dependabot[bot] 6eabd8aa1f build(deps): bump golang.org/x/image from 0.38.0 to 0.41.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.38.0 to 0.41.0.
- [Commits](https://github.com/golang/image/compare/v0.38.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-version: 0.41.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-03 12:38:48 +00:00
dependabot[bot] 57e15d32f4 build(deps): bump golang.org/x/net from 0.47.0 to 0.55.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.47.0 to 0.55.0.
- [Commits](https://github.com/golang/net/compare/v0.47.0...v0.55.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.55.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-03 12:31:35 +00:00
Abhinav Raut ddc82d9a1a fix: extract text from malformed email HTML
Swap k3a/html2text for jaytaylor/html2text in stringutil.HTML2Text.
k3a returns empty on HTML with orphan tags (e.g. stray </a>), which
made text_content blank for some emails.
2026-05-28 19:03:26 +05:30
Abhinav Raut edc82e9e55 refactor: drop Casbin, centralize agent cache invalidation, dedupe pending SLAs 2026-05-21 21:24:42 +05:30
Abhinav Raut a14d1dd0bc Merge pull request #114 from abhinavxd/feat/live-chat-channel
Live chat with widget
2026-04-17 03:09:08 +05:30
dependabot[bot] 2436f15ee9 build(deps): bump github.com/go-jose/go-jose/v4 from 4.0.5 to 4.1.4
Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.0.5 to 4.1.4.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Commits](https://github.com/go-jose/go-jose/compare/v4.0.5...v4.1.4)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v4
  dependency-version: 4.1.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-08 06:08:11 +00:00
dependabot[bot] 33b1ddc5b1 build(deps): bump golang.org/x/image from 0.18.0 to 0.38.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.18.0 to 0.38.0.
- [Commits](https://github.com/golang/image/compare/v0.18.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-version: 0.38.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 06:56:31 +00:00
Abhinav Raut a788553137 Use first unread message as subject for continuity emails, add ref number to continuity email subject.
- Continuity email layout fixes and improvments.
- Replace haikunator with email local part for visitor names, fallback to "Visitor"
- Add optional website_url config field for "go to chat" link in continuity email footer
- Remove unused / unncessary i18n keys.
2026-03-16 00:49:20 +05:30
Abhinav Raut eb0a7b437d Add page visit tracking to widget
- fix duplicate initialization guard
- notification bell for agents
- Refactor and clean up dead code
- Fixes to pre chat form
- Add new column country to users table
- Update ratelimit pkg to be generic
2026-03-11 03:52:07 +05:30
Abhinav Raut 4eb5dce12c Merge branch 'main' into feat/live-chat-channel 2026-02-22 15:13:36 +05:30
Abhinav Raut 727213631c SSRF protection to webhooks
- New config webhook option to allow certain CIDR ranges in webhooks.
2026-02-16 02:40:05 +05:30
Abhinav Raut 7958d7e212 Merge branch 'main' into feat/live-chat-channel 2026-01-14 00:33:51 +05:30
Abhinav Raut 5c364fb954 fix oauth credentials not being saved correctly , refactor use exisitng oauth pkg for oauth functionalities 2025-12-24 16:08:25 +05:30
egerong 3bc98bfd15 Implement parsing configuration from environment variables 2025-11-30 16:32:31 +02:00
Abhinav Raut ee2e929da5 bump simple s3 2025-11-26 12:35:34 +05:30
Abhinav Raut f516bbfa12 fix: improve MIME type detection and content disposition handling for media uploads for s3 store. 2025-11-25 16:06:36 +05:30
dependabot[bot] 1de50d5c12 chore(deps): bump golang.org/x/crypto from 0.38.0 to 0.45.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.38.0 to 0.45.0.
- [Commits](https://github.com/golang/crypto/compare/v0.38.0...v0.45.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.45.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-20 19:35:49 +00:00
Abhinav Raut bf1cf025e0 Merge branch 'main' into feat/live-chat-channel 2025-10-04 13:38:42 +05:30
Abhinav Raut cc36ef5a3a bump simple s3 2025-09-18 00:44:27 +05:30
Abhinav Raut 969d6ea4f9 Merge pull request #129 from abhinavxd/dependabot/go_modules/github.com/go-viper/mapstructure/v2-2.4.0
chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.0.0-alpha.1 to 2.4.0
2025-09-17 19:23:14 +05:30
Abhinav Raut bece58bdec fix[automation] respect case sensitive flag for contains and not contains operator
- test cases for automation evaluator
2025-09-02 02:31:08 +05:30
Abhinav Raut 634fc66e9f Translate welcome to libredesk email subject
- Update all SQL queries to add missing columns

- Update the create conversation API to allow setting the initiator of a conversation. For example, we might want to use this API to create a conversation on behalf of a customer, with the first message coming from the customer instead of the agent. This param allows this.

- Minor refactors and clean up

- Tidy go.mod

- Rename structs to reflect purpose

- Create focus structs for scanning JSON payloads for clarity.
2025-08-28 00:34:56 +05:30
dependabot[bot] 78b8607d8f chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.0.0-alpha.1 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.0.0-alpha.1...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.4.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-25 20:35:13 +00:00
Abhinav Raut 9a77c8953c Merge branch 'main' into feat/live-chat-channel 2025-08-24 01:52:12 +05:30
dependabot[bot] bf2c1fff6f chore(deps): bump golang.org/x/oauth2 from 0.21.0 to 0.27.0
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.21.0 to 0.27.0.
- [Commits](https://github.com/golang/oauth2/compare/v0.21.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-version: 0.27.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-20 09:11:03 +00:00
Abhinav Raut 5b6a58fba0 wip: intercom like live chat with chat widget
- new vue app for serving live chat widget, created subdirectories inside frontend dir `main` and `widget`
- vite changes for both main app and widget app.
- new backend live chat channel
- apis for live chat widget
2025-06-29 04:59:55 +05:30
Abhinav Raut c4a95672fe update simples3 2025-06-04 17:12:58 +05:30
Abhinav Raut 55ec962003 fix(activity-log): replace RemoteIP with fast-realip pkg for accurate IP retrieval
- Update go version to 1.24.3
2025-05-18 21:48:15 +05:30
dependabot[bot] 62023695a5 chore(deps): bump github.com/go-jose/go-jose/v4 from 4.0.2 to 4.0.5
Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.0.2 to 4.0.5.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-jose/go-jose/compare/v4.0.2...v4.0.5)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v4
  dependency-version: 4.0.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-03 15:34:59 +00:00
dependabot[bot] 59f5084bec chore(deps): bump github.com/redis/go-redis/v9 from 9.5.4 to 9.5.5
Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) from 9.5.4 to 9.5.5.
- [Release notes](https://github.com/redis/go-redis/releases)
- [Changelog](https://github.com/redis/go-redis/blob/master/CHANGELOG.md)
- [Commits](https://github.com/redis/go-redis/compare/v9.5.4...v9.5.5)

---
updated-dependencies:
- dependency-name: github.com/redis/go-redis/v9
  dependency-version: 9.5.5
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-30 06:58:01 +00:00
Abhinav Raut 0b2c607cd3 fix(deps): update simples3 to v0.9.0 2025-04-28 23:48:24 +05:30
Abhinav Raut 1875a62e00 feat: test cases for SLA calculator, string utilities and attachments 2025-03-26 23:57:56 +05:30
Abhinav Raut a36c81141b fix: update balance 2025-03-18 23:17:11 +05:30
Abhinav Raut 47af51d0dd update simple s3 2025-03-09 13:18:49 +05:30
Abhinav Raut e8f3f24422 feat: update build configuration and versioning system 2025-02-25 01:35:52 +05:30
dependabot[bot] dbb2ae303f chore(deps): bump golang.org/x/net from 0.27.0 to 0.33.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.27.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.27.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-20 06:58:24 +00:00
Abhinav Raut 0c54abbbad refactor: rename modules and imports to reflect project name 2025-01-11 21:46:29 +05:30
Abhinav Raut 7e15995048 fix: file uploads with same file names replacing previous files, switches to uuids for stored filenames.
- minor refactor and fixes.
2024-10-10 02:59:00 +05:30
Abhinav Raut 0e84fac099 feat: ACL and ABAC
- Simplify ws package.
2024-09-19 04:17:03 +05:30