handler

package
v0.0.122 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: GPL-3.0 Imports: 45 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SentryTracesSampleRateMetaName        = "sentry-traces-sample-rate"
	SentryReplaySessionSampleRateMetaName = "sentry-replay-session-sample-rate"
	SentryReplayErrorSampleRateMetaName   = "sentry-replay-error-sample-rate"
)

Sentry sample-rate meta-tag names. Injected alongside the DSN (and only with one) so ops can tune performance tracing and session replay per deployment without any client rebuild. Zero/absent means off.

View Source
const AppVersionHeaderName = "X-EX-App-Version"

AppVersionHeaderName is sent with HTTP responses so stale clients can discover a deployed frontend change even when their first API request fails before the websocket version handshake arrives.

View Source
const AppVersionMetaName = "app-version"

AppVersionMetaName is the HTML meta-tag name the SPA reads to learn which build it loaded with. The same string is hard-coded on the frontend (lib/version-meta.ts) — keep them in sync.

View Source
const BuildVersionMetaName = "build-version"

BuildVersionMetaName is the HTML meta-tag name the SPA reads for display-only release metadata. It must not be used for reload detection: a Git tag/SHA can stay the same across frontend artifact rebuilds in local and CI workflows.

View Source
const MaxGenericUploadBytes int64 = 512 * 1024
View Source
const SentryDSNMetaName = "sentry-dsn"

SentryDSNMetaName is the HTML meta-tag name the SPA reads to (optionally) initialize Sentry error reporting. Injected by spaHandler only when the server is configured with SENTRY_FRONTEND_DSN — delivery via the served HTML means the browser, the Electron shell and the Capacitor webview all pick it up without any client rebuild.

Variables

View Source
var BuildVersion string

BuildVersion can be set by release builds via:

-ldflags "-X github.com/DigitalTolk/ex/internal/handler.BuildVersion=<tag-or-sha>"

This is display-only release metadata for the About dialog. AppVersion must remain derived from the shipped frontend artifact so the reload banner still detects a new index.html even when the Git metadata is unchanged.

Functions

func AppVersion added in v0.0.8

func AppVersion(frontendFS fs.FS) string

AppVersion derives the build version from the SHA-256 of the embedded `index.html`. Vite bakes hashed asset filenames into index.html, so any change to any source file or dependency produces a different document — and therefore a different version. This replaces the old VERSION ldflag dance: the version derives from the artifact itself, not from build-time env-var plumbing.

Returns "dev" when the FS is unavailable or index.html can't be read. The caller (typically internal/app) treats both the version endpoint and the SPA's served meta tag as the same string, so the only way for the frontend to detect a mismatch is for the bundle to actually change.

func DisplayVersion added in v0.0.19

func DisplayVersion(appVersion string) string

DisplayVersion returns the human-facing version shown in About. Release builds prefer Git metadata; local/dev builds fall back to the app artifact version so the dialog still shows something useful.

func NewBrokerAdapter

func NewBrokerAdapter(b *pubsub.Broker) *brokerAdapter

NewBrokerAdapter returns a brokerAdapter that satisfies service.Broker.

func NewOIDCAdapter

func NewOIDCAdapter(p *auth.OIDCProvider) *oidcAdapter

NewOIDCAdapter returns an adapter that satisfies service.OIDCProvider.

func NewRouter

func NewRouter(d *Deps) http.Handler

NewRouter builds the application HTTP handler, registering all routes. All dependencies are bundled in *Deps — adding a new endpoint only requires adding a field to that struct (see deps.go).

Deps.FrontendFS should be the frontend/dist subtree (already sub-rooted); pass nil to disable the embedded SPA. Deps.AppVersion is the build identifier the SPA embeds in its `<meta name="app-version">` tag — main computes it once and forwards the same value here to avoid re-hashing index.html.

Types

type ActivityHandler added in v0.0.54

type ActivityHandler struct {
	// contains filtered or unexported fields
}

ActivityHandler exposes the activity-stream and reminder endpoints.

func NewActivityHandler added in v0.0.54

func NewActivityHandler(activity ActivityService, reminder ReminderService) *ActivityHandler

NewActivityHandler builds an ActivityHandler.

func (*ActivityHandler) CancelReminder added in v0.0.54

func (h *ActivityHandler) CancelReminder(w http.ResponseWriter, r *http.Request)

CancelReminder cancels a pending reminder.

func (*ActivityHandler) CreateReminder added in v0.0.54

func (h *ActivityHandler) CreateReminder(w http.ResponseWriter, r *http.Request)

CreateReminder schedules a "remind me about this message" reminder.

func (*ActivityHandler) Feed added in v0.0.54

Feed returns the caller's activity stream + unread count.

func (*ActivityHandler) ListReminders added in v0.0.54

func (h *ActivityHandler) ListReminders(w http.ResponseWriter, r *http.Request)

ListReminders returns the caller's pending reminders.

func (*ActivityHandler) MarkRead added in v0.0.54

func (h *ActivityHandler) MarkRead(w http.ResponseWriter, r *http.Request)

MarkRead advances the caller's activity read watermark, clearing the badge.

func (*ActivityHandler) RemoveItems added in v0.0.83

func (h *ActivityHandler) RemoveItems(w http.ResponseWriter, r *http.Request)

RemoveItems deletes specific items from the caller's activity stream. Body: {"ids": ["..."]}.

func (*ActivityHandler) SetItemsRead added in v0.0.83

func (h *ActivityHandler) SetItemsRead(w http.ResponseWriter, r *http.Request)

SetItemsRead marks specific activity items read or unread. Body: {"ids": ["..."], "read": true|false}.

func (*ActivityHandler) UpdateReminder added in v0.0.114

func (h *ActivityHandler) UpdateReminder(w http.ResponseWriter, r *http.Request)

UpdateReminder changes a pending reminder's time, people and note.

type ActivityService added in v0.0.54

type ActivityService interface {
	Feed(ctx context.Context, userID string) (model.ActivityFeed, error)
	MarkSeen(ctx context.Context, userID string) error
	SetItemsRead(ctx context.Context, userID string, ids []string, read bool) error
	RemoveItems(ctx context.Context, userID string, ids []string) error
}

ActivityService is the activity-stream behaviour the handler needs.

type AdminHandler added in v0.0.2

type AdminHandler struct {
	// contains filtered or unexported fields
}

AdminHandler exposes admin-only endpoints for workspace configuration. Authorization is enforced inside each handler — `middleware.Auth` only confirms the caller is signed in, not that they're an admin.

func NewAdminHandler added in v0.0.2

func NewAdminHandler(settings *service.SettingsService) *AdminHandler

NewAdminHandler constructs an AdminHandler.

func (*AdminHandler) EmailStatus added in v0.0.66

func (h *AdminHandler) EmailStatus(w http.ResponseWriter, r *http.Request)

EmailStatus reports the effective mail configuration. Admin-only: the sender identity and transport are operational details.

func (*AdminHandler) GetSettings added in v0.0.2

func (h *AdminHandler) GetSettings(w http.ResponseWriter, r *http.Request)

GetSettings returns the effective workspace settings (with defaults applied for any field the admin hasn't overridden). Available to all authenticated users so the upload UI can show the limits before attempting a request — the write side is admin-only.

func (*AdminHandler) PushStats added in v0.0.66

func (h *AdminHandler) PushStats(w http.ResponseWriter, r *http.Request)

PushStats returns this instance's mobile-push pipeline counters (scheduled / delivered / ack-suppressed / undeliverable — SPEC P4), so an admin can verify the desktop-ack ⇄ mobile-fallback arbitration is doing what the reliability contract says. Admin-only; per-instance numbers.

func (*AdminHandler) SearchStatus added in v0.0.13

func (h *AdminHandler) SearchStatus(w http.ResponseWriter, r *http.Request)

SearchStatus returns the search cluster's health, per-index doc counts/sizes, and the most recent reindex progress. Admin-only. Returns 503 with a structured payload (`configured: false`) when search isn't wired so the UI can render the panel without erroring.

func (*AdminHandler) SendTestEmail added in v0.0.66

func (h *AdminHandler) SendTestEmail(w http.ResponseWriter, r *http.Request)

SendTestEmail sends a diagnostic message so an admin can verify the mail settings end to end without waiting for a real invite or password reset. Admin-only.

The recipient defaults to the calling admin's own address — the common case is "does this work at all?", and it keeps a misconfigured server from being used to mail arbitrary strangers.

func (*AdminHandler) SetAgentModels added in v0.0.118

func (h *AdminHandler) SetAgentModels(w http.ResponseWriter, r *http.Request)

SetAgentModels replaces the models agents may run on. Admin-only. PUT /api/v1/admin/agent-models {"models": [{harness, id, label}]}

func (*AdminHandler) SetMailer added in v0.0.66

func (h *AdminHandler) SetMailer(sender email.Sender, provider, from string)

SetMailer wires the configured transactional-mail transport plus the settings an admin needs to see to make sense of a test result. A nil sender means no transport is configured; EmailStatus reports that instead of pretending mail works.

func (*AdminHandler) SetMappingRebuilder added in v0.0.56

func (h *AdminHandler) SetMappingRebuilder(reb MappingRebuildController)

SetMappingRebuilder wires the optional cluster-coordinated users/channels mapping rebuild (RecreateUsersChannels behind a Redis lock + shared status). nil → the mapping-rebuild route answers 503, same as an unconfigured search.

func (*AdminHandler) SetSearch added in v0.0.13

func (h *AdminHandler) SetSearch(reporter SearchStatusReporter, reindexer *search.Reindexer)

SetSearch wires the optional search status reporter + reindexer. Production passes the live ones; tests can pass nil and the search-admin routes return 503.

func (*AdminHandler) SetSharePointHosts added in v0.0.116

func (h *AdminHandler) SetSharePointHosts(hosts []string)

SetSharePointHosts tells clients which links are SharePoint links: they show those as file cards and open them for editing.

func (*AdminHandler) SetWorkbenchEnabled added in v0.0.119

func (h *AdminHandler) SetWorkbenchEnabled(on bool)

SetWorkbenchEnabled tells clients whether to offer Connect to Claude.

func (*AdminHandler) StartSearchMappingRebuild added in v0.0.56

func (h *AdminHandler) StartSearchMappingRebuild(w http.ResponseWriter, r *http.Request)

StartSearchMappingRebuild kicks off the cluster-coordinated users/channels mapping rebuild (staging index → atomic alias-swap) — the path that actually rolls a new analyzer onto an existing cluster. Admin-only. A Redis lock makes it single-flight across every instance: 202 if THIS call won the lock and started a run, 409 if another instance (or a still-cooling crashed run) holds it, 503 if search isn't configured, 500 on a coordination (Redis) error.

func (*AdminHandler) StartSearchReindex added in v0.0.13

func (h *AdminHandler) StartSearchReindex(w http.ResponseWriter, r *http.Request)

StartSearchReindex kicks off a full rebuild in the background. Admin-only. Returns 202 if a fresh run started, 409 if one is already running, 503 if search isn't configured.

func (*AdminHandler) UpdateSettings added in v0.0.2

func (h *AdminHandler) UpdateSettings(w http.ResponseWriter, r *http.Request)

UpdateSettings replaces the workspace settings. Admin-only.

type AgentHandler added in v0.0.72

type AgentHandler struct {
	// contains filtered or unexported fields
}

AgentHandler serves the SPA-facing agent surface: the shared agents with the caller's own preferences, and run timelines. Runner pairing lives on RunnerTokenHandler.

func NewAgentHandler added in v0.0.72

func NewAgentHandler(agents *agents.AgentService, orch *agents.Orchestrator, users *service.UserService) *AgentHandler

NewAgentHandler wires the handler.

func (*AgentHandler) CountOverrides added in v0.0.75

func (h *AgentHandler) CountOverrides(w http.ResponseWriter, r *http.Request)

CountOverrides reports how many people have their own settings for an agent, so an admin editing the workspace default can see how far it reaches. GET /api/v1/agents/{slug}/overrides

func (*AgentHandler) CreateAgent added in v0.0.72

func (h *AgentHandler) CreateAgent(w http.ResponseWriter, r *http.Request)

CreateAgent defines a new shared agent (admin-only; the route is gated by RequireSystemRole(admin)). POST /api/v1/agents

func (*AgentHandler) CreateSkill added in v0.0.72

func (h *AgentHandler) CreateSkill(w http.ResponseWriter, r *http.Request)

CreateSkill defines a new workspace skill, authored by the caller. POST /api/v1/skills

func (*AgentHandler) CreateSubscription added in v0.0.72

func (h *AgentHandler) CreateSubscription(w http.ResponseWriter, r *http.Request)

CreateSubscription makes the agent watch a channel FOR the caller — the caller must be able to read the parent (their machine and quota run the watch turns, their access gates what the agent sees). POST /api/v1/agents/{slug}/subscriptions

func (*AgentHandler) DecideApproval added in v0.0.72

func (h *AgentHandler) DecideApproval(w http.ResponseWriter, r *http.Request)

DecideApproval records the invoker's verdict on a pending approval. POST /api/v1/runs/{id}/approvals/{approvalID}

func (*AgentHandler) DecideCatchUp added in v0.0.72

func (h *AgentHandler) DecideCatchUp(w http.ResponseWriter, r *http.Request)

DecideCatchUp answers a watcher's catch-up ask: process the offline backlog now (one coalesced run) or dismiss it. Creator-only. POST /api/v1/watchers/{parentID}/{id}/catchup

func (*AgentHandler) DeleteSkill added in v0.0.72

func (h *AgentHandler) DeleteSkill(w http.ResponseWriter, r *http.Request)

DeleteSkill removes a skill (author, or any admin). DELETE /api/v1/skills/{id}

func (*AgentHandler) DeleteSubscription added in v0.0.72

func (h *AgentHandler) DeleteSubscription(w http.ResponseWriter, r *http.Request)

DeleteSubscription removes one of the caller's watches. DELETE /api/v1/agents/{slug}/subscriptions/{parentID}/{id}

func (*AgentHandler) GetArtifact added in v0.0.72

func (h *AgentHandler) GetArtifact(w http.ResponseWriter, r *http.Request)

GetArtifact returns one artifact of a run — the inline chat card fetches content through this on expand/download. Same access rule as Timeline: the invoker always, otherwise any member of the run's parent. GET /api/v1/runs/{id}/artifacts/{artifactID}

func (*AgentHandler) List added in v0.0.72

func (h *AgentHandler) List(w http.ResponseWriter, r *http.Request)

func (*AgentHandler) ListParentWatchers added in v0.0.72

func (h *AgentHandler) ListParentWatchers(w http.ResponseWriter, r *http.Request)

ListParentWatchers returns the caller's OWN watchers in one channel/DM, across every agent — used by the message list to badge watched threads. GET /api/v1/channels/{id}/watchers · GET /api/v1/conversations/{id}/watchers

func (*AgentHandler) ListSkills added in v0.0.72

func (h *AgentHandler) ListSkills(w http.ResponseWriter, r *http.Request)

ListSkills returns the skills the caller may see: every published skill plus their own private ones. GET /api/v1/skills

func (*AgentHandler) ListSubscriptions added in v0.0.72

func (h *AgentHandler) ListSubscriptions(w http.ResponseWriter, r *http.Request)

ListSubscriptions returns the caller's watches for one agent. GET /api/v1/agents/{slug}/subscriptions

func (*AgentHandler) PendingApprovals added in v0.0.119

func (h *AgentHandler) PendingApprovals(w http.ResponseWriter, r *http.Request)

PendingApprovals lists the caller's approvals, questions and draft replies still waiting on them, as run.approval frames, so a page that loads or reconnects shows the cards the live events delivered before it. GET /api/v1/approvals/pending

func (*AgentHandler) RenameAgent added in v0.0.72

func (h *AgentHandler) RenameAgent(w http.ResponseWriter, r *http.Request)

RenameAgent changes a shared agent's display name. Admin-only. PATCH /api/v1/agents/{slug}

func (*AgentHandler) ResetOverrides added in v0.0.75

func (h *AgentHandler) ResetOverrides(w http.ResponseWriter, r *http.Request)

ResetOverrides clears everyone's personal settings for an agent so the template governs the whole workspace.

Destructive and not undoable: a prefs row is one document, so this also clears each person's persona, limits, follow-up settings and pre-approved tool classes for this agent — not only the harness and model. The count comes back so the caller can report what it actually removed. DELETE /api/v1/agents/{slug}/overrides

func (*AgentHandler) SetRunFiles added in v0.0.89

func (h *AgentHandler) SetRunFiles(l runFileLoader)

SetRunFiles wires the attachment loader for the drawer's file list.

func (*AgentHandler) SetTimelineAccess added in v0.0.72

func (h *AgentHandler) SetTimelineAccess(a timelineAccessChecker)

SetTimelineAccess wires the parent-membership checker used by watch subscriptions. It no longer widens timeline reads — logs are invoker-only.

func (*AgentHandler) StopRun added in v0.0.72

func (h *AgentHandler) StopRun(w http.ResponseWriter, r *http.Request)

StopRun cancels every live run in this run's conversation thread — the human brake on a runaway agent discussion. Allowed for the invoker or any member of the parent (it's their channel being flooded). POST /api/v1/runs/{id}/stop

