Files
pipelines/internal/protocol/chat_shown.go
T
alan fc7dbb0ac0 Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:24 +00:00

153 lines
6.8 KiB
Go

package protocol
// ChatShown is the pushed frame type for an item a chat's model showed the
// operator through the Pipelines tools (show_file, show_image, show_html,
// show_diff, show_run, notify). The chat_subscribe reply carries the retained
// list in the same ChatShown field.
const ChatShown = "chat_shown"
// The ChatShownItem kinds.
const (
ChatShownFile = "file"
ChatShownImage = "image"
ChatShownHTML = "html"
ChatShownDiff = "diff"
ChatShownRun = "run"
ChatShownNotify = "notify"
)
// ChatShownLimit bounds the items retained per chat, and ChatShownHTMLBudget
// the HTML and diff bytes kept across them: older documents and diffs beyond
// it keep their entry but drop the body (Expired).
const (
ChatShownLimit = 100
ChatShownHTMLBudget = 2 << 20
)
// The ChatShownItem file states, computed when a chat's items are listed.
const (
// ChatShownFileChanged: the live file differs from what was shown.
ChatShownFileChanged = "changed"
// ChatShownFileMissing: the file (or its snapshot) no longer exists.
ChatShownFileMissing = "missing"
)
// ChatShownFrame is one chat's shown items, oldest first.
type ChatShownFrame struct {
SessionID string `json:"session_id"`
Items []ChatShownItem `json:"items"`
}
// ChatShownItem is one entry. A file or image Path is an absolute path on the
// chat's own machine, served by that machine's /files endpoint. When Snapshot
// is set, Path is a copy Pipelines took when the item was shown (Source is the
// path the model named; URL the https address an image was fetched from);
// otherwise Path is the live file, and ModTime and SHA256 record what was
// shown so State can say it changed since. A web image without Path is an
// older entry the client loads from URL itself. A replaced item keeps its ID
// and CreatedAt (its place in the transcript) and sets UpdatedAt.
type ChatShownItem struct {
ID string `json:"id"`
Kind string `json:"kind"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at,omitempty"`
Title string `json:"title,omitempty"`
Path string `json:"path,omitempty"`
Name string `json:"name,omitempty"`
Size int64 `json:"size,omitempty"`
Mime string `json:"mime,omitempty"`
Snapshot bool `json:"snapshot,omitempty"`
Source string `json:"source,omitempty"`
ModTime int64 `json:"mod_time,omitempty"`
SHA256 string `json:"sha256,omitempty"`
// State is ChatShownFileChanged or ChatShownFileMissing, else empty.
State string `json:"state,omitempty"`
URL string `json:"url,omitempty"`
Alt string `json:"alt,omitempty"`
HTML string `json:"html,omitempty"`
HTMLBytes int `json:"html_bytes,omitempty"`
// Diff is a show_diff item's repository comparison; DiffBytes is the size
// of its patches, counted against ChatShownHTMLBudget.
Diff *ChatShownDiffBody `json:"diff,omitempty"`
DiffBytes int `json:"diff_bytes,omitempty"`
// Run is a show_run item's run, kept current as the run changes.
Run *ChatShownRunBody `json:"run,omitempty"`
// HeightHint is the model's preferred inline height in logical pixels.
HeightHint int `json:"height_hint,omitempty"`
Expired bool `json:"expired,omitempty"`
Message string `json:"message,omitempty"`
Priority string `json:"priority,omitempty"`
Delivered bool `json:"delivered,omitempty"`
// Detail says why a notification was not delivered (or not to the phone).
Detail string `json:"detail,omitempty"`
// Channels says where a delivered notification went: "apps" (the
// operator's signed-in Pipelines apps). Items recorded before ntfy was
// removed may also carry "phone".
Channels []string `json:"channels,omitempty"`
}
// ChatShownRunBody is the run a show_run item follows. StartedAt and
// FinishedAt are epoch milliseconds (FinishedAt zero while it runs).
type ChatShownRunBody struct {
ID int64 `json:"id"`
Pipeline string `json:"pipeline"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
Outcome string `json:"outcome,omitempty"`
CurrentStage string `json:"current_stage,omitempty"`
Workspace string `json:"workspace,omitempty"`
StartedAt int64 `json:"started_at,omitempty"`
FinishedAt int64 `json:"finished_at,omitempty"`
// Map is the run's graph and per-stage progress for the card's mini-map
// and stage strip; nil when the server could not read it or the graph has
// more than ChatShownRunMapStages stages.
Map *ChatShownRunMap `json:"map,omitempty"`
}
// ChatShownRunMapStages bounds the graph a run card carries.
const ChatShownRunMapStages = 48
// ChatShownRunMap is a run's graph reduced to what a card draws: each
// declared stage's routes and progress, and the compact route evidence (the
// latest visit of every stage and of every taken route, in sequence order,
// as RunGraphEvidence). Its size is bounded by the graph, not by the run's
// length, so a long loop does not grow it.
type ChatShownRunMap struct {
Stages []ChatShownRunStage `json:"stages"`
Visits []RunGraphVisit `json:"visits"`
}
// ChatShownRunStage is one declared stage with its progress in the run.
// Seconds totals its finished visits; RunningSince (epoch milliseconds) is the
// start of a visit still running, so a client can add the live part.
type ChatShownRunStage struct {
Key string `json:"key"`
Type string `json:"type,omitempty"`
Edges map[string]string `json:"edges,omitempty"`
FallbackError bool `json:"fallback_error,omitempty"`
Visits int `json:"visits,omitempty"`
Status string `json:"status,omitempty"`
Seconds int64 `json:"seconds,omitempty"`
RunningSince int64 `json:"running_since,omitempty"`
}
// ChatShownDiffBody is one Git comparison a chat's model showed: the work tree
// (or HEAD when CommittedOnly, or HeadRevision when set) of Repo against
// BaseCommit, which is HEAD when Base is empty and the merge base with Base
// otherwise. Paths, when set, limits the comparison to those paths or globs.
// Changes uses the same per-file shape as a run's recorded changes; it is nil
// once Expired.
type ChatShownDiffBody struct {
Repo string `json:"repo"`
Base string `json:"base,omitempty"`
BaseCommit string `json:"base_commit,omitempty"`
Head string `json:"head,omitempty"`
HeadRevision string `json:"head_revision,omitempty"`
Paths []string `json:"paths,omitempty"`
CommittedOnly bool `json:"committed_only,omitempty"`
Files int `json:"files"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Changes *StageFileChanges `json:"changes,omitempty"`
}