Documentation
¶
Overview ¶
Package companion is the local web window beside the game: a chat page that streams the agent's answer, knows the current character, and refreshes the moment ForeverScribe saves. It reuses the ask package's prompt and agent runner, so the agent runs exactly as `ask` runs it.
Index ¶
Constants ¶
const ( MaxBody = 8 << 10 MaxQuestion = 1000 HistoryTurns = 4 HistoryChars = 4000 HistoryAnswerChars = 600 )
Limits. History is the context kept from earlier turns of the same character: at most HistoryTurns turns and HistoryChars characters, oldest dropped first, each answer cut to HistoryAnswerChars.
const ( DigestOn = "on" DigestOff = "off" DigestNoAddon = "addon not found" DigestFailed = "error" )
Digest statuses.
const ( ActionAsk = "ask" // send Question with Ref to /api/ask ActionPlayStyle = "play_style" // open the play-style choice ActionRefreshPlan = "refresh_plan" // POST /api/refresh-plan ActionOpenEntry = "open_entry" // show the entry whose ref is Ref )
Suggestion actions.
const DataNotice = "Game data updated (talent builds and more)"
DataNotice is the dim line shown after a dataset update installs.
const ErrNoAgent = "No AI client set up yet: install Claude Code, Codex or Antigravity CLI, or choose one in settings."
ErrNoAgent is what asking says when no AI client is set up.
const MaxEntries = 14
MaxEntries is the most plan entries a character carries for the overlay.
const MaxSuggestions = 3
MaxSuggestions is the most suggested actions a character carries.
const NextQuests = 3
NextQuests is how many next quests each character carries.
const NoDataMessage = "Game data not downloaded yet; see Setup"
NoDataMessage is what the player sees instead of advice when no game data has downloaded.
const PlanStops = 6
PlanStops is how many route stops each character carries for the overlay.
const TokenHeader = "X-Wowc-Token"
TokenHeader carries the token for the app, whose origin cannot hold the cookie.
Variables ¶
var AppOrigins = []string{"http://tauri.localhost", "https://tauri.localhost", "tauri://localhost"}
AppOrigins are the webview origins of the desktop app (Tauri on Windows, and elsewhere).
Functions ¶
This section is empty.
Types ¶
type CharInfo ¶
type CharInfo struct {
Key string `json:"key"`
Name string `json:"name"`
Class string `json:"class"`
Level int `json:"level"`
CapturedAt int64 `json:"captured_at"`
Next []string `json:"next,omitempty"` // the top next quests, from the digest
// NextLines is the same quests as Next with the digest's structured, untruncated fields, so the
// overlay can lay them out like the in-game panel. Next stays for older pages.
NextLines []NextLine `json:"next_lines,omitempty"`
// Entries is the character's current panel entries in the in-game panel's order, each with its
// suggested questions (asks) and ref, so the overlay can offer them as one-click questions.
Entries []PlanEntry `json:"entries,omitempty"`
Plan []string `json:"plan,omitempty"` // the route's first stops, in order
PlanLine string `json:"plan_line,omitempty"` // "N stops"
// PlanSteps is the same stops with their lock state, so the overlay can dim a locked one.
PlanSteps []PlanStep `json:"plan_steps,omitempty"`
// Style is the saved play style (the overlay's "Play style" row); nil until the player sets one.
Style *character.Profile `json:"style,omitempty"`
// Specs is the class's spec names for the Spec dropdown; an old free-text spec in Style is
// already migrated to the matching one, or "" for "Not sure yet".
Specs []string `json:"specs,omitempty"`
// Suggestions is the ranked list of at most three next actions (see suggest.go).
Suggestions []Suggestion `json:"suggestions,omitempty"`
}
CharInfo is one captured character.
type Config ¶
type Config struct {
ForeverScribe string // ForeverScribe.lua, polled for game data
Ask ask.Config // the agent; SavedVariables and AnswersPath serve in-game questions
Stream bool // the agent command is Claude's and can print stream-json
LAN bool // listening on all interfaces
App bool // the desktop app's webview is the client: its origins pass, and the token may come in a header or query
Dataset string // dataset directory, for each character's next quests (empty: none until Setup downloads it)
Cache dataset.Store // where the Setup row looks for and downloads the dataset (Root empty: the per-user cache)
Poll time.Duration
NoUsage bool // start with the usage line off
AutoDigest bool // rewrite the in-game digest when ForeverScribe saves
DigestPath string // Digest.lua; empty derives it from ForeverScribe
Debounce time.Duration // quiet time after a save before the digest is written (default 2s)
GameDir string // the WoW folder the player chose in the setup checklist (empty: detect)
HTTP *http.Client // for the addon lookup and install (nil: the default client)
AddonAPI string // the addon's latest-release URL (empty: GitHub's)
Update func(context.Context) (release.Result, error) // looks up the latest release for /api/update; nil answers no notice
Profiles string // the play-style store (empty: profile.Path())
Now func() time.Time // the clock for ask ages (nil: time.Now)
}
Config is one companion's settings.
type DigestState ¶ added in v0.3.0
type DigestState struct {
Enabled bool `json:"enabled"`
Status string `json:"status"`
UpdatedAt int64 `json:"updated_at,omitempty"` // when the file was last written or confirmed current
Error string `json:"error,omitempty"`
}
DigestState is the in-game digest's status: whether it is kept up to date, and when it last was.
type Entry ¶
type Entry struct {
ID string `json:"id"`
Source string `json:"source"` // "web" or "game"
Character string `json:"character"`
Question string `json:"question"`
Answer string `json:"answer"`
Status string `json:"status"` // "waiting", "answering" (text so far in Answer), "done" or "error"
Streamed bool `json:"streamed"`
UsageTip string `json:"usage_tip,omitempty"` // the usage line's tooltip: cached tokens are cheaper but may still count
Usage string `json:"usage,omitempty"` // "≈3.1k tokens · haiku": tokens when the CLI reported them, and the model; only with the setting on
Notice string `json:"notice,omitempty"` // a one-line notice, e.g. the reasoning setting was dropped
At int64 `json:"at"`
// Needs is set, with Status "needs", when the question needs a play style the character has not
// saved: the choices to show as buttons. No AI call was made. Saving the choice (POST /api/profile)
// asks the question again, once, and says so with a "reask" event.
Needs *ask.Needs `json:"needs,omitempty"`
}
Entry is one turn of the chat history.
type NextLine ¶ added in v0.7.3
type NextLine struct {
Text string `json:"text"`
Kind string `json:"kind,omitempty"`
Title string `json:"title,omitempty"`
Level int `json:"level,omitempty"`
Class bool `json:"class,omitempty"`
Elite bool `json:"elite,omitempty"`
NPC string `json:"npc,omitempty"`
Zone string `json:"zone,omitempty"`
Objectives []NextObjective `json:"objectives,omitempty"`
Points int `json:"points,omitempty"`
Unlocks []string `json:"unlocks,omitempty"` // a turn-in's follow-ups: "Quest (from NPC, here)"
}
NextLine is one next-list entry: the digest line's text plus its structured fields, none clipped.
type NextObjective ¶ added in v0.7.3
type NextObjective struct {
Text string `json:"text"`
Have int `json:"have,omitempty"`
Need int `json:"need,omitempty"`
HasCount bool `json:"has_count,omitempty"`
}
NextObjective is one objective of a next quest; Have and Need are set only when HasCount.
type PlanEntry ¶ added in v0.7.7
type PlanEntry struct {
Group string `json:"group"` // next, upgrades, notes, dungeons or talents
Kind string `json:"kind,omitempty"`
Title string `json:"title"`
Status string `json:"status,omitempty"`
Why string `json:"why,omitempty"` // one short reason, at most 70 characters
Class bool `json:"class,omitempty"`
Asks []string `json:"asks,omitempty"`
Ref string `json:"ref,omitempty"`
}
PlanEntry is one entry of the in-game panel as the overlay lists it: a one-line title and status in the player's words, and the questions to offer. Ref is sent back with a question so the advisor knows the subject; the overlay never shows it.
type PlanStep ¶ added in v0.7.5
type PlanStep struct {
Text string `json:"text"` // the action in words, without the place
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Locked bool `json:"locked,omitempty"`
After int `json:"after,omitempty"`
}
PlanStep is one route stop for the overlay; After is the step a locked stop waits for.
type RefreshResult ¶ added in v0.7.8
type RefreshResult struct {
Message string `json:"message"`
NewSteps int `json:"new_steps"`
Files []string `json:"files,omitempty"`
}
RefreshResult is what /api/refresh-plan answers.
type Server ¶
type Server struct {
Token string
// contains filtered or unexported fields
}
Server is the companion.
func (*Server) SetAutoDigest ¶ added in v0.3.0
SetAutoDigest turns the automatic digest on or off and republishes the status.
type Settings ¶ added in v0.3.0
type Settings struct {
Length string `json:"length"` // brief, standard or detailed
Model string `json:"model"` // efficient, balanced, best or custom
Custom string `json:"custom_model"` // the model name for "custom"
Reasoning string `json:"reasoning"` // low, medium or high
Usage bool `json:"usage"` // show the token usage line under answers
ModelNote string `json:"model_note,omitempty"` // what the models mean for the current AI client
// Client and Choices tell the overlay what to offer for the current AI client; the overlay
// remembers each client's last choice and sends it back. Both are ignored in a request.
Client string `json:"client"`
Choices ask.Choices `json:"choices"`
}
Settings are the answer settings the overlay changes while it runs.
type State ¶
type State struct {
Characters []CharInfo `json:"characters"`
Default string `json:"default"`
CapturedAt int64 `json:"captured_at"`
Error string `json:"error,omitempty"`
History []Entry `json:"history"`
Streaming bool `json:"streaming"`
Digest DigestState `json:"digest"`
Settings Settings `json:"settings"`
DataNotice string `json:"data_notice,omitempty"` // set once a dataset update has installed
}
State is what the page loads and what a "game" event carries.
type Suggestion ¶ added in v0.7.8
type Suggestion struct {
ID string `json:"id"`
Label string `json:"label"`
Why string `json:"why,omitempty"`
Action string `json:"action"`
Question string `json:"question,omitempty"`
Ref string `json:"ref,omitempty"`
}
Suggestion is one suggested next action for the overlay. ID is stable for the same advice, so the overlay can dismiss it for the day. Question is set for an "ask"; Ref for an "ask" and an "open_entry".