func (*AgentHandler) ThreadTimeline added in v0.0.72

func (h *AgentHandler) ThreadTimeline(w http.ResponseWriter, r *http.Request)

ThreadTimeline is the drawer's whole-thread view: every run under one root message, merged. Same shape as Timeline (run = the latest, so state/stop/ polling keep working) plus `runs`. GET /api/v1/runs/thread?parent=<channel|conversation id>&root=<message id>

func (*AgentHandler) Timeline added in v0.0.72

func (h *AgentHandler) Timeline(w http.ResponseWriter, r *http.Request)

Timeline returns a run and its full event list for the Activity Drawer. GET /api/v1/runs/{id}

func (*AgentHandler) UpdatePrefs added in v0.0.72

func (h *AgentHandler) UpdatePrefs(w http.ResponseWriter, r *http.Request)

UpdatePrefs applies the caller's edits to THEIR prefs for one agent. PATCH /api/v1/agents/{slug}/prefs

func (*AgentHandler) UpdateSkill added in v0.0.72

func (h *AgentHandler) UpdateSkill(w http.ResponseWriter, r *http.Request)

UpdateSkill applies the author's edits — or an admin's. PATCH /api/v1/skills/{id}

func (*AgentHandler) UpdateSubscription added in v0.0.72

func (h *AgentHandler) UpdateSubscription(w http.ResponseWriter, r *http.Request)

UpdateSubscription edits a watcher's instruction / action mode (creator-only). PATCH /api/v1/agents/{slug}/subscriptions/{parentID}/{id}

func (*AgentHandler) Wired added in v0.0.97

func (h *AgentHandler) Wired() error

type AgentRunToolHandler added in v0.0.72

type AgentRunToolHandler struct {
	// contains filtered or unexported fields
}

AgentRunToolHandler serves MCP tool calls for live runs.

func NewAgentRunToolHandler added in v0.0.72

func NewAgentRunToolHandler(orch *agents.Orchestrator, messages *service.MessageService, ctxSvc *agents.ContextService, agents *agents.AgentService) *AgentRunToolHandler

NewAgentRunToolHandler wires the handler.

func (*AgentRunToolHandler) CancelReminder added in v0.0.72

func (h *AgentRunToolHandler) CancelReminder(w http.ResponseWriter, r *http.Request)

CancelReminder cancels one of the invoker's pending reminders. DELETE /api/v1/agent/run/reminders/{id}

func (*AgentRunToolHandler) ClaimTask added in v0.0.72

func (h *AgentRunToolHandler) ClaimTask(w http.ResponseWriter, r *http.Request)

ClaimTask atomically claims one part of a co-invoked task (first write wins) so parallel agents can split work without racing. POST /api/v1/agent/run/claims

func (*AgentRunToolHandler) CreateChannel added in v0.0.72

func (h *AgentRunToolHandler) CreateChannel(w http.ResponseWriter, r *http.Request)

