Chat tools: argument validation, replace, file snapshots, server-fetched images, show_run, show_diff head/paths, schedule_followup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,8 @@ 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, notify). The chat_subscribe reply carries the retained list in the same
|
||||
// ChatShown field.
|
||||
// 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.
|
||||
@@ -12,6 +12,7 @@ const (
|
||||
ChatShownImage = "image"
|
||||
ChatShownHTML = "html"
|
||||
ChatShownDiff = "diff"
|
||||
ChatShownRun = "run"
|
||||
ChatShownNotify = "notify"
|
||||
)
|
||||
|
||||
@@ -23,6 +24,14 @@ const (
|
||||
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"`
|
||||
@@ -30,17 +39,29 @@ type ChatShownFrame struct {
|
||||
}
|
||||
|
||||
// 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; URL is an
|
||||
// https image address the client loads without credentials.
|
||||
// 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"`
|
||||
@@ -49,6 +70,8 @@ type ChatShownItem struct {
|
||||
// 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"`
|
||||
@@ -59,15 +82,33 @@ type ChatShownItem struct {
|
||||
Detail string `json:"detail,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"`
|
||||
}
|
||||
|
||||
// ChatShownDiffBody is one Git comparison a chat's model showed: the work tree
|
||||
// (or HEAD when CommittedOnly) of Repo against BaseCommit, which is HEAD when
|
||||
// Base is empty and the merge base with Base otherwise. Changes uses the same
|
||||
// per-file shape as a run's recorded changes; it is nil once Expired.
|
||||
// (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"`
|
||||
|
||||
Reference in New Issue
Block a user