CreateChannel creates a channel AS THE INVOKER — their access level gates it (guests can't create channels; the service enforces that). POST /api/v1/agent/run/channels

func (*AgentRunToolHandler) CreateSchedule added in v0.0.78

func (h *AgentRunToolHandler) CreateSchedule(w http.ResponseWriter, r *http.Request)

CreateSchedule creates a scheduled order AS THE INVOKER. POST /api/v1/agent/run/schedules

func (*AgentRunToolHandler) DeleteSchedule added in v0.0.78

func (h *AgentRunToolHandler) DeleteSchedule(w http.ResponseWriter, r *http.Request)

DeleteSchedule removes one of the invoker's scheduled orders. DELETE /api/v1/agent/run/schedules/{id}

func (*AgentRunToolHandler) DownloadAttachment added in v0.0.89

func (h *AgentRunToolHandler) DownloadAttachment(w http.ResponseWriter, r *http.Request)

DownloadAttachment streams one attachment the run's INVOKER can read: the invoking message's files by default, or any message in the run's chat named by messageID (the [m:<id>] labels in the transcript). GET /api/v1/agent/run/attachments/{id}?messageID=

func (*AgentRunToolHandler) GetApproval added in v0.0.72

func (h *AgentRunToolHandler) GetApproval(w http.ResponseWriter, r *http.Request)

GetApproval reports an approval's current state (the poll target). GET /api/v1/agent/run/approvals/{id}

func (*AgentRunToolHandler) GetContext added in v0.0.72

func (h *AgentRunToolHandler) GetContext(w http.ResponseWriter, r *http.Request)

GetContext re-assembles the full layered bundle fresh — the get_context tool for long runs whose claim-time bundle went stale (plan-v2 §8). GET /api/v1/agent/run/context

func (*AgentRunToolHandler) GetThread added in v0.0.72

func (h *AgentRunToolHandler) GetThread(w http.ResponseWriter, r *http.Request)

GetThread returns the run's thread window in bundle format — same [m:<id>] labels the context bundle uses, read as the invoker. GET /api/v1/agent/run/thread

func (*AgentRunToolHandler) InvokeSkill added in v0.0.72

func (h *AgentRunToolHandler) InvokeSkill(w http.ResponseWriter, r *http.Request)

InvokeSkill returns a skill's instructions and audits the use. POST /api/v1/agent/run/skills/{id}

func (*AgentRunToolHandler) JoinChannel added in v0.0.72

func (h *AgentRunToolHandler) JoinChannel(w http.ResponseWriter, r *http.Request)

JoinChannel joins the INVOKER to a public channel. POST /api/v1/agent/run/channels/{id}/join

func (*AgentRunToolHandler) LinkMessage added in v0.0.72

func (h *AgentRunToolHandler) LinkMessage(w http.ResponseWriter, r *http.Request)

LinkMessage builds a clickable permalink to a message in this workspace, so an agent can reference a specific message instead of pasting an opaque [m:<id>] marker. The URL uses the workspace origin (BASE_URL) and the same grammar the client unfurls into a quoted-message card:

<base>/channel/<channelID>#msg-<id>   (optional ?thread=<root>)
<base>/conversation/<convID>#msg-<id>

Defaults to the run's own parent when no target is given. Access is checked with the INVOKER's permissions — an agent can't mint a link into a channel its invoker can't see. POST /api/v1/agent/run/link-message

func (*AgentRunToolHandler) ListChannels added in v0.0.72

func (h *AgentRunToolHandler) ListChannels(w http.ResponseWriter, r *http.Request)

ListChannels lists the channels the INVOKER is in (the ones the agent can read/post via their access). GET /api/v1/agent/run/channels

func (*AgentRunToolHandler) ListReminders added in v0.0.72

func (h *AgentRunToolHandler) ListReminders(w http.ResponseWriter, r *http.Request)

ListReminders lists the invoker's pending reminders. GET /api/v1/agent/run/reminders

func (*AgentRunToolHandler) ListSchedules added in v0.0.78

func (h *AgentRunToolHandler) ListSchedules(w http.ResponseWriter, r *http.Request)

ListSchedules lists the invoker's scheduled orders across every agent. GET /api/v1/agent/run/schedules

func (*AgentRunToolHandler) ListSkills added in v0.0.72

func (h *AgentRunToolHandler) ListSkills(w http.ResponseWriter, r *http.Request)

ListSkills returns the workspace skill directory (id/name/description — instructions come from InvokeSkill, so listing stays cheap). GET /api/v1/agent/run/skills

func (*AgentRunToolHandler) ListUsers added in v0.0.72

func (h *AgentRunToolHandler) ListUsers(w http.ResponseWriter, r *http.Request)

ListUsers searches the workspace directory (names the agent can @mention or DM on the invoker's behalf). GET /api/v1/agent/run/users?q=

func (*AgentRunToolHandler) NotifyOwner added in v0.0.72

func (h *AgentRunToolHandler) NotifyOwner(w http.ResponseWriter, r *http.Request)

NotifyOwner sends a PRIVATE message from the agent to the run's creator — the "DM me" primitive watchers use in notify/draft mode. Lands in the DM between the creator and this agent (created on first use), so it never appears in the watched channel. Not gated by the notify-only post block. POST /api/v1/agent/run/notify

func (*AgentRunToolHandler) PinMessage added in v0.0.72

func (h *AgentRunToolHandler) PinMessage(w http.ResponseWriter, r *http.Request)

PinMessage pins or unpins a message in the run's thread (as the invoker). POST /api/v1/agent/run/pins

func (*AgentRunToolHandler) PostMessage added in v0.0.72

func (h *AgentRunToolHandler) PostMessage(w http.ResponseWriter, r *http.Request)

PostMessage posts into the run's thread as the agent, capped per run. POST /api/v1/agent/run/messages

func (*AgentRunToolHandler) PostToChannel added in v0.0.72

func (h *AgentRunToolHandler) PostToChannel(w http.ResponseWriter, r *http.Request)

PostToChannel posts as the agent into ANOTHER channel the invoker is in. Shares the per-run post cap with post_message. POST /api/v1/agent/run/channels/{id}/messages

func (*AgentRunToolHandler) ProposeReply added in v0.0.72

func (h *AgentRunToolHandler) ProposeReply(w http.ResponseWriter, r *http.Request)

ProposeReply drafts an editable reply the invoker can approve, edit, or cancel (the reply-mode watcher path). The agent doesn't post — on approval the server posts the (possibly edited) text. Fire-and-forget: the run may end. POST /api/v1/agent/run/propose-reply

func (*AgentRunToolHandler) PublishArtifact added in v0.0.72

func (h *AgentRunToolHandler) PublishArtifact(w http.ResponseWriter, r *http.Request)

PublishArtifact stores a run-produced document, viewable in the drawer. POST /api/v1/agent/run/artifacts

func (*AgentRunToolHandler) React added in v0.0.72

React toggles a normal reaction as the agent, authorized by the invoker. POST /api/v1/agent/run/reactions

func (*AgentRunToolHandler) ReadChannel added in v0.0.72

func (h *AgentRunToolHandler) ReadChannel(w http.ResponseWriter, r *http.Request)

ReadChannel renders another channel's recent messages in bundle format, read as the invoker. GET /api/v1/agent/run/channels/{id}/messages?limit=&thread= Without thread: the channel's recent TOP-LEVEL messages. With thread (any message id inside a thread — a permalink's target included): that thread's messages, the reply bodies a channel window deliberately omits.

func (*AgentRunToolHandler) ReadDM added in v0.0.72

ReadDM reads the INVOKER's own direct conversation with one user — their message history with that person, which the invoker can already see in the app. Supports the same thread narrowing as ReadChannel. GET /api/v1/agent/run/dm/{userID}/messages?limit=&thread=

func (*AgentRunToolHandler) ReadPins added in v0.0.72

func (h *AgentRunToolHandler) ReadPins(w http.ResponseWriter, r *http.Request)

ReadPins lists a channel's pinned messages — the durable stuff members chose to keep visible (decisions, links, standing docs). GET /api/v1/agent/run/channels/{id}/pins

func (*AgentRunToolHandler) RequestApproval added in v0.0.72

func (h *AgentRunToolHandler) RequestApproval(w http.ResponseWriter, r *http.Request)

RequestApproval opens a blocking human-in-the-loop gate. The MCP server polls GetApproval until it settles (plan-v2 §7 approval timing). POST /api/v1/agent/run/approvals

func (*AgentRunToolHandler) SearchWorkspace added in v0.0.72

func (h *AgentRunToolHandler) SearchWorkspace(w http.ResponseWriter, r *http.Request)

SearchWorkspace searches message history the INVOKER can see. GET /api/v1/agent/run/search?q=&limit=

func (*AgentRunToolHandler) SendDM added in v0.0.72

SendDM opens (or reuses) the DM between the INVOKER and the target, and posts into it as the agent. Shares the per-run post cap. POST /api/v1/agent/run/dm

func (*AgentRunToolHandler) SetAttachments added in v0.0.89

func (h *AgentRunToolHandler) SetAttachments(a *service.AttachmentService)

SetAttachments wires the attachment service; the router registers the attachment routes only when set.

func (*AgentRunToolHandler) SetBaseURL added in v0.0.72

func (h *AgentRunToolHandler) SetBaseURL(u string)

SetBaseURL wires the public origin used to build message permalinks.

func (*AgentRunToolHandler) SetReminder added in v0.0.72

func (h *AgentRunToolHandler) SetReminder(w http.ResponseWriter, r *http.Request)

SetReminder schedules a reminder for the INVOKER (it fires into their activity + notifications), anchored to a message in the run's thread. Give either remind_at (RFC3339) or in_minutes. POST /api/v1/agent/run/reminders

func (*AgentRunToolHandler) SetState added in v0.0.72

func (h *AgentRunToolHandler) SetState(w http.ResponseWriter, r *http.Request)

SetState drives the machine state reaction from the MCP set_state tool. POST /api/v1/agent/run/state

func (*AgentRunToolHandler) SetWorkspace added in v0.0.72

func (h *AgentRunToolHandler) SetWorkspace(deps AgentWorkspaceDeps)

SetWorkspace wires the workspace tool dependencies.

func (*AgentRunToolHandler) UpdateMemory added in v0.0.72

func (h *AgentRunToolHandler) UpdateMemory(w http.ResponseWriter, r *http.Request)

UpdateMemory replaces the agent's core memory for THIS invoker (injected into every future bundle for this pairing). POST /api/v1/agent/run/memory

func (*AgentRunToolHandler) UploadAttachment added in v0.0.89

func (h *AgentRunToolHandler) UploadAttachment(w http.ResponseWriter, r *http.Request)

UploadAttachment stores a file the agent produced, for its own posts. Raw bytes in the body; Content-Length is the declared size; the file name rides X-Ex-Filename (percent-encoded). Counted against the run's upload cap BEFORE the bytes are read, so a capped run cannot even make the server buffer them. POST /api/v1/agent/run/attachments

func (*AgentRunToolHandler) Wired added in v0.0.97

func (h *AgentRunToolHandler) Wired() error

func (*AgentRunToolHandler) WriteContext added in v0.0.72

func (h *AgentRunToolHandler) WriteContext(w http.ResponseWriter, r *http.Request)

WriteContext appends a shared-context item as the agent, gated by the INVOKER's access and audited on the run timeline. POST /api/v1/agent/run/context

type AgentRunnerHandler added in v0.0.72

type AgentRunnerHandler struct {
	// contains filtered or unexported fields
}

AgentRunnerHandler serves the desktop runner's API. Every route sits behind AuthScope(runner): claims.UserID is the runner's OWNER.

func NewAgentRunnerHandler added in v0.0.72

func NewAgentRunnerHandler(agents *agents.AgentService, orch *agents.Orchestrator) *AgentRunnerHandler

NewAgentRunnerHandler wires the handler.

func (*AgentRunnerHandler) Claim added in v0.0.72

Claim long-polls for work. 200 with assignments, or 204 when the wait budget lapses empty. POST /api/v1/agent/runner/claim

func (*AgentRunnerHandler) Complete added in v0.0.72

func (h *AgentRunnerHandler) Complete(w http.ResponseWriter, r *http.Request)

Complete finalizes a run. POST /api/v1/agent/runner/runs/{id}/complete

func (*AgentRunnerHandler) Events added in v0.0.72

Events ingests a runner batch for one run. The response tells the runner whether to abort (limit tripped / run closed). POST /api/v1/agent/runner/runs/{id}/events

func (*AgentRunnerHandler) Fail added in v0.0.72

Fail records a runner-side failure. POST /api/v1/agent/runner/runs/{id}/fail

func (*AgentRunnerHandler) Heartbeat added in v0.0.72

func (h *AgentRunnerHandler) Heartbeat(w http.ResponseWriter, r *http.Request)

Heartbeat refreshes the runner + run leases; the response lists runs the runner must kill (terminal server-side). POST /api/v1/agent/runner/heartbeat

func (*AgentRunnerHandler) Register added in v0.0.72

func (h *AgentRunnerHandler) Register(w http.ResponseWriter, r *http.Request)

Register announces a runner. The shared agents (gg/qib) exist workspace- wide already — registering just makes them AVAILABLE to this user, since runs execute on the invoker's own machine. POST /api/v1/agent/runner/register

type AgentWorkspaceDeps added in v0.0.72

type AgentWorkspaceDeps struct {
	Channels      *service.ChannelService
	Conversations *service.ConversationService
	Searcher      search.Searcher // may be nil → search returns empty
	SearchAccess  SearchAccess
	Reminders     *service.ReminderService // may be nil → reminder tools 404
}

AgentWorkspaceDeps carries the extra services the workspace tools need. Optional as a unit — when unset the workspace endpoints 404 (router skips).

type AttachmentHandler

type AttachmentHandler struct {
	// contains filtered or unexported fields
}

AttachmentHandler exposes HTTP endpoints for uploading and managing message attachments.

func NewAttachmentHandler

func NewAttachmentHandler(svc *service.AttachmentService) *AttachmentHandler

NewAttachmentHandler creates an AttachmentHandler.

func (*AttachmentHandler) CreateUploadURL

func (h *AttachmentHandler) CreateUploadURL(w http.ResponseWriter, r *http.Request)

CreateUploadURL handles POST /api/v1/attachments/url. The client posts {filename, contentType, size, sha256}; we either return an existing attachment (alreadyExists=true, no upload required) or the attachment to upload: its object key, plus the multipart upload to resume when a previous attempt at the same file never finished. The bytes then go straight to S3 through requests signed by SignUploadRequest.

func (*AttachmentHandler) Delete

Delete removes a draft attachment (chip removed before sending). Refuses when other messages still reference the upload (SHA256 dedup case).

func (*AttachmentHandler) Get

Get handles GET /api/v1/attachments/{id} and returns the attachment with a freshly signed URL — the previously signed URL may have expired.

func (*AttachmentHandler) HTMLPreview added in v0.0.97

func (h *AttachmentHandler) HTMLPreview(w http.ResponseWriter, r *http.Request)

HTMLPreview handles GET /api/v1/html-preview/{token}/{filename...}: the HTML file behind a media token — the same bearer capability as /api/v1/media, no cookie involved — as a sandboxed document for the preview frame.

func (*AttachmentHandler) List

List handles GET /api/v1/attachments?ids=a,b,c and returns metadata + freshly signed URLs for each requested ID. Missing IDs are silently skipped — the caller compares returned IDs to detect them. Used by message renderers to resolve N attachment refs in one round-trip instead of N.

func (*AttachmentHandler) Media added in v0.0.19

Media handles public capability URLs generated by AttachmentService. The random token is the authorization boundary, same as a presigned S3 URL, but the URL stays stable for the Redis TTL so browser caching can work.

func (*AttachmentHandler) ProcessUpload added in v0.0.43

func (h *AttachmentHandler) ProcessUpload(w http.ResponseWriter, r *http.Request)

ProcessUpload handles POST /api/v1/attachments/{id}/process after the browser has finished the direct-to-S3 PUT. It validates the uploaded object and generates server-owned thumbnails before the attachment is sent.

func (*AttachmentHandler) SetPoster added in v0.0.90

func (h *AttachmentHandler) SetPoster(w http.ResponseWriter, r *http.Request)

SetPoster handles POST /api/v1/attachments/{id}/poster: the uploader's browser sends a frame of the video it just uploaded (the request body, an image), kept as the video's thumbnails.

func (*AttachmentHandler) SignUploadRequest added in v0.0.82

func (h *AttachmentHandler) SignUploadRequest(w http.ResponseWriter, r *http.Request)

SignUploadRequest handles POST /api/v1/attachments/{id}/upload-request. The browser's uploader (Uppy) posts each S3 request it is about to make — {method, key, uploadId?, partNumber?} — and gets back a presigned URL plus the headers it was signed with.

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

AuthHandler exposes HTTP endpoints for authentication flows.

func NewAuthHandler

func NewAuthHandler(authSvc *service.AuthService, jwt *auth.JWTManager) *AuthHandler

NewAuthHandler creates an AuthHandler.

func (*AuthHandler) AcceptInvite

func (h *AuthHandler) AcceptInvite(w http.ResponseWriter, r *http.Request)

AcceptInvite accepts an invitation and creates a guest account.

func (*AuthHandler) AdminResetUserPassword added in v0.0.66

func (h *AuthHandler) AdminResetUserPassword(w http.ResponseWriter, r *http.Request)

AdminResetUserPassword mints a one-time password-reset link for a guest account and emails it to that guest. Admin-only.

The link comes back in the response as well, so an admin can relay it directly when mail is unconfigured or the relay is down; `emailSent` tells the UI which story to show. SSO users are rejected with 409 — their credential lives in the identity provider and must stay there.

func (*AuthHandler) CreateInvite

func (h *AuthHandler) CreateInvite(w http.ResponseWriter, r *http.Request)

CreateInvite generates an invitation for a new user.

func (*AuthHandler) DesktopComplete added in v0.0.24

func (h *AuthHandler) DesktopComplete(w http.ResponseWriter, r *http.Request)

DesktopComplete redeems a one-time desktop_code: it sets the refresh cookie first-party and lands the app on the SPA callback. Only a navigation the app itself starts may redeem a code — Electron's loadURL and WKWebView's load(URLRequest) send Sec-Fetch-Site: none (a client without fetch metadata sends nothing). A link to this URL — posted in a message (same-origin) or on another site — would otherwise plant the code minter's session in whoever clicks it, so any other value is refused before the code is touched.

func (*AuthHandler) ForgotPassword added in v0.0.66

func (h *AuthHandler) ForgotPassword(w http.ResponseWriter, r *http.Request)

ForgotPassword is the unauthenticated "email me a reset link" endpoint for guest accounts. It always answers 204: the response must not reveal whether an address is registered, whether it is a guest, or whether mail went out.

func (*AuthHandler) GuestLogin

func (h *AuthHandler) GuestLogin(w http.ResponseWriter, r *http.Request)

GuestLogin authenticates a guest user with email and password.

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)

Logout invalidates the refresh token and clears the cookie.

func (*AuthHandler) OIDCCallback

func (h *AuthHandler) OIDCCallback(w http.ResponseWriter, r *http.Request)

OIDCCallback handles the identity provider redirect after authentication.

func (*AuthHandler) OIDCLogin

func (h *AuthHandler) OIDCLogin(w http.ResponseWriter, r *http.Request)

OIDCLogin initiates the OIDC login flow by redirecting to the identity provider. An optional ?redirect_to=<url> query parameter overrides where the browser is sent after a successful callback (must be a localhost, tauri://, or ex:// URL).

func (*AuthHandler) RefreshToken

func (h *AuthHandler) RefreshToken(w http.ResponseWriter, r *http.Request)

RefreshToken exchanges a refresh token for a new access token. Accepts the token from an httpOnly cookie.

func (*AuthHandler) ResetPassword added in v0.0.66

func (h *AuthHandler) ResetPassword(w http.ResponseWriter, r *http.Request)

ResetPassword redeems a one-time reset token and sets a new password. The caller is unauthenticated — the token IS the credential — so the token is single-use and every existing session for the account is revoked.

type BotHandler added in v0.0.112

type BotHandler struct {
	// contains filtered or unexported fields
}

BotHandler is the admin API for bot accounts and their access tokens (/api/v1/admin/bots). The service refuses anyone but an admin.

func NewBotHandler added in v0.0.112

func NewBotHandler(svc *service.BotService) *BotHandler

NewBotHandler returns the bot admin handler.

func (*BotHandler) Create added in v0.0.112

func (h *BotHandler) Create(w http.ResponseWriter, r *http.Request)

Create answers POST /api/v1/admin/bots.

func (*BotHandler) CreateToken added in v0.0.112

func (h *BotHandler) CreateToken(w http.ResponseWriter, r *http.Request)

CreateToken answers POST /api/v1/admin/bots/{id}/tokens with the token and its secret, which is never shown again.

func (*BotHandler) Delete added in v0.0.115

func (h *BotHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete answers DELETE /api/v1/admin/bots/{id}.

func (*BotHandler) Disable added in v0.0.112

func (h *BotHandler) Disable(w http.ResponseWriter, r *http.Request)

Disable answers POST /api/v1/admin/bots/{id}/disable.

func (*BotHandler) Enable added in v0.0.112

func (h *BotHandler) Enable(w http.ResponseWriter, r *http.Request)

Enable answers POST /api/v1/admin/bots/{id}/enable.

func (*BotHandler) List added in v0.0.112

func (h *BotHandler) List(w http.ResponseWriter, r *http.Request)

List answers GET /api/v1/admin/bots.

func (*BotHandler) ListTokens added in v0.0.112

func (h *BotHandler) ListTokens(w http.ResponseWriter, r *http.Request)

ListTokens answers GET /api/v1/admin/bots/{id}/tokens.

func (*BotHandler) RevokeToken added in v0.0.112

func (h *BotHandler) RevokeToken(w http.ResponseWriter, r *http.Request)

RevokeToken answers DELETE /api/v1/admin/bots/{id}/tokens/{tokenID}.

func (*BotHandler) Update added in v0.0.112

func (h *BotHandler) Update(w http.ResponseWriter, r *http.Request)

Update answers PATCH /api/v1/admin/bots/{id}.

type ChannelHandler

type ChannelHandler struct {
	// contains filtered or unexported fields
}

ChannelHandler exposes HTTP endpoints for channel operations.

func NewChannelHandler

func NewChannelHandler(channelSvc *service.ChannelService, messageSvc *service.MessageService) *ChannelHandler

NewChannelHandler creates a ChannelHandler.

func (*ChannelHandler) Act added in v0.0.116

Act clicks a button on a channel message. Body: {"blockID", "actionID"} — which button, nothing more: what the click does comes from the stored message (MessageService.Act).

func (*ChannelHandler) AddMember

func (h *ChannelHandler) AddMember(w http.ResponseWriter, r *http.Request)

AddMember adds a user to a channel with a given role.

func (*ChannelHandler) Archive

func (h *ChannelHandler) Archive(w http.ResponseWriter, r *http.Request)

Archive marks a channel as archived.

func (*ChannelHandler) BrowsePublic

func (h *ChannelHandler) BrowsePublic(w http.ResponseWriter, r *http.Request)

BrowsePublic returns a paginated list of public channels visible to the authenticated user. Guests get only the channels they belong to. When a `q` query param is supplied and OpenSearch is configured, the handler routes the query through it; otherwise it falls back to the paginated DDB scan so the directory's client-side filter still works.

func (*ChannelHandler) ConvertConversation added in v0.0.93

func (h *ChannelHandler) ConvertConversation(w http.ResponseWriter, r *http.Request)

ConvertConversation turns a group message into a private channel: POST /api/v1/conversations/{id}/convert {"name": "..."} → the channel.

func (*ChannelHandler) Create

func (h *ChannelHandler) Create(w http.ResponseWriter, r *http.Request)

Create creates a new channel.

func (*ChannelHandler) DeleteMessage

func (h *ChannelHandler) DeleteMessage(w http.ResponseWriter, r *http.Request)

DeleteMessage removes a message from a channel.

func (*ChannelHandler) EditMessage

func (h *ChannelHandler) EditMessage(w http.ResponseWriter, r *http.Request)

EditMessage updates a message in a channel.

func (*ChannelHandler) Get

Get returns a channel by ID or slug. If the path param is a 26-char ULID it looks up by ID; otherwise it treats the value as a slug.

func (*ChannelHandler) GetThread

func (h *ChannelHandler) GetThread(w http.ResponseWriter, r *http.Request)

GetThread returns all messages in the thread rooted at msgId.

func (*ChannelHandler) Join

Join adds the authenticated user to a public channel.

func (*ChannelHandler) Leave

func (h *ChannelHandler) Leave(w http.ResponseWriter, r *http.Request)

Leave removes the authenticated user from a channel.

func (*ChannelHandler) List

List returns all channels the authenticated user belongs to.

func (*ChannelHandler) ListFiles added in v0.0.8

func (h *ChannelHandler) ListFiles(w http.ResponseWriter, r *http.Request)

ListFiles returns one page of the files shared in the channel, newest first (see fileQuery for the parameters).

func (*ChannelHandler) ListMembers

func (h *ChannelHandler) ListMembers(w http.ResponseWriter, r *http.Request)

ListMembers returns all members of a channel.

func (*ChannelHandler) ListMessages

func (h *ChannelHandler) ListMessages(w http.ResponseWriter, r *http.Request)

ListMessages returns messages for a channel. Supports ?cursor= for older pagination, ?after= for newer pagination, and ?around=<msgId> for a centred window (used by deep-link search results).

func (*ChannelHandler) ListPinned added in v0.0.2

func (h *ChannelHandler) ListPinned(w http.ResponseWriter, r *http.Request)

ListPinned returns the channel's currently-pinned messages.

func (*ChannelHandler) MakePrivate added in v0.0.101

func (h *ChannelHandler) MakePrivate(w http.ResponseWriter, r *http.Request)

MakePrivate turns a public channel private.

func (*ChannelHandler) MarkRead added in v0.0.52

func (h *ChannelHandler) MarkRead(w http.ResponseWriter, r *http.Request)

SetMute toggles the muted flag for the authenticated user on a channel. Body: { "muted": true|false }. Mute is a per-user preference and only affects notification dispatch, not real-time event delivery. MarkRead catches the caller up to the channel's latest message, clearing the sidebar unread badge. Idempotent — safe to call on an already-read channel.

func (*ChannelHandler) MarkUnread added in v0.0.81

func (h *ChannelHandler) MarkUnread(w http.ResponseWriter, r *http.Request)

MarkUnread makes a channel message (and everything after it) unread again for the caller — or, for a thread reply, re-opens the thread as unread. PUT /api/v1/channels/{id}/messages/{msgId}/unread

func (*ChannelHandler) NameAvailable added in v0.0.101

func (h *ChannelHandler) NameAvailable(w http.ResponseWriter, r *http.Request)

NameAvailable answers whether a channel may be called {name}: the create and rename dialogs ask while the name is typed, so a taken name shows before submitting. ?channel= is the channel being renamed — its own name counts as available to it. Guests can't create channels, so they get no answer about which names exist.

func (*ChannelHandler) RemoveMember

func (h *ChannelHandler) RemoveMember(w http.ResponseWriter, r *http.Request)

RemoveMember removes a user from a channel.

func (*ChannelHandler) SendMessage

func (h *ChannelHandler) SendMessage(w http.ResponseWriter, r *http.Request)

SendMessage creates a new message in a channel.

func (*ChannelHandler) SetIcon added in v0.0.118

func (h *ChannelHandler) SetIcon(w http.ResponseWriter, r *http.Request)

SetIcon sets or clears ({"icon": ""}) the emoji shown for the channel.

func (*ChannelHandler) SetMute

func (h *ChannelHandler) SetMute(w http.ResponseWriter, r *http.Request)

func (*ChannelHandler) SetNoUnfurl added in v0.0.11

func (h *ChannelHandler) SetNoUnfurl(w http.ResponseWriter, r *http.Request)

SetNoUnfurl flips the link-preview suppression flag on a channel message. Body: { "noUnfurl": bool }. Author-only.

func (*ChannelHandler) SetNotificationPrefs added in v0.0.50

func (h *ChannelHandler) SetNotificationPrefs(w http.ResponseWriter, r *http.Request)

SetNotificationPrefs sets the authenticated user's per-channel notification overrides. Body is the override object: each field may be omitted/null to inherit the account default, or set to an explicit value.

func (*ChannelHandler) SetPinned added in v0.0.2

func (h *ChannelHandler) SetPinned(w http.ResponseWriter, r *http.Request)

SetPinned pins or unpins a message in a channel. Body: { "pinned": bool }.

func (*ChannelHandler) ToggleReaction

func (h *ChannelHandler) ToggleReaction(w http.ResponseWriter, r *http.Request)

ToggleReaction adds or removes the caller's reaction (emoji) on a message.

func (*ChannelHandler) Unarchive added in v0.0.92

func (h *ChannelHandler) Unarchive(w http.ResponseWriter, r *http.Request)

Unarchive makes an archived channel writable again.

func (*ChannelHandler) Update

func (h *ChannelHandler) Update(w http.ResponseWriter, r *http.Request)

Update modifies a channel's name or description.

func (*ChannelHandler) UpdateMemberRole

func (h *ChannelHandler) UpdateMemberRole(w http.ResponseWriter, r *http.Request)

UpdateMemberRole changes a member's role in a channel.

type ChannelResolver added in v0.0.55

type ChannelResolver interface {
	GetByID(ctx context.Context, id string) (*model.Channel, error)
}

ChannelResolver loads one channel by ID so the channel-search endpoint can drop ghost hits the same way: a channel hard-deleted straight from DynamoDB leaves user-side membership rows behind, so its ID survives in the caller's allowed set and the stale index doc would otherwise surface as a clickable dead link.

type CodingTaskHandler added in v0.0.72

type CodingTaskHandler struct {
	// contains filtered or unexported fields
}

CodingTaskHandler serves the coding-task layer (plan-coding-agent.md): run-scoped tools the dev agent (and its runner) call, plus the human surface behind the task card — read, sign off, steering.

func NewCodingTaskHandler added in v0.0.72

func NewCodingTaskHandler(tasks *agents.CodingTaskService, orch *agents.Orchestrator) *CodingTaskHandler

NewCodingTaskHandler wires the handler.

func (*CodingTaskHandler) Close added in v0.0.72

Close ends a task by hand from the card: done (merge requests are open, Ex is finished) or abandoned (drop the work). Requester-only. POST /api/v1/coding-tasks/{id}/close

func (*CodingTaskHandler) Create added in v0.0.72

Create opens a coding task for the run's invoker (the create_coding_task tool). Deterministic side effects: project (product + repos) resolved or recorded, project channel, pinned task card, pointer back in the origin thread, kickoff run in the task thread. POST /api/v1/agent/run/coding-task

func (*CodingTaskHandler) Get added in v0.0.72

Get returns a task the caller can see (member of its project channel) — the task card's live data. GET /api/v1/coding-tasks/{id}

func (*CodingTaskHandler) ListByChannel added in v0.0.72

func (h *CodingTaskHandler) ListByChannel(w http.ResponseWriter, r *http.Request)

ListByChannel lists a project channel's tasks. GET /api/v1/channels/{id}/coding-tasks

func (*CodingTaskHandler) ListProjects added in v0.0.72

func (h *CodingTaskHandler) ListProjects(w http.ResponseWriter, r *http.Request)

ListProjects lists the known coding projects (products → repos). GET /api/v1/coding-projects

func (*CodingTaskHandler) Report added in v0.0.72

Report applies a lifecycle update from a task run (runner workspace beats, the agent's task_state tool, the MR step). POST /api/v1/agent/run/coding-task/report

func (*CodingTaskHandler) RequestMR added in v0.0.72

func (h *CodingTaskHandler) RequestMR(w http.ResponseWriter, r *http.Request)

RequestMR is the hard gate before push + MR (request_mr tool). Approved only with the requester's sign-off on record — the card button, or the approval this tool raises and passes back as approvalID. POST /api/v1/agent/run/coding-task/request-mr

func (*CodingTaskHandler) SetSteering added in v0.0.72

func (h *CodingTaskHandler) SetSteering(w http.ResponseWriter, r *http.Request)

SetSteering flips the per-task "anyone in channel may steer" toggle. PATCH /api/v1/coding-tasks/{id}

func (*CodingTaskHandler) SignOff added in v0.0.72

func (h *CodingTaskHandler) SignOff(w http.ResponseWriter, r *http.Request)

SignOff is the requester's "ship it" from the task card: records the sign-off and starts the push + MR run. POST /api/v1/coding-tasks/{id}/signoff

func (*CodingTaskHandler) TestPlan added in v0.0.72

func (h *CodingTaskHandler) TestPlan(w http.ResponseWriter, r *http.Request)

TestPlan publishes the requester-facing test plan (publish_test_plan tool): state → awaiting_user_test, deterministic "ready to test" note. POST /api/v1/agent/run/coding-task/test-plan

type CommandHandler added in v0.0.65

type CommandHandler struct {
	// contains filtered or unexported fields
}

CommandHandler exposes the slash-command registry: discovery for the composer's "/" autocomplete and execution.

func NewCommandHandler added in v0.0.65

func NewCommandHandler(commands *service.CommandService) *CommandHandler

NewCommandHandler creates a CommandHandler.

func (*CommandHandler) List added in v0.0.65

List returns the commands available to this workspace. An empty list is valid (no integrations configured) — clients then offer no commands.

func (*CommandHandler) Run added in v0.0.65

Run executes a slash command in a chat. The command posts its result into the chat itself (fanning out over WebSocket like any message); the response returns that message for the invoking client.

type ConnectorHandler added in v0.0.72

type ConnectorHandler struct {
	// contains filtered or unexported fields
}

ConnectorHandler serves the connector registry: listing (any user), ingest (admin), install/uninstall (per-user credential), and the runner-facing payload that ships docs + tokens to the invoker's machine.

func NewConnectorHandler added in v0.0.72

func NewConnectorHandler(c *agents.ConnectorService, runs liveRunGetter) *ConnectorHandler

func (*ConnectorHandler) Ingest added in v0.0.72

func (h *ConnectorHandler) Ingest(w http.ResponseWriter, r *http.Request)

Ingest registers or replaces a connector (route is admin-gated).

func (*ConnectorHandler) Install added in v0.0.72

func (h *ConnectorHandler) Install(w http.ResponseWriter, r *http.Request)

Install connects the caller: paste-a-token, or email/password for password-kind connectors (with a two-factor round trip when the auth service demands one).

func (*ConnectorHandler) List added in v0.0.72

List returns every connector with the caller's install status.

func (*ConnectorHandler) RunnerConnectors added in v0.0.72

func (h *ConnectorHandler) RunnerConnectors(w http.ResponseWriter, r *http.Request)

RunnerConnectors ships the run's connectors (docs + tokens) to the runner. Run-token scoped: claims.UserID is the run's INVOKER, so a run only ever sees the connectors of the person it acts for — and only the ones the invoking message explicitly picked with /connector tokens.

func (*ConnectorHandler) Sync added in v0.0.72

Sync pulls the connector catalog from the connector-provider and ingests it into the registry (admin-gated at the route). Replaces the old sync script.

func (*ConnectorHandler) Uninstall added in v0.0.72

func (h *ConnectorHandler) Uninstall(w http.ResponseWriter, r *http.Request)

Uninstall disconnects the caller from a connector.

func (*ConnectorHandler) UpdateInstall added in v0.0.72

func (h *ConnectorHandler) UpdateInstall(w http.ResponseWriter, r *http.Request)

UpdateInstall changes install settings — today just agentUse (may agents attach this connector themselves: ask | always | never).

func (*ConnectorHandler) UseConnector added in v0.0.72

func (h *ConnectorHandler) UseConnector(w http.ResponseWriter, r *http.Request)

UseConnector is the agent-initiated attach (the use_connector tool). Run-token scoped. Policy comes from the INVOKER's install:

never  → refused outright
always → attached immediately
ask    → first call raises the approval card HERE and returns
         {status:"ask", approvalID}; the runner waits for the decision and
         calls again with that id, which is verified by PURPOSE before
         attaching. The server owning both ends is what makes the check
         sound: the model neither writes the card's text nor picks which
         approval counts.

func (*ConnectorHandler) VerifyInstall added in v0.0.72

func (h *ConnectorHandler) VerifyInstall(w http.ResponseWriter, r *http.Request)

VerifyInstall re-checks an install's credential against the service (for "unverified" installs saved while the service was unreachable).

type ContextHandler added in v0.0.72

type ContextHandler struct {
	// contains filtered or unexported fields
}

ContextHandler serves the human side of shared context (plan-v2 §8): listing, adding, pinning and deleting the curated items agents read into every bundle for a channel/conversation.

func NewContextHandler added in v0.0.72

func NewContextHandler(ctxSvc *agents.ContextService) *ContextHandler

NewContextHandler wires the handler.

func (*ContextHandler) Create added in v0.0.72

func (h *ContextHandler) Create(w http.ResponseWriter, r *http.Request)

Create appends one item authored by the caller. POST /api/v1/context/{parentType}/{parentID}

func (*ContextHandler) Delete added in v0.0.72

func (h *ContextHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes an item. DELETE /api/v1/context/{parentType}/{parentID}/{itemID}

func (*ContextHandler) List added in v0.0.72

List returns a parent's shared-context items. GET /api/v1/context/{parentType}/{parentID}

func (*ContextHandler) SetPinned added in v0.0.72

func (h *ContextHandler) SetPinned(w http.ResponseWriter, r *http.Request)

SetPinned toggles an item's trim priority. PATCH /api/v1/context/{parentType}/{parentID}/{itemID}

type ConversationHandler

type ConversationHandler struct {
	// contains filtered or unexported fields
}

ConversationHandler exposes HTTP endpoints for conversation operations.

func NewConversationHandler

func NewConversationHandler(convSvc *service.ConversationService, messageSvc *service.MessageService) *ConversationHandler

NewConversationHandler creates a ConversationHandler.

func (*ConversationHandler) Act added in v0.0.116

Act clicks a button on a conversation message (see ChannelHandler.Act).

func (*ConversationHandler) Create

Create starts a new direct message or group conversation.

func (*ConversationHandler) DeleteMessage

func (h *ConversationHandler) DeleteMessage(w http.ResponseWriter, r *http.Request)

DeleteMessage removes a message from a conversation.

func (*ConversationHandler) EditMessage

func (h *ConversationHandler) EditMessage(w http.ResponseWriter, r *http.Request)

EditMessage updates a message in a conversation.

func (*ConversationHandler) Get

Get returns a single conversation by ID.

func (*ConversationHandler) GetThread

func (h *ConversationHandler) GetThread(w http.ResponseWriter, r *http.Request)

GetThread returns all messages in the thread rooted at msgId for a conversation.

func (*ConversationHandler) List

List returns all conversations the authenticated user participates in.

func (*ConversationHandler) ListFiles added in v0.0.8

func (h *ConversationHandler) ListFiles(w http.ResponseWriter, r *http.Request)

ListFiles returns one page of the files shared in the conversation, newest first (see fileQuery for the parameters).

func (*ConversationHandler) ListMessages

func (h *ConversationHandler) ListMessages(w http.ResponseWriter, r *http.Request)

ListMessages returns messages for a conversation. Supports ?cursor= (older), ?after= (newer), and ?around=<msgId> (window).

func (*ConversationHandler) ListPinned added in v0.0.2

func (h *ConversationHandler) ListPinned(w http.ResponseWriter, r *http.Request)

ListPinned returns the conversation's currently-pinned messages.

func (*ConversationHandler) MarkRead added in v0.0.26

func (h *ConversationHandler) MarkRead(w http.ResponseWriter, r *http.Request)

func (*ConversationHandler) MarkUnread added in v0.0.81

func (h *ConversationHandler) MarkUnread(w http.ResponseWriter, r *http.Request)

MarkUnread is the conversation (DM / group / self-DM) counterpart. PUT /api/v1/conversations/{id}/messages/{msgId}/unread

func (*ConversationHandler) SendMessage

func (h *ConversationHandler) SendMessage(w http.ResponseWriter, r *http.Request)

SendMessage creates a new message in a conversation.

func (*ConversationHandler) SetMute added in v0.0.118

SetMute mutes or unmutes ({"muted": bool}) the caller's chat with a bot or a webhook. A chat with a person is refused.

func (*ConversationHandler) SetNoUnfurl added in v0.0.11

func (h *ConversationHandler) SetNoUnfurl(w http.ResponseWriter, r *http.Request)

SetNoUnfurl flips the link-preview suppression flag on a conversation message. Body: { "noUnfurl": bool }. Author-only.

func (*ConversationHandler) SetPinned added in v0.0.2

func (h *ConversationHandler) SetPinned(w http.ResponseWriter, r *http.Request)

SetPinned pins or unpins a message in a conversation.

func (*ConversationHandler) ToggleReaction

func (h *ConversationHandler) ToggleReaction(w http.ResponseWriter, r *http.Request)

ToggleReaction adds or removes the caller's reaction (emoji) on a message.

type ConversationParticipantLister added in v0.0.46

type ConversationParticipantLister struct {
	// contains filtered or unexported fields
}

ConversationParticipantLister adapts a conversation getter to the eventlog.ParticipantLister interface.

func NewConversationParticipantLister added in v0.0.46

func NewConversationParticipantLister(get GetConversationFunc) *ConversationParticipantLister

NewConversationParticipantLister wraps a conversation getter function so it resolves recipients for conversation topics.

func (*ConversationParticipantLister) ParticipantIDs added in v0.0.46

func (c *ConversationParticipantLister) ParticipantIDs(ctx context.Context, conversationID string) ([]string, error)

ParticipantIDs returns the participant userIDs for the conversation. Returns an empty slice (not an error) for a missing conversation — publish-time fan-out should never fail an action because a stale topic resolved nothing.

type Deps added in v0.0.45

type Deps struct {
	// Required core.
	Auth         *AuthHandler
	User         *UserHandler
	Channel      *ChannelHandler
	Conversation *ConversationHandler
	WS           *WSHandler
	JWT          *auth.JWTManager

	// Optional resource handlers — nil disables the corresponding routes.
	UserState  *UserStateHandler
	Upload     *UploadHandler
	Emoji      *EmojiHandler
	Presence   *PresenceHandler
	Attachment *AttachmentHandler
	Admin      *AdminHandler
	Thread     *ThreadHandler
	Draft      *DraftHandler
	Version    *VersionHandler
	Unfurl     *UnfurlHandler
	Sidebar    *SidebarHandler
	Search     *SearchHandler
	Webhook    *WebhookHandler
	// Interaction serves app interactivity (setup, response URLs).
	Interaction *InteractionHandler
	// Bot accounts: the admin page's API, and the Mattermost-compatible API
	// (/api/v4) bots call with their tokens.
	Bot        *BotHandler
	Mattermost *MattermostHandler
	// User groups: mentionable named sets of people (/api/v1/usergroups).
	UserGroup *UserGroupHandler
	Activity  *ActivityHandler
	Command   *CommandHandler
	// SharePoint serves posted SharePoint links; nil unless SharePoint
	// sharing is configured.
	SharePoint *SharePointHandler
	// Scheduled messages: compose now, deliver at a chosen time.
	ScheduledMessage *ScheduledMessageHandler
	// Agent orchestration (plan-v2): SPA surface, ex-runner API, and the
	// run-scoped MCP tool API. All three nil-skippable as a unit.
	Agent        *AgentHandler
	AgentRunner  *AgentRunnerHandler
	AgentRunTool *AgentRunToolHandler
	// ex-runner pairing, renewal and the Runners page. Also the revocation
	// check behind every runner route: nil means NO runner token is accepted.
	RunnerToken *RunnerTokenHandler
	// Shared context (CTX#, plan-v2 §8): the human curation surface.
	Context *ContextHandler
	// Connectors: external-service API docs + per-user credentials.
	Connector *ConnectorHandler
	// Coding tasks (plan-coding-agent.md): run-scoped task tools + the human
	// task-card surface. Registered only when AgentRunTool is also set.
	CodingTask *CodingTaskHandler
	// Project serves the Projects page (products + design references).
	Project *ProjectHandler

	// SPA/static.
	FrontendFS fs.FS
	AppVersion string
	// SentryFrontend, when its DSN is set, is stamped into the served
	// index.html as meta tags so the SPA (in browsers and both native shells)
	// initializes Sentry — an ops-only opt-in, no client rebuild needed.
	SentryFrontend SentryFrontendConfig

	// CORS / cross-origin policy. The first non-empty entry is treated
	// as the canonical primary origin in the middleware.
	AllowOrigins []string

	// BaseURL is the public URL browsers open the app at. Its host joins the
	// request's own in the page's frame-src for the HTML preview route, in
	// case a proxy in front rewrites Host.
	BaseURL string

	// UploadConnectSrc lists extra CSP connect-src origins for the
	// direct-to-storage browser uploads (the presigned-PUT endpoint). Only
	// needed when that endpoint is plain http (local MinIO) — production
	// https stores are covered by the base policy.
	UploadConnectSrc []string

	// FrameSrc lists the https origins the page may frame: the SharePoint
	// hosts a shared file's preview loads from. Empty unless SharePoint
	// sharing is on.
	FrameSrc []string

	// DisableAccessLog silences per-request logging except 5xx responses
	// (ACCESS_LOG_ENABLED=false). Zero value keeps full access logging.
	DisableAccessLog bool

	// RateLimiter throttles unauthenticated auth + webhook endpoints per client
	// IP. Nil disables rate limiting (e.g. in tests).
	RateLimiter middleware.RateLimitCounter
}

Deps is the single set of dependencies the HTTP router needs to wire up the API surface. Bundling them into a struct (instead of a long positional parameter list on NewRouter) means adding a new endpoint only requires adding a field here — not editing every call-site or rotating positional args.

Optional handlers (Search, Sidebar, Unfurl, …) may be left nil; the router skips their route registrations. The required core (Auth, User, Channel, Conversation, WS, JWT) is asserted in NewRouter.

type DraftHandler added in v0.0.23

type DraftHandler struct {
	// contains filtered or unexported fields
}

DraftHandler exposes server-side message draft endpoints.

func NewDraftHandler added in v0.0.23

func NewDraftHandler(draftSvc *service.DraftService) *DraftHandler

func (*DraftHandler) Delete added in v0.0.23

func (h *DraftHandler) Delete(w http.ResponseWriter, r *http.Request)

func (*DraftHandler) List added in v0.0.23

func (h *DraftHandler) List(w http.ResponseWriter, r *http.Request)

func (*DraftHandler) Upsert added in v0.0.23

func (h *DraftHandler) Upsert(w http.ResponseWriter, r *http.Request)

type EmojiHandler

type EmojiHandler struct {
	// contains filtered or unexported fields
}

EmojiHandler exposes HTTP endpoints for custom emoji management.

func NewEmojiHandler

func NewEmojiHandler(s *service.EmojiService) *EmojiHandler

NewEmojiHandler creates an EmojiHandler.

func (*EmojiHandler) Create

func (h *EmojiHandler) Create(w http.ResponseWriter, r *http.Request)

Create adds a new custom emoji. The image must already be uploaded; the caller passes the resulting fileURL.

func (*EmojiHandler) Delete

func (h *EmojiHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a custom emoji. Only admins or the creator may delete.

func (*EmojiHandler) List

func (h *EmojiHandler) List(w http.ResponseWriter, r *http.Request)

List returns all custom emojis defined in the workspace.

func (*EmojiHandler) ListFrequent added in v0.0.47

func (h *EmojiHandler) ListFrequent(w http.ResponseWriter, r *http.Request)

ListFrequent returns the caller's most-used emoji shortcodes, highest count first, capped by the optional `limit` query parameter.

func (*EmojiHandler) RecordFrequent added in v0.0.47

func (h *EmojiHandler) RecordFrequent(w http.ResponseWriter, r *http.Request)

RecordFrequent records one use of an emoji shortcode by the caller so it can surface in their frequently-used shelf.

type GetConversationFunc added in v0.0.46

type GetConversationFunc func(ctx context.Context, id string) (*model.Conversation, error)

GetConversationFunc abstracts the conversation store's get-by-ID for the same reason.

type InboxReplayer added in v0.0.46

type InboxReplayer interface {
	Replay(ctx context.Context, userID string, since string) (eventlog.ReplayResult, error)
}

InboxReplayer is the subset of the durable event log used by the WS handshake replay path.

type InteractionHandler added in v0.0.116

type InteractionHandler struct {
	// contains filtered or unexported fields
}

InteractionHandler serves app interactivity: its setup in the webhooks panel, and the response_url apps answer clicks through.

func NewInteractionHandler added in v0.0.116

func NewInteractionHandler(svc *service.InteractionService) *InteractionHandler

NewInteractionHandler creates an InteractionHandler.

func (*InteractionHandler) CloseView added in v0.0.116

func (h *InteractionHandler) CloseView(w http.ResponseWriter, r *http.Request)

CloseView forgets a form its person closed. Body (optional): {"all": true} closes its whole stack; "values" is what was entered, for an app that asked to hear about closing.

func (*InteractionHandler) MessagesUpdate added in v0.0.116

func (h *InteractionHandler) MessagesUpdate(w http.ResponseWriter, r *http.Request)

MessagesUpdate replaces one of the app's messages. Body: {"channel_id", "message_id", "text"/"blocks"/"attachments", optional "if_version"}.

func (*InteractionHandler) PreviewView added in v0.0.116

func (h *InteractionHandler) PreviewView(w http.ResponseWriter, r *http.Request)

PreviewView answers with a form as ex would draw it, for the webhooks panel's builder. Body: a view.

func (*InteractionHandler) Respond added in v0.0.116

Respond takes an app's answer to a click, posted to its response_url. No session: the URL's token is the credential. The answer follows Slack's shape: {"ok": true}, or {"ok": false, "error": "<code>"}.

func (*InteractionHandler) RotateBotToken added in v0.0.116

func (h *InteractionHandler) RotateBotToken(w http.ResponseWriter, r *http.Request)

RotateBotToken issues a bot token; the answer is the only time it is shown. Body: {"revokeNow": bool}.

func (*InteractionHandler) RotateSigningSecret added in v0.0.116

func (h *InteractionHandler) RotateSigningSecret(w http.ResponseWriter, r *http.Request)

RotateSigningSecret issues a signing secret, shown once. Body as above.

func (*InteractionHandler) SendTest added in v0.0.116

func (h *InteractionHandler) SendTest(w http.ResponseWriter, r *http.Request)

SendTest sends the app a signed sample click and answers with how it went.

func (*InteractionHandler) SetEmailSharing added in v0.0.116

func (h *InteractionHandler) SetEmailSharing(w http.ResponseWriter, r *http.Request)

SetEmailSharing turns sharing clickers' emails with the app on or off. Body: {"enabled": bool}. Workspace admins only.

func (*InteractionHandler) SetPaused added in v0.0.116

func (h *InteractionHandler) SetPaused(w http.ResponseWriter, r *http.Request)

SetPaused stops or resumes the app's buttons. Body: {"enabled": bool}. Workspace admins only.

func (*InteractionHandler) SetRequestURL added in v0.0.116

func (h *InteractionHandler) SetRequestURL(w http.ResponseWriter, r *http.Request)

SetRequestURL sets (or, empty, clears) where the app receives clicks. Body: {"requestURL": "https://…"}.

func (*InteractionHandler) Status added in v0.0.116

Status answers with a webhook's interactivity: settings, pause, history.

func (*InteractionHandler) SubmitView added in v0.0.116

func (h *InteractionHandler) SubmitView(w http.ResponseWriter, r *http.Request)

SubmitView sends a person's form to its app. Body: {"values": {block_id: {action_id: <raw value>}}} — text as typed, a date as YYYY-MM-DD, a time as HH:MM, an option's value or a user ID; a list of them for multi-selects and checkboxes.

func (*InteractionHandler) ViewAction added in v0.0.116

func (h *InteractionHandler) ViewAction(w http.ResponseWriter, r *http.Request)

ViewAction sends a change in a person's form to its app. Body: {"blockID", "actionID", "value" (string or list), "values" (the form as it stands, like a submission's)}.

func (*InteractionHandler) ViewsOpen added in v0.0.116

func (h *InteractionHandler) ViewsOpen(w http.ResponseWriter, r *http.Request)

ViewsOpen opens a form for the person whose click minted the trigger_id. Body: {"trigger_id", "view"}.

func (*InteractionHandler) ViewsPush added in v0.0.116

func (h *InteractionHandler) ViewsPush(w http.ResponseWriter, r *http.Request)

ViewsPush stacks a form on the one the person is in. Body: {"trigger_id" (from that form), "view"}.

func (*InteractionHandler) ViewsUpdate added in v0.0.116

func (h *InteractionHandler) ViewsUpdate(w http.ResponseWriter, r *http.Request)

ViewsUpdate changes an open form. Body: {"view_id" or "external_id", optional "hash", "view"}.

type JSON

type JSON map[string]interface{}

JSON is a convenience type for building JSON response objects.

type ListMembersFunc added in v0.0.46

type ListMembersFunc func(ctx context.Context, channelID string) ([]*model.ChannelMembership, error)

ListMembersFunc abstracts the membership store's channel-member listing so the eventlog adapter doesn't depend on a concrete store type. internal/app passes the bound method; tests pass a closure.

type MappingRebuildController added in v0.0.56

type MappingRebuildController interface {
	Start(ctx context.Context, now func() int64) (bool, error)
	Status(ctx context.Context) (search.MappingRebuildStatus, error)
	SchemaVersions(ctx context.Context) ([]search.SchemaVersionInfo, error)
}

MappingRebuildController is the slim view AdminHandler needs to trigger and report the cluster-coordinated users/channels mapping rebuild. The concrete *search.MappingRebuilder satisfies it; tests inject a fake.

type MattermostHandler added in v0.0.112

type MattermostHandler struct {
	// contains filtered or unexported fields
}

MattermostHandler is the Mattermost-compatible REST API (/api/v4): the calls an integration written against Mattermost makes to open an incident channel, add people to it, post, and message someone directly, authenticated with a bot's access token. Requests and answers keep Mattermost's wire format — its field names, millisecond timestamps, status codes and error body — so such an integration only changes its base URL and token.

func NewMattermostHandler added in v0.0.112

func NewMattermostHandler(bots *service.BotService, users *service.UserService, mm *service.MattermostService) *MattermostHandler

NewMattermostHandler returns the Mattermost API handler.

func (*MattermostHandler) AddChannelMember added in v0.0.112

func (h *MattermostHandler) AddChannelMember(w http.ResponseWriter, r *http.Request)

AddChannelMember answers POST /api/v4/channels/{channel_id}/members.

func (*MattermostHandler) Authenticate added in v0.0.112

func (h *MattermostHandler) Authenticate(next http.Handler) http.Handler

Authenticate admits requests made with a bot's token: the request then acts as that bot, with a member's rights. Session tokens are refused here, and bot tokens everywhere else.

func (*MattermostHandler) CreateChannel added in v0.0.112

func (h *MattermostHandler) CreateChannel(w http.ResponseWriter, r *http.Request)

CreateChannel answers POST /api/v4/channels. ex has one workspace, so any team_id is taken, and channels have one name, so display_name and header are answered back but not kept; the purpose becomes the description.

func (*MattermostHandler) CreateDirectChannel added in v0.0.112

func (h *MattermostHandler) CreateDirectChannel(w http.ResponseWriter, r *http.Request)

CreateDirectChannel answers POST /api/v4/channels/direct: the body is the two user IDs, the bot's own among them. The conversation shows up for the other person with its first message.

func (*MattermostHandler) CreatePost added in v0.0.112

func (h *MattermostHandler) CreatePost(w http.ResponseWriter, r *http.Request)

CreatePost answers POST /api/v4/posts: to a channel the bot is a member of, or a direct channel it opened; root_id makes it a thread reply.

func (*MattermostHandler) Me added in v0.0.112

Me answers GET /api/v4/users/me: the bot itself.

func (*MattermostHandler) UserByEmail added in v0.0.112

func (h *MattermostHandler) UserByEmail(w http.ResponseWriter, r *http.Request)

UserByEmail answers GET /api/v4/users/email/{email}.

type MembershipMemberLister added in v0.0.46

type MembershipMemberLister struct {
	// contains filtered or unexported fields
}

MembershipMemberLister adapts a channel-membership lister to the eventlog.MemberLister interface (just userIDs, not full membership rows) so the publisher can fan-out to per-user inboxes without pulling the full membership model through the eventlog package.

func NewMembershipMemberLister added in v0.0.46

func NewMembershipMemberLister(list ListMembersFunc) *MembershipMemberLister

NewMembershipMemberLister wraps a channel-membership listing function so it resolves recipients for the durable event log.

func (*MembershipMemberLister) MemberIDs added in v0.0.46

func (m *MembershipMemberLister) MemberIDs(ctx context.Context, channelID string) ([]string, error)

MemberIDs returns the user IDs of all members of the channel. Empty/nil rows are filtered so an empty userID can't propagate to XADD (where it would fail anyway).

type NotificationAckRecorder added in v0.0.51

type NotificationAckRecorder interface {
	MarkNotificationAcked(ctx context.Context, userID, messageID string) error
}

NotificationAckRecorder records a client's acknowledgement that it received (and surfaced) the desktop notification for a message. The deferred mobile-push fallback reads these to avoid double-notifying a desktop that actually delivered. Implemented by the Redis cache.

type ParentIndexAdapter added in v0.0.45

type ParentIndexAdapter struct {
	// contains filtered or unexported fields
}

ParentIndexAdapter bridges store.ParentIndexStoreImpl into the service layer's ParentPinFileIndexStore interface (named after its concrete consumers — ListPinned and ListFiles — so service code reads as "set pin index, set file index" without importing the store package).

func NewParentIndexAdapter added in v0.0.45

func NewParentIndexAdapter(s *store.ParentIndexStoreImpl) *ParentIndexAdapter

func (*ParentIndexAdapter) DeleteFileIndex added in v0.0.45

func (a *ParentIndexAdapter) DeleteFileIndex(ctx context.Context, parentID, attachmentID string) error

func (*ParentIndexAdapter) DeletePinIndex added in v0.0.45

func (a *ParentIndexAdapter) DeletePinIndex(ctx context.Context, parentID, msgID string) error

func (*ParentIndexAdapter) ListFileIndex added in v0.0.45

func (a *ParentIndexAdapter) ListFileIndex(ctx context.Context, parentID string) ([]service.FileIndexEntry, error)

func (*ParentIndexAdapter) ListPinIndex added in v0.0.45

func (a *ParentIndexAdapter) ListPinIndex(ctx context.Context, parentID string) ([]service.PinIndexEntry, error)

func (*ParentIndexAdapter) SetFileIndex added in v0.0.45

func (a *ParentIndexAdapter) SetFileIndex(ctx context.Context, parentID, attachmentID, msgID, authorID string, createdAt time.Time) error

func (*ParentIndexAdapter) SetFileIndexName added in v0.0.103

func (a *ParentIndexAdapter) SetFileIndexName(ctx context.Context, parentID, attachmentID, filename string) error

func (*ParentIndexAdapter) SetPinIndex added in v0.0.45

func (a *ParentIndexAdapter) SetPinIndex(ctx context.Context, parentID, msgID, pinnedBy string, pinnedAt time.Time) error

type PresenceHandler

type PresenceHandler struct {
	// contains filtered or unexported fields
}

PresenceHandler exposes HTTP endpoints for online presence.

func NewPresenceHandler

func NewPresenceHandler(s *service.PresenceService) *PresenceHandler

NewPresenceHandler creates a PresenceHandler.

func (*PresenceHandler) List

List returns the user IDs currently considered online. Used by clients on connect to backfill presence state before subscribing to the presence pub/sub channel for live updates.

func (*PresenceHandler) SetAlwaysOnline added in v0.0.72

func (h *PresenceHandler) SetAlwaysOnline(f func(r *http.Request) []string)

SetAlwaysOnline wires the always-online roster (agent user IDs). Optional.

func (*PresenceHandler) Wired added in v0.0.97

func (h *PresenceHandler) Wired() error

type ProjectHandler added in v0.0.89

type ProjectHandler struct {
	// contains filtered or unexported fields
}

ProjectHandler serves the Projects page (plan-projects-design.md): products with their design references and reference screenshots.

func NewProjectHandler added in v0.0.89

func NewProjectHandler(p *agents.ProjectService) *ProjectHandler

NewProjectHandler wires the handler.

func (*ProjectHandler) AddScreen added in v0.0.89

func (h *ProjectHandler) AddScreen(w http.ResponseWriter, r *http.Request)

AddScreen adds a reference screenshot (the image is uploaded first through the normal attachment flow). POST /api/v1/projects/{key}/screens

func (*ProjectHandler) Create added in v0.0.89

func (h *ProjectHandler) Create(w http.ResponseWriter, r *http.Request)

Create registers a project. POST /api/v1/projects

func (*ProjectHandler) Delete added in v0.0.89

func (h *ProjectHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a project and its screens. DELETE /api/v1/projects/{key}

func (*ProjectHandler) DeleteScreen added in v0.0.89

func (h *ProjectHandler) DeleteScreen(w http.ResponseWriter, r *http.Request)

DeleteScreen removes a screen. DELETE /api/v1/projects/{key}/screens/{id}

func (*ProjectHandler) Get added in v0.0.89

Get returns one project with its screens. GET /api/v1/projects/{key}

func (*ProjectHandler) List added in v0.0.89

List returns every project with gallery counts. GET /api/v1/projects

func (*ProjectHandler) Update added in v0.0.89

func (h *ProjectHandler) Update(w http.ResponseWriter, r *http.Request)

Update patches a project. PATCH /api/v1/projects/{key}

func (*ProjectHandler) UpdateScreen added in v0.0.89

func (h *ProjectHandler) UpdateScreen(w http.ResponseWriter, r *http.Request)

UpdateScreen edits a screen's labels or replaces its image. PATCH /api/v1/projects/{key}/screens/{id}

type ReminderService added in v0.0.54

type ReminderService interface {
	Schedule(ctx context.Context, userID string, in service.ReminderInput) (*model.Reminder, error)
	ListPending(ctx context.Context, userID string) ([]*model.Reminder, error)
	Cancel(ctx context.Context, userID, id string) error
	Update(ctx context.Context, userID, id string, in service.ReminderUpdate) (*model.Reminder, error)
}

ReminderService is the reminder behaviour the handler needs.

type RunnerTokenHandler added in v0.0.89

type RunnerTokenHandler struct {
	// contains filtered or unexported fields
}

RunnerTokenHandler serves ex-runner pairing and the Runners page:

POST   /api/v1/runner-tokens/grants    session   browser approves a pairing → one-time code
POST   /api/v1/runner-tokens/exchange  public    CLI redeems code + PKCE verifier → runner token
GET    /api/v1/runner-tokens           session   the caller's connected runners
DELETE /api/v1/runner-tokens/{id}      session   disconnect one of them
POST   /api/v1/runner-tokens/workbench session   Connect to Claude (agent workbench)
GET    /api/v1/runner-tokens/workbench session   how that setup is going
POST   /api/v1/agent/runner/renew      runner    fresh expiry, same install
POST   /api/v1/agent/runner/revoke     runner    `ex-runner logout`

func NewRunnerTokenHandler added in v0.0.89

func NewRunnerTokenHandler(svc *agents.RunnerTokenService) *RunnerTokenHandler

NewRunnerTokenHandler wires the handler.

func (*RunnerTokenHandler) Checker added in v0.0.89

Checker exposes the service as the runner middleware's revocation check.

func (*RunnerTokenHandler) ConnectWorkbench added in v0.0.119

func (h *RunnerTokenHandler) ConnectWorkbench(w http.ResponseWriter, r *http.Request)

ConnectWorkbench POST /api/v1/runner-tokens/workbench: Connect to Claude. ex issues the caller a runner token and hands it to the agent workbench, which queues setting up a runner for them; the answer is that job. The token never comes back here.

func (*RunnerTokenHandler) CreateGrant added in v0.0.89

func (h *RunnerTokenHandler) CreateGrant(w http.ResponseWriter, r *http.Request)

CreateGrant POST /api/v1/runner-tokens/grants

func (*RunnerTokenHandler) Exchange added in v0.0.89

func (h *RunnerTokenHandler) Exchange(w http.ResponseWriter, r *http.Request)

Exchange POST /api/v1/runner-tokens/exchange

func (*RunnerTokenHandler) List added in v0.0.89

List GET /api/v1/runner-tokens

func (*RunnerTokenHandler) Renew added in v0.0.89

Renew POST /api/v1/agent/runner/renew

func (*RunnerTokenHandler) Revoke added in v0.0.89

Revoke DELETE /api/v1/runner-tokens/{id}

func (*RunnerTokenHandler) RevokeSelf added in v0.0.89

func (h *RunnerTokenHandler) RevokeSelf(w http.ResponseWriter, r *http.Request)

RevokeSelf POST /api/v1/agent/runner/revoke

func (*RunnerTokenHandler) SetLiveRunners added in v0.0.89

func (h *RunnerTokenHandler) SetLiveRunners(l liveRunnerLister)

SetLiveRunners lets the list say which installs are online right now. Optional: without it every install lists as offline.

func (*RunnerTokenHandler) Wired added in v0.0.97

func (h *RunnerTokenHandler) Wired() error

func (*RunnerTokenHandler) WorkbenchStatus added in v0.0.119

func (h *RunnerTokenHandler) WorkbenchStatus(w http.ResponseWriter, r *http.Request)

WorkbenchStatus GET /api/v1/runner-tokens/workbench: how the caller's onboarding on the agent workbench is going.

type ScheduledMessageHandler added in v0.0.81

type ScheduledMessageHandler struct {
	// contains filtered or unexported fields
}

ScheduledMessageHandler serves /api/v1/scheduled-messages: compose now, deliver at a chosen time.

func NewScheduledMessageHandler added in v0.0.81

func NewScheduledMessageHandler(svc scheduledMessages) *ScheduledMessageHandler

NewScheduledMessageHandler builds a ScheduledMessageHandler.

func (*ScheduledMessageHandler) Create added in v0.0.81

Create schedules a message. POST /api/v1/scheduled-messages

func (*ScheduledMessageHandler) Delete added in v0.0.81

Delete drops a scheduled message. DELETE /api/v1/scheduled-messages/{id}

func (*ScheduledMessageHandler) List added in v0.0.81

List returns the caller's scheduled messages, soonest first. GET /api/v1/scheduled-messages

func (*ScheduledMessageHandler) SendNow added in v0.0.81

SendNow posts a scheduled message immediately (also retries a failed one). POST /api/v1/scheduled-messages/{id}/send

func (*ScheduledMessageHandler) Update added in v0.0.81

Update edits a scheduled message's text and/or time. PATCH /api/v1/scheduled-messages/{id}

type SearchAccess added in v0.0.13

type SearchAccess interface {
	AllowedParentIDs(ctx context.Context, userID string) ([]string, error)
}

SearchAccess resolves the parent IDs (channels + conversations) the caller is allowed to see, so the message-search endpoint can apply the same RBAC the read paths do. Returning an empty slice means "no access" and the handler short-circuits with an empty result.

type SearchHandler added in v0.0.13

type SearchHandler struct {
	// contains filtered or unexported fields
}

SearchHandler exposes the public search endpoints. Searcher may be a noop implementation when search isn't configured — in that case the endpoints return empty results rather than 503 so the UI can show "no results" cleanly.

func NewSearchHandler added in v0.0.13

func NewSearchHandler(s search.Searcher, a SearchAccess, users UserResolver, channels ChannelResolver) *SearchHandler

NewSearchHandler builds a handler. Any dependency may be nil: a nil searcher/access degrades to empty responses, a nil resolver skips ghost filtering. The resolvers are constructor arguments — not setters — so internal/app can't silently forget to wire them.

func (*SearchHandler) SearchChannels added in v0.0.13

func (h *SearchHandler) SearchChannels(w http.ResponseWriter, r *http.Request)

SearchChannels handles GET /api/v1/search/channels?q=&limit=

func (*SearchHandler) SearchFiles added in v0.0.13

func (h *SearchHandler) SearchFiles(w http.ResponseWriter, r *http.Request)

SearchFiles handles GET /api/v1/search/files — same shape as SearchMessages but matches against attachment filenames.

func (*SearchHandler) SearchMessages added in v0.0.13

func (h *SearchHandler) SearchMessages(w http.ResponseWriter, r *http.Request)

SearchMessages handles GET /api/v1/search/messages Query params: q, limit, from, in, sort. RBAC filters by membership.

func (*SearchHandler) SearchUsers added in v0.0.13

func (h *SearchHandler) SearchUsers(w http.ResponseWriter, r *http.Request)

SearchUsers handles GET /api/v1/search/users?q=&limit=

type SearchStatusReporter added in v0.0.13

type SearchStatusReporter interface {
	ClusterHealth(ctx context.Context) (map[string]any, error)
	IndexStats(ctx context.Context) ([]search.IndexStat, error)
}

SearchStatusReporter is the slim view AdminHandler needs to render the search status panel: cluster health + per-index docs/size. The concrete *search.Client satisfies this directly.

type SentryFrontendConfig added in v0.0.57

type SentryFrontendConfig struct {
	DSN                     string
	TracesSampleRate        float64
	ReplaySessionSampleRate float64
	ReplayErrorSampleRate   float64
}

SentryFrontendConfig is the frontend error-reporting opt-in served to the SPA via meta tags. Rates are 0..1; zero means off.

type SharePointHandler added in v0.0.116

type SharePointHandler struct {
	// contains filtered or unexported fields
}

SharePointHandler exposes posted SharePoint links: their card, retrying one that failed to share, and a shared file's preview.

func NewSharePointHandler added in v0.0.116

func NewSharePointHandler(svc SharePointService) *SharePointHandler

Link returns a posted link's card: GET /api/v1/sharepoint/link?parentType= channel|conversation&parentID=…&url=…. 204 when the link was never shared.

func (*SharePointHandler) Preview added in v0.0.116

func (h *SharePointHandler) Preview(w http.ResponseWriter, r *http.Request)

Preview returns a short-lived address showing a shared file as it is, for the caller only: GET /api/v1/sharepoint/preview?parentType=channel| conversation&parentID=…&fileID=….

func (*SharePointHandler) Retry added in v0.0.116

Retry shares a link that failed again, as its poster: POST /api/v1/sharepoint/link/retry with {parentType, parentID, url}.

func (*SharePointHandler) UploadConversationOfficeFile added in v0.0.116

func (h *SharePointHandler) UploadConversationOfficeFile(w http.ResponseWriter, r *http.Request)

UploadConversationOfficeFile is UploadOfficeFile for a DM or group DM: PUT /api/v1/conversations/{id}/office-files?name=….

func (*SharePointHandler) UploadOfficeFile added in v0.0.116

func (h *SharePointHandler) UploadOfficeFile(w http.ResponseWriter, r *http.Request)

UploadOfficeFile puts an Office file posted in a channel into the caller's OneDrive: PUT /api/v1/channels/{id}/office-files?name=…, the file as the body. 409 when they have no working Microsoft sign-in; any refusal tells the client to attach it the ordinary way instead.

type SharePointService added in v0.0.116

type SharePointService interface {
	Link(ctx context.Context, viewerID, parentID, parentType, rawURL string) (*model.SharePointLink, error)
	RetryLink(ctx context.Context, userID, parentID, parentType, rawURL string) error
	Preview(ctx context.Context, viewerID, parentID, parentType, fileID string) (string, error)
	UploadOfficeFile(ctx context.Context, userID, parentID, parentType, name string, body io.Reader, size int64) (*service.OfficeUpload, error)
}

SharePointService is the SharePoint-link behaviour the handler needs.

type SidebarHandler added in v0.0.3

type SidebarHandler struct {
	// contains filtered or unexported fields
}

SidebarHandler exposes the per-user sidebar customisation endpoints: favorite/unfavorite, assign-to-category (for both channels and conversations), and category CRUD.

func NewSidebarHandler added in v0.0.3

func NewSidebarHandler(channelSvc *service.ChannelService, convSvc *service.ConversationService, categorySvc *service.CategoryService) *SidebarHandler

func (*SidebarHandler) CreateCategory added in v0.0.3

func (h *SidebarHandler) CreateCategory(w http.ResponseWriter, r *http.Request)

CreateCategory adds a new category for the calling user.

func (*SidebarHandler) DeleteCategory added in v0.0.3

func (h *SidebarHandler) DeleteCategory(w http.ResponseWriter, r *http.Request)

DeleteCategory removes a category.

func (*SidebarHandler) ListCategories added in v0.0.3

func (h *SidebarHandler) ListCategories(w http.ResponseWriter, r *http.Request)

ListCategories returns the user's sidebar categories.

func (*SidebarHandler) Move added in v0.0.59

Move applies a drag-and-drop reorder as an EVENT: "item X dropped into section S directly after item A". The server resolves it against the canonical layout and computes every resulting position itself — clients never send position numbers (a stale client used to write ordering math computed against a layout that had already moved on, which is exactly how drops landed one slot off). A stale anchor yields 409; the client refetches the truth and the user drops again against current state.

func (*SidebarHandler) MoveCategory added in v0.0.59

func (h *SidebarHandler) MoveCategory(w http.ResponseWriter, r *http.Request)

MoveCategory reorders a sidebar category the same event-shaped way: "category X dropped directly after category A" (empty = first). Returns the categories in their new canonical order.

func (*SidebarHandler) SetCategory added in v0.0.3

func (h *SidebarHandler) SetCategory(w http.ResponseWriter, r *http.Request)

SetCategory assigns the channel to a sidebar category (or clears the assignment when categoryID is empty).

func (*SidebarHandler) SetConversationCategory added in v0.0.3

func (h *SidebarHandler) SetConversationCategory(w http.ResponseWriter, r *http.Request)

SetConversationCategory assigns a DM/group to one of the user's sidebar categories, like a channel (or clears the assignment when categoryID is empty), and stores its sidebar position.

func (*SidebarHandler) SetConversationFavorite added in v0.0.3

func (h *SidebarHandler) SetConversationFavorite(w http.ResponseWriter, r *http.Request)

SetConversationFavorite toggles the favorite flag on a DM/group for the calling user. Same wire shape as the channel version.

func (*SidebarHandler) SetFavorite added in v0.0.3

func (h *SidebarHandler) SetFavorite(w http.ResponseWriter, r *http.Request)

SetFavorite toggles the favorite flag on a channel for the calling user.

func (*SidebarHandler) SetSidebarService added in v0.0.59

func (h *SidebarHandler) SetSidebarService(s *service.SidebarService)

SetSidebarService wires the server-owned reorder service (optional in tests that only exercise the legacy per-row endpoints).

func (*SidebarHandler) UpdateCategory added in v0.0.3

func (h *SidebarHandler) UpdateCategory(w http.ResponseWriter, r *http.Request)

UpdateCategory renames or repositions a category. Body fields are optional; only the ones supplied are applied.

func (*SidebarHandler) Wired added in v0.0.97

func (h *SidebarHandler) Wired() error

type ThreadHandler added in v0.0.2

type ThreadHandler struct {
	// contains filtered or unexported fields
}

ThreadHandler exposes endpoints that span all parents (channels and conversations) for the authenticated user.

func NewThreadHandler added in v0.0.2

func NewThreadHandler(messageSvc *service.MessageService) *ThreadHandler

NewThreadHandler creates a ThreadHandler.

func (*ThreadHandler) Follow added in v0.0.24

func (h *ThreadHandler) Follow(w http.ResponseWriter, r *http.Request)

func (*ThreadHandler) FollowState added in v0.0.107

func (h *ThreadHandler) FollowState(w http.ResponseWriter, r *http.Request)

FollowState says whether the authenticated user follows one thread.

func (*ThreadHandler) List added in v0.0.2

func (h *ThreadHandler) List(w http.ResponseWriter, r *http.Request)

List returns one page of the authenticated user's threads: unread ones first, then the rest, latest reply first. ?cursor= continues from the previous page's nextCursor; ?limit= sizes the page.

func (*ThreadHandler) Unfollow added in v0.0.24

func (h *ThreadHandler) Unfollow(w http.ResponseWriter, r *http.Request)

type UnfurlHandler added in v0.0.11

type UnfurlHandler struct {
	// contains filtered or unexported fields
}

UnfurlHandler exposes /api/v1/unfurl?url=… so the client can render link previews without each browser hitting third-party sites directly (CORS would block most of them anyway).

func NewUnfurlHandler added in v0.0.11

func NewUnfurlHandler(svc *service.UnfurlService) *UnfurlHandler

NewUnfurlHandler builds an UnfurlHandler.

func (*UnfurlHandler) Get added in v0.0.11

Get returns a JSON UnfurlPreview for the `url` query parameter. Failures (timeout, blocked host, non-HTML, network) return 204 No Content so the client can quietly skip the preview without surfacing an error to the user.

func (h *UnfurlHandler) SetMessageLinks(r messageLinkResolver)

SetMessageLinks wires the internal message-link resolver so links to other messages in this workspace unfurl as rich previews.

func (*UnfurlHandler) Wired added in v0.0.97

func (h *UnfurlHandler) Wired() error

type UnreadSeqAdapter added in v0.0.52

type UnreadSeqAdapter struct {
	// contains filtered or unexported fields
}

UnreadSeqAdapter binds a parent's message-seq incrementer, current-seq reader and per-user last-read setter into one service.UnreadSeqStore. It lets channels (counter on the channel store, last-read on the membership store) and conversations (both on the conversation store) share the same MessageService unread path.

func NewUnreadSeqAdapter added in v0.0.52

func NewUnreadSeqAdapter(
	incr func(ctx context.Context, parentID string) (int64, error),
	current func(ctx context.Context, parentID string) (int64, error),
	lastRead func(ctx context.Context, parentID, userID string, seq int64) error,
) *UnreadSeqAdapter

func (*UnreadSeqAdapter) CurrentMessageSeq added in v0.0.81

func (a *UnreadSeqAdapter) CurrentMessageSeq(ctx context.Context, parentID string) (int64, error)

func (*UnreadSeqAdapter) IncrementMessageSeq added in v0.0.52

func (a *UnreadSeqAdapter) IncrementMessageSeq(ctx context.Context, parentID string) (int64, error)

func (*UnreadSeqAdapter) SetLastRead added in v0.0.52

func (a *UnreadSeqAdapter) SetLastRead(ctx context.Context, parentID, userID string, seq int64) error

type UploadHandler

type UploadHandler struct {
	// contains filtered or unexported fields
}

UploadHandler exposes generic file-upload endpoints backed by S3 presigned URLs.

func NewUploadHandler

func NewUploadHandler(s3 *storage.S3Client) *UploadHandler

NewUploadHandler creates an UploadHandler.

func (*UploadHandler) CreateUploadURL

func (h *UploadHandler) CreateUploadURL(w http.ResponseWriter, r *http.Request)

CreateUploadURL returns a presigned PUT URL the browser can use to upload a file directly to S3, plus a presigned GET URL the client can embed in a message.

type UserGroupHandler added in v0.0.121

type UserGroupHandler struct {
	// contains filtered or unexported fields
}

UserGroupHandler is the user-group API (/api/v1/usergroups). Every member reads groups; admins enable or disable them and run the sync (the service decides). Groups themselves come from Microsoft 365. Guests are refused.

func NewUserGroupHandler added in v0.0.121

func NewUserGroupHandler(svc *service.UserGroupService) *UserGroupHandler

NewUserGroupHandler returns the user-group handler.

func (*UserGroupHandler) Disable added in v0.0.121

func (h *UserGroupHandler) Disable(w http.ResponseWriter, r *http.Request)

Disable answers POST /api/v1/usergroups/{id}/disable.

func (*UserGroupHandler) Enable added in v0.0.121

func (h *UserGroupHandler) Enable(w http.ResponseWriter, r *http.Request)

Enable answers POST /api/v1/usergroups/{id}/enable.

func (*UserGroupHandler) ForUser added in v0.0.121

func (h *UserGroupHandler) ForUser(w http.ResponseWriter, r *http.Request)

ForUser answers GET /api/v1/users/{id}/usergroups.

func (*UserGroupHandler) Get added in v0.0.121

Get answers GET /api/v1/usergroups/{id}.

func (*UserGroupHandler) List added in v0.0.121

List answers GET /api/v1/usergroups?includeDisabled=true.

func (*UserGroupHandler) Permissions added in v0.0.121

func (h *UserGroupHandler) Permissions(w http.ResponseWriter, r *http.Request)

Permissions answers GET /api/v1/usergroup-permissions: whether the caller may manage groups (the directory shows its controls by it).

func (*UserGroupHandler) SyncNow added in v0.0.121

func (h *UserGroupHandler) SyncNow(w http.ResponseWriter, r *http.Request)

SyncNow answers POST /api/v1/usergroup-sync: starts a sync (admins). 202 with the status when one started or was already running; 429 with the status right after a run.

func (*UserGroupHandler) SyncStatus added in v0.0.121

func (h *UserGroupHandler) SyncStatus(w http.ResponseWriter, r *http.Request)

SyncStatus answers GET /api/v1/usergroup-sync: how the sync went (admins).

type UserHandler

type UserHandler struct {
	// contains filtered or unexported fields
}

UserHandler exposes HTTP endpoints for user operations.

func NewUserHandler

func NewUserHandler(userSvc *service.UserService, s3 *storage.S3Client) *UserHandler

NewUserHandler creates a UserHandler.

func (*UserHandler) BatchGetUsers

func (h *UserHandler) BatchGetUsers(w http.ResponseWriter, r *http.Request)

BatchGetUsers returns users matching a list of IDs in a single request.

func (*UserHandler) ClearMyUserStatus added in v0.0.22

func (h *UserHandler) ClearMyUserStatus(w http.ResponseWriter, r *http.Request)

ClearMyUserStatus clears the authenticated user's visible status message.

func (*UserHandler) CreateAvatarUploadURL

func (h *UserHandler) CreateAvatarUploadURL(w http.ResponseWriter, r *http.Request)

CreateAvatarUploadURL returns a presigned PUT URL the browser can use to upload an avatar directly to S3 without the bytes passing through this server. The browser then PATCHes /users/me with the returned key to associate the new avatar with the user.

func (*UserHandler) GetMe

func (h *UserHandler) GetMe(w http.ResponseWriter, r *http.Request)

GetMe returns the authenticated user's profile.

func (*UserHandler) GetUser

func (h *UserHandler) GetUser(w http.ResponseWriter, r *http.Request)

GetUser returns a user by ID. Non-admin callers receive limited fields.

func (*UserHandler) ListFrequentPeople added in v0.0.120

func (h *UserHandler) ListFrequentPeople(w http.ResponseWriter, r *http.Request)

ListFrequentPeople returns the IDs of the people the caller mentions and messages most, highest first, capped by the optional `limit` query parameter. The composer's @-list puts them first.

func (*UserHandler) ListUsers

func (h *UserHandler) ListUsers(w http.ResponseWriter, r *http.Request)

ListUsers returns the whole roster, paged through internally. If the "q" query parameter is provided, it searches users by display name or email prefix instead. `?all=true` is the mention popup's copy, which it caches client-side, so it's ALWAYS the limited public projection. The directory (default + `?q=`) paths give the full record to admins and the public projection to everyone else (see usersForCaller). The default path used to return one page of 50 and drop the next cursor, so the directory never listed anyone past the first 50 accounts.

func (*UserHandler) SetMyNotificationSettings added in v0.0.50

func (h *UserHandler) SetMyNotificationSettings(w http.ResponseWriter, r *http.Request)

SetMyNotificationSettings replaces the authenticated user's account-level notification settings (levels, toggles, keywords) and returns the updated profile. Body is the full NotificationSettings object.

func (*UserHandler) SetMyUserStatus added in v0.0.22

func (h *UserHandler) SetMyUserStatus(w http.ResponseWriter, r *http.Request)

SetMyUserStatus sets the authenticated user's visible status message.

func (*UserHandler) SetUserStatus added in v0.0.2

func (h *UserHandler) SetUserStatus(w http.ResponseWriter, r *http.Request)

SetUserStatus deactivates or reactivates any account — SSO accounts included. Admin-only, and never the caller's own account (an admin could otherwise lock themselves out).

func (*UserHandler) SnoozeMyNotifications added in v0.0.118

func (h *UserHandler) SnoozeMyNotifications(w http.ResponseWriter, r *http.Request)

SnoozeMyNotifications turns Do Not Disturb on for {"minutes": n}, or off with 0.

func (*UserHandler) UpdateMe

func (h *UserHandler) UpdateMe(w http.ResponseWriter, r *http.Request)

UpdateMe updates the authenticated user's profile.

func (*UserHandler) UpdateUserRole

func (h *UserHandler) UpdateUserRole(w http.ResponseWriter, r *http.Request)

UpdateUserRole changes a user's system role. Admin-only.

type UserResolver added in v0.0.55

type UserResolver interface {
	GetBatch(ctx context.Context, ids []string) ([]*model.User, error)
}

UserResolver batch-loads users by ID so the user-search endpoint can drop hits whose canonical row no longer exists (deleted users that still linger in a stale search index — "ghosts"). Missing IDs are simply omitted from the returned slice. Wire the cache-first UserService.GetBatch (NOT the raw store) so the per-keystroke autocomplete doesn't pay a cold DynamoDB read for warm IDs.

type UserStateHandler added in v0.0.26

type UserStateHandler struct {
	// contains filtered or unexported fields
}

func NewUserStateHandler added in v0.0.26

func NewUserStateHandler(stateSvc *service.UserStateService, msgSvc *service.MessageService, convSvc *service.ConversationService) *UserStateHandler

func (*UserStateHandler) Get added in v0.0.26

func (*UserStateHandler) HideConversation added in v0.0.26

func (h *UserStateHandler) HideConversation(w http.ResponseWriter, r *http.Request)

func (*UserStateHandler) HideSkill added in v0.0.72

func (h *UserStateHandler) HideSkill(w http.ResponseWriter, r *http.Request)

HideSkill / UnhideSkill toggle one skill's presence in THIS user's agent discovery index. Hiding is curation, not permission: an explicit /skill pick still attaches a hidden skill.

func (*UserStateHandler) MarkThreadSeen added in v0.0.26

func (h *UserStateHandler) MarkThreadSeen(w http.ResponseWriter, r *http.Request)

func (*UserStateHandler) SetSkillLookup added in v0.0.72

func (h *UserStateHandler) SetSkillLookup(s skillLookup)

SetSkillLookup wires skill validation for the hide/unhide endpoints.

func (*UserStateHandler) ThreadRead added in v0.0.110

func (h *UserStateHandler) ThreadRead(w http.ResponseWriter, r *http.Request)

ThreadRead returns how far the caller has read one thread — asked when the thread opens. It is the caller's own row, so it needs no access check.

func (*UserStateHandler) UnhideConversation added in v0.0.26

func (h *UserStateHandler) UnhideConversation(w http.ResponseWriter, r *http.Request)

func (*UserStateHandler) UnhideSkill added in v0.0.72

func (h *UserStateHandler) UnhideSkill(w http.ResponseWriter, r *http.Request)

func (*UserStateHandler) Wired added in v0.0.97

func (h *UserStateHandler) Wired() error

type VersionHandler added in v0.0.3

type VersionHandler struct {
	// contains filtered or unexported fields
}

VersionHandler exposes the build version of the running binary so the browser can detect when a deploy has rolled out and trigger a reload.

The version string is opaque — the frontend only needs to compare for equality with the version it shipped with.

func NewVersionHandler added in v0.0.3

func NewVersionHandler(version string) *VersionHandler

NewVersionHandler builds a VersionHandler that always returns the supplied version string. An empty value is replaced with "dev" so the endpoint never returns an ambiguous blank.

func (*VersionHandler) Get added in v0.0.3

Get returns {"version": "<build version>"}. No auth — the version is not sensitive and the frontend needs to fetch it before login completes.

The version doubles as a strong ETag. Pollers send If-None-Match on every tick; once the version stabilises after a deploy, those polls resolve to a 0-byte 304 instead of the JSON payload.

type WSHandler

type WSHandler struct {
	// contains filtered or unexported fields
}

WSHandler serves a WebSocket connection for real-time updates.

func NewWSHandler

func NewWSHandler(broker *pubsub.Broker, chanSvc *service.ChannelService, convSvc *service.ConversationService, presenceSvc *service.PresenceService) *WSHandler

NewWSHandler creates a WSHandler.

func (*WSHandler) Connect

func (h *WSHandler) Connect(w http.ResponseWriter, r *http.Request)

Connect upgrades the HTTP connection to a WebSocket for the authenticated user. Authentication is the one-time ?ticket= redeemed by UpgradeAuth.

func (*WSHandler) Drain added in v0.0.64

func (h *WSHandler) Drain(timeout time.Duration) bool

Drain blocks until every in-flight Connect handler has finished its teardown (presence cleanup + offline publish), or the timeout lapses. Called during graceful shutdown AFTER the broker closes its clients (which unblocks each connection loop). Returns false on timeout — teardown then finishes on the distributed side by per-connection expiry.

func (*WSHandler) MintTicket added in v0.0.64

func (h *WSHandler) MintTicket(w http.ResponseWriter, r *http.Request)

MintTicket issues a one-time WebSocket upgrade ticket for the authenticated user (POST /api/v1/ws/ticket, authed + per-user rate limited). The ticket inherits the caller's token expiry as the socket's session deadline: the connection is force-closed shortly after the access token would have expired, so a revoked/deactivated session cannot keep a live socket beyond the token lifetime even if the ephemeral force-logout event is lost.

func (*WSHandler) SetNotificationAckRecorder added in v0.0.51

func (h *WSHandler) SetNotificationAckRecorder(r NotificationAckRecorder)

SetNotificationAckRecorder wires the store that records desktop-delivery acks (a `notification.ack` inbound frame). Optional — without it, acks are ignored and the deferred mobile-push fallback degrades to presence-only behaviour.

func (*WSHandler) SetOriginPolicy added in v0.0.45

func (h *WSHandler) SetOriginPolicy(patterns []string)

SetOriginPolicy configures which Origin headers the WebSocket upgrade will accept. Patterns are host-only (e.g. "app.example.com", "localhost") and use path.Match wildcards (see coder/websocket AcceptOptions.OriginPatterns). A single "*" entry disables origin verification — used in local dev where the bound port may be hit from arbitrary scratch origins. In production this MUST be a concrete allowlist; an unset policy fails closed (same-origin only).

func (*WSHandler) SetPublisher added in v0.0.3

func (h *WSHandler) SetPublisher(p service.Publisher)

SetPublisher wires a publisher for inbound ephemeral events (typing indicator). Optional — when nil, inbound typing is dropped.

func (*WSHandler) SetReplayer added in v0.0.46

func (h *WSHandler) SetReplayer(r InboxReplayer)

SetReplayer wires the durable inbox so reconnects with a `since` cursor can replay events missed during the disconnect. Optional — when nil, the handshake skips replay and the client falls back to its own refetch logic.

func (*WSHandler) SetTicketStore added in v0.0.64

func (h *WSHandler) SetTicketStore(s WSTicketStore)

SetTicketStore wires the one-time upgrade ticket store. Required for WebSockets: without it, MintTicket answers 503 and every upgrade 401.

func (*WSHandler) SetUserService added in v0.0.22

func (h *WSHandler) SetUserService(s *service.UserService)

SetUserService wires the profile service for lightweight client heartbeat metadata, currently timezone drift while a user remains logged in.

func (*WSHandler) SetVersion added in v0.0.4

func (h *WSHandler) SetVersion(v string)

SetVersion records the running build version so each newly-connected client receives a "server.version" frame as part of the handshake. The browser uses this to decide if its bundle is outdated — sending it on the WS instead of polling /api/v1/version every minute keeps a chatty pinger off the HTTP fast path even with many connected users.

func (*WSHandler) UpgradeAuth added in v0.0.64

func (h *WSHandler) UpgradeAuth(next http.Handler) http.Handler

UpgradeAuth authenticates the WebSocket upgrade: the ?ticket= query is redeemed (single-use) and its userID + session deadline become the request's auth context. A ticket is the ONLY way in — there is no Authorization-header fallback: it was guarded by nothing but a per-IP rate limit, so it bypassed the per-user limit on minting tickets (and thereby on opening sockets), and no client uses it (the SPA — also what the desktop shell hosts — always mints a ticket). The access JWT never appears in the URL.

func (*WSHandler) Wired added in v0.0.97

func (h *WSHandler) Wired() error

type WSTicketStore added in v0.0.64

type WSTicketStore interface {
	MintWSTicket(ctx context.Context, ticket, userID string, sessionDeadline time.Time) error
	ConsumeWSTicket(ctx context.Context, ticket string) (userID string, sessionDeadline time.Time, err error)
}

WSTicketStore mints and redeems one-time WebSocket upgrade tickets (Redis-backed in production). A browser cannot set an Authorization header on a WebSocket, so historically the upgrade URL carried the full access JWT (?token=...) — leaking a 15-minute credential into LB/proxy logs, browser history, and APM URL capture. Tickets replace that: single-use, 30-second, high-entropy, and carrying only an opaque random value in the URL.

type WebhookHandler added in v0.0.48

type WebhookHandler struct {
	// contains filtered or unexported fields
}

func NewWebhookHandler added in v0.0.48

func NewWebhookHandler(svc *service.IncomingWebhookService) *WebhookHandler

func (*WebhookHandler) Create added in v0.0.48

func (h *WebhookHandler) Create(w http.ResponseWriter, r *http.Request)

func (*WebhookHandler) Delete added in v0.0.48

func (h *WebhookHandler) Delete(w http.ResponseWriter, r *http.Request)

func (*WebhookHandler) DeleteTemplate added in v0.0.116

func (h *WebhookHandler) DeleteTemplate(w http.ResponseWriter, r *http.Request)

DeleteTemplate removes a rich webhook's template.

func (*WebhookHandler) Execute added in v0.0.48

func (h *WebhookHandler) Execute(w http.ResponseWriter, r *http.Request)

Execute is a classic webhook's URL, /hooks/{id}. It answers exactly as it always has; a rich webhook posts to ExecuteRich instead.

func (*WebhookHandler) ExecuteRich added in v0.0.116

func (h *WebhookHandler) ExecuteRich(w http.ResponseWriter, r *http.Request)

ExecuteRich is a rich webhook's URL, /hooks/v2/{id}.

func (*WebhookHandler) List added in v0.0.48

func (*WebhookHandler) Preview added in v0.0.116

func (h *WebhookHandler) Preview(w http.ResponseWriter, r *http.Request)

Preview answers with the message a payload would post (see IncomingWebhookService.PreviewMessage), for the webhooks panel's live preview. The body is a webhook payload.

func (*WebhookHandler) SaveTemplate added in v0.0.116

func (h *WebhookHandler) SaveTemplate(w http.ResponseWriter, r *http.Request)

SaveTemplate adds or replaces a rich webhook's template. Body: {"payload": {…a webhook payload with {{placeholders}}…}}.

func (*WebhookHandler) Update added in v0.0.48

func (h *WebhookHandler) Update(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL