From ff12e86792824d1f4ad7c948f35b52f682d438bc Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 4 Nov 2026 20:15:48 +0000 Subject: [PATCH 1/3] FEAT: add session goal commands and live goal status --- README.md | 27 ++- docs/slash-command-support.md | 10 +- internal/codex/daemon_status.go | 1 + internal/codex/daemon_status_unix.go | 20 ++ internal/codex/live_usage.go | 5 + internal/codex/session_command_cache.go | 3 + internal/codex/session_commands.go | 8 +- internal/codex/session_commands_unix.go | 37 ++- internal/codex/session_goal.go | 98 ++++++++ internal/codex/session_goal_commands_unix.go | 179 +++++++++++++++ internal/codex/session_goal_test.go | 84 +++++++ internal/codex/session_goal_unix.go | 185 +++++++++++++++ internal/codex/session_goal_unix_test.go | 226 +++++++++++++++++++ internal/codex/session_prompt_unix.go | 3 + internal/codex/session_settings_unix_test.go | 55 +++++ internal/i18n/locales/da.json | 9 + internal/i18n/locales/de.json | 9 + internal/i18n/locales/en-GB.json | 9 + internal/i18n/locales/es.json | 9 + internal/i18n/locales/et.json | 9 + internal/i18n/locales/fi.json | 9 + internal/i18n/locales/fr.json | 9 + internal/i18n/locales/it.json | 9 + internal/i18n/locales/ja.json | 9 + internal/i18n/locales/nb.json | 9 + internal/i18n/locales/nl.json | 9 + internal/i18n/locales/pt-BR.json | 9 + internal/i18n/locales/pt-PT.json | 9 + internal/i18n/locales/ru.json | 9 + internal/i18n/locales/sv.json | 9 + internal/i18n/locales/tr.json | 9 + internal/i18n/locales/zh-Hans.json | 9 + internal/ui/model.go | 8 + internal/ui/monitor.go | 3 + internal/ui/monitor_commands.go | 17 +- internal/ui/monitor_commands_inline.go | 11 +- internal/ui/monitor_context.go | 1 + internal/ui/monitor_goal.go | 53 +++++ internal/ui/monitor_goal_test.go | 148 ++++++++++++ internal/ui/monitor_statusline.go | 4 +- internal/web/control_commands.go | 2 + internal/web/dist/assets/index-CoCF2Nd3.js | 47 ---- internal/web/dist/assets/index-CqJz1WRL.css | 1 + internal/web/dist/assets/index-DAmIts8A.js | 50 ++++ internal/web/dist/assets/index-DiPYjudz.css | 1 - internal/web/dist/index.html | 4 +- internal/web/session_goal_test.go | 35 +++ internal/web/state.go | 23 +- intro-post.md | 4 +- web/src/GoalStatus.svelte | 45 ++++ web/src/SessionCommands.svelte | 26 ++- web/src/SessionCopy.svelte | 14 +- web/src/Sessions.svelte | 27 ++- web/src/StatusLine.svelte | 14 +- web/src/state.svelte.ts | 10 + web/tests/browser.spec.ts | 196 ++++++++++++++++ 56 files changed, 1745 insertions(+), 93 deletions(-) create mode 100644 internal/codex/session_goal.go create mode 100644 internal/codex/session_goal_commands_unix.go create mode 100644 internal/codex/session_goal_test.go create mode 100644 internal/codex/session_goal_unix.go create mode 100644 internal/codex/session_goal_unix_test.go create mode 100644 internal/ui/monitor_goal.go create mode 100644 internal/ui/monitor_goal_test.go delete mode 100644 internal/web/dist/assets/index-CoCF2Nd3.js create mode 100644 internal/web/dist/assets/index-CqJz1WRL.css create mode 100644 internal/web/dist/assets/index-DAmIts8A.js delete mode 100644 internal/web/dist/assets/index-DiPYjudz.css create mode 100644 internal/web/session_goal_test.go create mode 100644 web/src/GoalStatus.svelte diff --git a/README.md b/README.md index 1b3f73ae..35af6433 100644 --- a/README.md +++ b/README.md @@ -1821,6 +1821,7 @@ Browse-only entries do not execute tools or change configuration. | `/cd` | Change the selected session’s directory after review and confirmation while idle and with no queued messages. Absolute, session-relative and `~/` paths are supported; success is verified from running configuration. Retains thread ID/history; does not reproduce native project-config reload/fork. | | `/cwd`, `/pwd` | Read-only aliases showing the running session’s current directory, including during active turns. | | `/rename` | Edit the selected session’s saved name and apply it without a second confirmation. Uses Codex’s name API; works during an active turn and does not send a prompt or change model settings. | +| `/goal` | Inspect this session’s objective, official goal state and token budget/usage. Set an objective, edit it, pause, resume or clear it. Native forms `/goal `, `/goal edit`, `/goal pause`, `/goal resume` and `/goal clear` are supported. The Budget option (also `/goal budget `) changes the total goal-token budget. Mutations require confirmation by default. | | `/model` | Advertised models, their descriptions and supported reasoning levels. Choosing a model resets its explicit speed override to the server default. | | Advertised speed commands, such as `/fast` | Show the default speed and every advertised tier in one list, initially highlighting the current speed. Up/Down highlights; **Enter APPLY** or clicking a choice applies it without a second confirmation. IDs and descriptions come from the current model's catalogue; no tier IDs are guessed. The changed speed is verified before success is reported. | | `/plan` | Advertised collaboration modes, using Codex's built-in mode instructions. | @@ -1828,6 +1829,30 @@ Browse-only entries do not execute tools or change configuration. | `/skills`, `/apps`, `/mcp`, `/hooks`, `/experimental` | **Browse-only** live inventories and supplied help, including MCP tool descriptions. Invoke/configure these through Codex. | | `/help` | Available command families. Unsupported or empty catalogues are omitted. | +**Session goals:** a connected shared app-server with its goals feature enabled +is required. Goal status appears directly below the configured statusline fields +in session rows; full detail places it right-aligned on the bottom border before +COPY and other controls, when space permits. Web shows the same per-session state +below row metadata and in the detail footer. **PURSUING GOAL**, **GOAL STALLED**, +**GOAL PAUSED**, **GOAL USAGE LIMITED**, **GOAL BUDGET LIMITED** and **GOAL COMPLETE** +come from Codex—not inactivity guesses—and do not replace WORKING, approvals or +TURN COMPLETE. Unavailable refreshes mark retained observations **GOAL STALE**. +Use `/goal` for the objective and counters. Linked agents do not inherit their +parent’s goal label, and goal observations are not persisted by Codexometer. + +Creating or resuming an active goal can start work immediately and consume quota, +even while the session was idle; updating an active objective can guide a running +turn. Editing a paused/stalled goal retains its state; editing a completed or +budget-limited goal reactivates it, matching Codex CLI. Pause/clear stop continued +pursuit but do not interrupt a turn already running. The budget is a **total +goal-token budget**, not an account spending limit; omitted budgets are retained, +and `unlimited` explicitly removes the goal budget. Codexometer accepts objectives +up to 4,096 characters and positive budgets up to 9,007,199,254,740,991; Codex can +impose further limits. Every mutation is session-scoped, freshly revalidated and +verified after acknowledgment, with no automatic retry. `--no-confirm` also opts +out of goal confirmations; read-only web mode never enables goal writes. +Older/unsupported servers omit the live `/goal` family rather than simulating it. + On Codex 0.166.0, `/hooks` queries the selected loaded thread, including hooks from its execution environments, and identifies their environment when supplied. Older servers retain directory-based discovery. A real thread/permission/transport @@ -1934,7 +1959,7 @@ action keys when using `--no-confirm`. **Slash-command audit:** the [complete version-matched inventory](docs/slash-command-support.md) compares Codexometer with Codex CLI **0.162.1**, including aliases, partial support and the reason for each missing adapter. Several missing commands already have -server APIs (`/compact`, `/fork`, `/review`, `/goal`, `/ps`, `/stop`); they need +server APIs (`/compact`, `/fork`, `/review`, `/ps`, `/stop`); they need Codexometer workflows. Native display commands need local UI implementations. The published reference is incomplete for this version and includes older names. diff --git a/docs/slash-command-support.md b/docs/slash-command-support.md index 4207da5f..aeb0e484 100644 --- a/docs/slash-command-support.md +++ b/docs/slash-command-support.md @@ -4,7 +4,7 @@ Audited on 2026-10-10 against **Codex CLI 0.162.1** (`rust-v0.162.1`), using its The tables cover all **63 registered command variants** and the three additional accepted aliases `/cwd`, `/pet` and `/clean`: **66 upstream command names** in total. Codexometer’s local `/help` entry and model-advertised speed aliases are outside that count. Platform, feature and debug-build filters affect actual visibility. The [published reference](https://learn.chatgpt.com/docs/developer-commands#built-in-slash-commands) omits some commands in this registry and also lists older names. Codexometer has explicit adapters/local UI implementations; it does not send slash commands as model prompts. There is no generic server endpoint to discover or execute the CLI's slash commands. -“Missing” below means no Codexometer slash adapter, **not** that the server lacks the capability. Live commands require a loaded session and shared app-server; browser control commands require writable mode. Windows' existing file-based monitoring path does not gain live server commands from this change. +“Missing” below means no Codexometer slash adapter, **not** that the server lacks the capability. Live commands require a loaded session and shared app-server; browser control commands require writable mode. Windows' existing file-based monitoring path does not gain live server commands from this change. Goal support below was additionally checked against the current local Codex source and official app-server goal documentation on 2026-11-04; it does not imply a new audit of every registry entry. ## Priority and complexity scale @@ -29,13 +29,14 @@ These are proposed priorities for Codexometer's session-monitoring/control role, Aliases on one row share the rating and implementation. Lifecycle commands share a thread-handoff foundation, so their costs should not be added as independent projects. P1 is a value/need ranking, not a claim that every P1 is a quick win. Work blocked on a foundation comes after that foundation even if it has the same priority. -Local Codexometer support below was updated on **2026-10-11**; the upstream registry snapshot remains 0.162.1. +Local Codexometer goal support below was updated on **2026-11-04**; the upstream registry snapshot remains 0.162.1. ## Implemented and partial support | Command | Support | Priority | Complexity | Implementation and limits | | --- | --- | --- | --- | --- | | `/rename` | Implemented | Done | — | Confirmed `thread/name/set`; works during active turns. | +| `/goal` | Session adapter | Done | — | Session-scoped `thread/goal/get`, `set`, `clear`; native objective/edit/pause/resume/clear forms plus a token-budget editor. Fresh review/verification, default mutation confirmation, live goal notifications and stale-safe snapshot fallback shared by TUI/web. Goal state follows row statusline fields and precedes full-detail controls. Requires a goal-enabled shared app-server. | | `/cd ` | Implemented with narrower semantics | P1 | Very high | Confirmed `thread/settings/update`, sending only `threadId` and `cwd`. Requires idle/local session, empty queue, no pending approval and an existing directory. Resolves relative paths from the running session directory, expands `~`/`~/`, rechecks symlinks and verifies the result from running configuration. No write retries. See the semantics below. Proposed next increment: destination project-context reload with trust/permission validation and a verified conversation handoff. Reuse the lifecycle foundation below; native-client cooperation may still be necessary. | | `/pwd`, `/cwd` | Implemented aliases | Done | — | Read-only `thread/resume` **without overrides** reports the running directory, including during active turns. Captured `thread/read.cwd` metadata is not used as the answer. The session directory/footer also follows live directory reads and settings notifications. | | `/model` | Session adapter | Done | — | Live model/reasoning catalogue, confirmed while idle. Clears explicit speed override when selecting a model; does not reproduce native CLI persistence. Session-only scope is intentional; no global-default editor is proposed. | @@ -66,7 +67,7 @@ Native `/cd` is a larger client workflow: destination project-configuration relo ## Missing commands with server capabilities or conversation workflows -These are adapter/workflow gaps. Where an API exists it is listed; this PR only adds directory commands. +These are adapter/workflow gaps. Where an API exists it is listed. | Command | Priority | Complexity | Mechanism / why missing | | --- | --- | --- | --- | @@ -80,7 +81,6 @@ These are adapter/workflow gaps. Where an API exists it is listed; this PR only | `/compact` | P1 | Medium | `thread/compact/start` exists; needs state checks and completion/error progress rather than reporting a queued operation as done. Proposed next increment: confirmed start plus completion/error tracking, keeping polling and approvals responsive throughout. | | `/recap` | P2 | High | Native summarization workflow has no adapter/progress UI; verify that workflow before choosing a server operation or prompt. Provisional estimate: first establish the native summarization semantics, then add a reviewed summary workflow without changing the source conversation unexpectedly. | | `/review` | P2 | High | `review/start` exists; no review-target picker, delivery mode or progress UI. Proposed next increment: target/delivery selection, confirmed start and a dedicated review-progress/result view. | -| `/goal` | P2 | Medium | `thread/goal/get`, `set`, `clear` exist; no goal editor, budget/clear confirmation or goal state. Proposed next increment: read/edit/clear goal and budget with session targeting, confirmation and live state refresh. | | `/side`, `/btw` | P3 | High | Ephemeral forks need a temporary conversation/draft view, thread routing and cleanup. Proposed next increment: an isolated ephemeral conversation UI with separate drafts, lifecycle cleanup and source-thread return. | | `/approve` | P1 | High | `thread/approveGuardianDeniedAction` exists; needs exact targeting of a recent automatic-review denial. Ordinary approval buttons are a different action. Proposed next increment: identify the exact retained denied action, review its original scope, confirm the retry and track the result. A generic approval shortcut is insufficient. | | `/ps` | P1 | Medium | `thread/backgroundTerminals/list` exists; no list/detail adapter. Telemetry process/session views do not reproduce it. Proposed next increment: a read-only, session-scoped terminal list with command/state detail and refresh; foundation for /stop. | @@ -135,7 +135,7 @@ These require Codexometer UX, not forwarding the command name to a server. 1. **P1 read-only additions:** `/ps`, `/status` and `/warnings` views. The Low-complexity `/usage` and `/copy` aliases are implemented. They build on existing controls and improve visibility before adding more mutations. 2. **P1 session controls:** `/compact`, the linked-agent `/subagents` picker, and reviewed `/stop`/`clean` built on `/ps`. Add `/approve` as its own High-complexity workflow with exact denied-action targeting. 3. **P1 lifecycle foundation:** `/new`, `/resume` and `/fork`, sharing subscription, selection, draft and history-handoff handling. Then pursue full `/cd` project-context parity; it depends on this foundation and remains Very high complexity. -4. **P2 extensions:** `/plan` inline prompts, `/goal`, `/archive`, `/debug-config`, daemon diagnostics and reviewed `/init`; then `/review`, `/export`, `/diff`, `/mention`, skill invocation and MCP login/inspection. Put `/clear` after `/new`, agent management after linked-agent navigation, and `/worktree` after lifecycle/project-context support. +4. **P2 extensions:** `/plan` inline prompts, `/archive`, `/debug-config`, daemon diagnostics and reviewed `/init`; then `/review`, `/export`, `/diff`, `/mention`, skill invocation and MCP login/inspection. Put `/clear` after `/new`, agent management after linked-agent navigation, and `/worktree` after lifecycle/project-context support. `/goal` is now implemented. 5. **P3/Defer:** optional global/account, import, installation, sandbox, daemon lifecycle, keymap and composer-mode work require explicit scope and demand. Treat daemon diagnostics as the smaller first step to its P2 workflow. Voice, IDE integration and pets should not displace core monitoring/control work. Exclude internal debug and retired/unregistered names. The next PR should cover **`/ps`**, a Medium-complexity read-only background-terminal inventory. Add **`/status`** and **`/warnings`** as separate read-only increments. The four Low-complexity families (`/usage`, `/copy`, `/theme`, `/exit`/`quit`) are now implemented. Subsequent PRs can add compaction and background-terminal stopping using those views. Full directory-context transitions need a separate design and PR covering project configuration/trust loading, conversation handoff and attached-client behavior. diff --git a/internal/codex/daemon_status.go b/internal/codex/daemon_status.go index a3c368c2..5175ff97 100644 --- a/internal/codex/daemon_status.go +++ b/internal/codex/daemon_status.go @@ -19,6 +19,7 @@ type sessionStatusProvider interface { } type sessionDaemonSnapshot struct { + Goals map[string]*SessionGoal UsageCoverage map[string]string Contexts map[string]SessionContext WorkingDirectories map[string]string diff --git a/internal/codex/daemon_status_unix.go b/internal/codex/daemon_status_unix.go index 4995600b..58ccd5bd 100644 --- a/internal/codex/daemon_status_unix.go +++ b/internal/codex/daemon_status_unix.go @@ -29,6 +29,10 @@ type daemonStatusProvider struct { queueRevision uint64 queueCapabilities map[string]queueCapability contexts map[string]*daemonContextState + goals map[string]goalObservation + goalVersions map[string]uint64 + goalGeneration uint64 + goalsUnsupported bool socketPath string mu sync.Mutex @@ -107,6 +111,7 @@ func (p *daemonStatusProvider) Fetch(ctx context.Context, threadIDs []string) (s } } + p.refreshSessionGoals(ctx, threadIDs) coverage := p.readUsageCoverage(ctx, threadIDs) statuses := make(map[string]sessionRuntimeStatus, len(threadIDs)) for _, threadID := range threadIDs { @@ -157,7 +162,13 @@ func (p *daemonStatusProvider) cachedStatusSnapshot(threadIDs []string, now time func (p *daemonStatusProvider) statusSnapshotLocked(threadIDs []string) sessionDaemonSnapshot { statuses := make(map[string]sessionRuntimeStatus, len(threadIDs)) directories := make(map[string]string, len(threadIDs)) + goals := make(map[string]*SessionGoal) for _, threadID := range threadIDs { + if _, subscribed := p.subscribed[threadID]; subscribed { + if goal := p.goals[threadID].goal; goal != nil { + goals[threadID] = goal.Clone() + } + } if status, ok := p.statuses[threadID]; ok { if state := p.contexts[threadID]; status == sessionRuntimeIdle && state != nil && state.completed { status = sessionRuntimeComplete @@ -180,6 +191,7 @@ func (p *daemonStatusProvider) statusSnapshotLocked(threadIDs []string) sessionD coverage[id] = issue } return sessionDaemonSnapshot{ + Goals: goals, UsageCoverage: coverage, Contexts: daemonContextSnapshot(p.contexts, threadIDs, statuses), WorkingDirectories: directories, @@ -238,6 +250,9 @@ func (p *daemonStatusProvider) unsubscribeMissing(ctx context.Context, threadIDs p.mu.Lock() delete(p.subscribed, threadID) delete(p.contexts, threadID) + delete(p.goals, threadID) + delete(p.goalVersions, threadID) + p.goalGeneration++ delete(p.threadDirectories, threadID) for key := range p.reroutedTurns { if key.threadID == threadID { @@ -480,6 +495,7 @@ func (p *daemonStatusProvider) readLoop(connection *websocket.Conn, wires ...*da if envelope.Method == "thread/queue/changed" { p.queueRevision++ } + p.goalNotificationLocked(envelope.Method, envelope.Params) if p.contexts == nil { p.contexts = map[string]*daemonContextState{} } @@ -619,6 +635,10 @@ func (p *daemonStatusProvider) disconnect(connection *websocket.Conn) { } p.subscribed = nil p.contexts = nil + p.goals = nil + p.goalVersions = nil + p.goalsUnsupported = false + p.goalGeneration++ p.reroutedTurns = nil p.lastStatusAt = time.Time{} p.statusThreads = nil diff --git a/internal/codex/live_usage.go b/internal/codex/live_usage.go index 4b2738b4..b5c8795b 100644 --- a/internal/codex/live_usage.go +++ b/internal/codex/live_usage.go @@ -60,6 +60,7 @@ type LiveUsageSnapshot struct { // LiveUsageSession is one independently started local Codex session. Token // usage from explicitly linked spawned descendants is folded into the root. type LiveUsageSession struct { + Goal *SessionGoal ModelSettings SessionModelSettings ID string Name string @@ -139,6 +140,7 @@ type LiveUsageReader struct { nameIndexInfo os.FileInfo daemonContexts map[string]SessionContext daemonDirectories map[string]string + daemonGoals map[string]*SessionGoal SessionsRoot string WriterLocksRoot string statusProvider sessionStatusProvider @@ -406,6 +408,7 @@ func (r *LiveUsageReader) fetchTokenUsage(ctx context.Context, forceFullDiscover var daemonCoverage map[string]string r.daemonContexts = nil r.daemonDirectories = nil + r.daemonGoals = nil appServerUp := false r.daemonSubscribedThreads = nil if r.statusProvider != nil { @@ -415,6 +418,7 @@ func (r *LiveUsageReader) fetchTokenUsage(ctx context.Context, forceFullDiscover r.daemonContexts = daemonSnapshot.Contexts daemonCoverage = daemonSnapshot.UsageCoverage r.daemonDirectories = daemonSnapshot.WorkingDirectories + r.daemonGoals = daemonSnapshot.Goals r.ingestResolvedModelObservations(daemonSnapshot.ModelObservations) r.daemonSubscribedThreads = daemonSnapshot.SubscribedThreads } @@ -1541,6 +1545,7 @@ func (r *LiveUsageReader) sessionSnapshots(now time.Time, liveWriters map[string activeCount := 0 anyWorking := false for _, session := range groups { + session.Goal = r.daemonGoals[session.ID].Clone() if root := byID[session.ID]; root != nil && !session.Unattributed { session.ModelSettings = root.modelSettings } diff --git a/internal/codex/session_command_cache.go b/internal/codex/session_command_cache.go index c35eaa4f..16b1ef82 100644 --- a/internal/codex/session_command_cache.go +++ b/internal/codex/session_command_cache.go @@ -59,6 +59,9 @@ func commandMenuPath(path string) string { func cacheableCommandPath(path string) bool { // Typed names and paths are short-lived reviews, not catalogue branches. + if _, _, input := SessionCommandInputValue(path); input || strings.HasPrefix(path, "goal ") { + return false + } return ValidSessionCommandPath(path) && !strings.HasPrefix(path, "/") && !strings.HasPrefix(path, "rename/") && !strings.HasPrefix(path, "rename ") && !strings.HasPrefix(path, "cd/") && !strings.HasPrefix(path, "cd ") } diff --git a/internal/codex/session_commands.go b/internal/codex/session_commands.go index 8e888ee3..c6422953 100644 --- a/internal/codex/session_commands.go +++ b/internal/codex/session_commands.go @@ -12,7 +12,7 @@ const ( SessionRenameInputLimit = 512 SessionDirectoryInputLimit = 1024 // One UTF-8 rune can take four bytes, each percent-encoded as three bytes. - SessionCommandPathLimit = len("rename/") + SessionDirectoryInputLimit*utf8.UTFMax*3 + SessionCommandPathLimit = len("goal/edit/") + SessionGoalInputLimit*utf8.UTFMax*3 ) // ValidSessionCommandPath shares the encoded transport bound and decoded editor @@ -23,12 +23,18 @@ func ValidSessionCommandPath(path string) bool { return false } command := strings.TrimPrefix(strings.TrimSpace(path), "/") + if objective, direct := strings.CutPrefix(command, "goal "); direct { + return utf8.RuneCountInString(objective) <= SessionGoalInputLimit + } for _, family := range []struct { name string limit int }{ {"rename", SessionRenameInputLimit}, {"cd", SessionDirectoryInputLimit}, + {"goal/set", SessionGoalInputLimit}, + {"goal/edit", SessionGoalInputLimit}, + {"goal/budget", 32}, } { value, encoded := strings.CutPrefix(command, family.name+"/") if !encoded { diff --git a/internal/codex/session_commands_unix.go b/internal/codex/session_commands_unix.go index af971ff1..44de8b08 100644 --- a/internal/codex/session_commands_unix.go +++ b/internal/codex/session_commands_unix.go @@ -44,13 +44,21 @@ func (p *daemonStatusProvider) sessionCommandScope(id, path string) string { } status := p.statuses[id] transition := p.commandTransitions[id] + goalScope := "" + if path == "goal" || strings.HasPrefix(path, "goal/") || strings.HasPrefix(path, "goal ") { + goalScope = goalIdentity(p.goals[id].goal) + if path == "goal" { + goalScope = commandDigest(p.goals[id].goal) + } + status, transition = sessionRuntimeUnknown, 0 + } if path == "" || path == "help" { status = sessionRuntimeUnknown // Root names/help survive ordinary turn transitions. transition = 0 } // Resuming a thread can repeat its settings notification. Invalidate on // effective values, not notification counters, so warming can settle. - return commandDigest([]any{p.commandGeneration, status, transition, p.threadDirectories[id], p.threadSettings[id]}) + return commandDigest([]any{p.commandGeneration, status, transition, p.threadDirectories[id], p.threadSettings[id], goalScope}) } func commandDigest(value any) string { @@ -148,6 +156,7 @@ func (p *daemonStatusProvider) sessionCommands(ctx context.Context, id, path str if name, ok := strings.CutPrefix(path, "rename "); ok { path = "rename/" + url.PathEscape(strings.TrimSpace(name)) } + path = goalCommandPath(path) if directory, ok := strings.CutPrefix(path, "cd "); ok { path = "cd/" + url.PathEscape(strings.TrimSpace(directory)) } @@ -171,7 +180,7 @@ func (p *daemonStatusProvider) finalizeCommandMenu(thread commandThread, path st connection := fmt.Sprintf("%p", p.connection) p.mu.Unlock() status := thread.Status.Type - if menu.Picker { + if menu.Picker || path == "goal" || strings.HasPrefix(path, "goal/") { // Speed overrides target future turns, so starting/completing a turn // does not invalidate confirmation. Effective settings still do. status = "" @@ -181,19 +190,25 @@ func (p *daemonStatusProvider) finalizeCommandMenu(thread commandThread, path st } func normalizeCommandMenu(menu SessionCommandMenu) SessionCommandMenu { - safeHelp := commandText(menu.Help) == strings.TrimSpace(menu.Help) - menu.Title, menu.Help = commandLabel(menu.Title), commandText(menu.Help) + helpText := commandText + if menu.Path == "goal" || strings.HasPrefix(menu.Path, "goal/") { + // A complete objective plus review instructions can exceed the ordinary + // telemetry excerpt budget. Never silently clip an actionable review. + helpText = func(s string) string { return strings.TrimSpace(SanitizeApprovalText(s)) } + } + safeHelp := helpText(menu.Help) == strings.TrimSpace(menu.Help) + menu.Title, menu.Help = commandLabel(menu.Title), helpText(menu.Help) unique := make([]SessionCommandChoice, 0, len(menu.Choices)) seen := map[string]bool{} for i := range menu.Choices { o := &menu.Choices[i] - if o.method != "" && (!safeHelp || commandLabel(o.Label) != o.Label || commandText(o.Help) != strings.TrimSpace(o.Help)) { + if o.method != "" && (!safeHelp || commandLabel(o.Label) != o.Label || helpText(o.Help) != strings.TrimSpace(o.Help)) { o.method = "" o.params = nil o.Help = "Complete safe help unavailable. Use Codex for this option." o.Unavailable = o.Help } - o.Label, o.Help = commandLabel(o.Label), commandText(o.Help) + o.Label, o.Help = commandLabel(o.Label), helpText(o.Help) o.Unavailable = commandText(o.Unavailable) o.ID = commandDigest([]any{o.Label, o.Help, o.Next, o.Unavailable, o.method, o.params}) o.Action = o.method != "" @@ -248,7 +263,7 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, } if path == "" || path == "help" { - families := []string{"rename", "cd", "cwd", "pwd", "model", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} + families := []string{"rename", "cd", "cwd", "pwd", "model", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental", "goal"} menus := make([]SessionCommandMenu, len(families)) scopes := make([]string, len(families)) errs := make([]error, len(families)) @@ -288,6 +303,9 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, if parts[0] == "cd" || parts[0] == "cwd" || parts[0] == "pwd" { return p.commandDirectoryMenu(ctx, t, path) } + if parts[0] == "goal" { + return p.commandGoalMenu(ctx, t, path) + } if parts[0] == "rename" { m.Title = "/rename" m.Help = "Rename this session in Codex. Enter a single-line name and apply it. It does not send a prompt or change model settings." @@ -441,7 +459,7 @@ func commandReserved(s string) bool { if IsLocalSessionCommand(s) { return true } - for _, name := range []string{"help", "rename", "cd", "cwd", "pwd", "model", "tier", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} { + for _, name := range []string{"help", "rename", "cd", "cwd", "pwd", "model", "tier", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental", "goal"} { if s == name { return true } @@ -467,6 +485,9 @@ func (p *daemonStatusProvider) ExecuteSessionCommand(ctx context.Context, id, pa } for _, o := range m.Choices { if o.ID == choice && o.Action { + if strings.HasPrefix(o.method, "thread/goal/") { + return p.executeGoalCommand(ctx, conn, id, o) + } _, hasTier := o.params["serviceTier"] speedOnly := m.Picker && o.method == "thread/settings/update" && hasTier && len(o.params) == 2 p.mu.Lock() diff --git a/internal/codex/session_goal.go b/internal/codex/session_goal.go new file mode 100644 index 00000000..62e58ca9 --- /dev/null +++ b/internal/codex/session_goal.go @@ -0,0 +1,98 @@ +package codex + +import ( + "fmt" + "net/url" + "strings" +) + +const SessionGoalInputLimit = 4096 + +// SessionGoal is an observed, session-specific goal, not an instruction to this +// client. Only explicit, separately validated command actions can mutate it. +type SessionGoal struct { + ThreadID string `json:"threadId"` + Objective string `json:"objective"` + Status string `json:"status"` + TokenBudget *int64 `json:"tokenBudget"` + TokensUsed int64 `json:"tokensUsed"` + TimeUsedSeconds int64 `json:"timeUsedSeconds"` + CreatedAt int64 `json:"createdAt"` + UpdatedAt int64 `json:"updatedAt"` + Stale bool `json:"stale,omitempty"` +} + +func (g *SessionGoal) Clone() *SessionGoal { + if g == nil { + return nil + } + copy := *g + if g.TokenBudget != nil { + budget := *g.TokenBudget + copy.TokenBudget = &budget + } + return © +} + +func (g *SessionGoal) Label() string { + if g == nil { + return "" + } + if g.Stale { + return "GOAL STALE" + } + switch g.Status { + case "active": + return "PURSUING GOAL" + case "blocked": + return "GOAL STALLED" + case "paused": + return "GOAL PAUSED" + case "usageLimited": + return "GOAL USAGE LIMITED" + case "budgetLimited": + return "GOAL BUDGET LIMITED" + case "complete": + return "GOAL COMPLETE" + default: + return "GOAL STATUS UNKNOWN" + } +} + +func (g *SessionGoal) Usage() string { + if g == nil { + return "" + } + if g.TokenBudget != nil { + return fmt.Sprintf("%d / %d TOKENS", g.TokensUsed, *g.TokenBudget) + } + return fmt.Sprintf("%d TOKENS // %ds", g.TokensUsed, g.TimeUsedSeconds) +} + +func knownGoalStatus(status string) bool { + switch status { + case "active", "paused", "blocked", "usageLimited", "budgetLimited", "complete": + return true + } + return false +} + +// Input command paths have an explicit allowlist shared by adapters and views. +// The value is URL-encoded as a single segment, including any literal slashes. +func SessionCommandInputValue(path string) (parent, value string, ok bool) { + for _, prefix := range []string{"rename", "cd", "goal/set", "goal/edit", "goal/budget"} { + if encoded, found := strings.CutPrefix(path, prefix+"/"); found { + decoded, err := url.PathUnescape(encoded) + return prefix, decoded, err == nil + } + } + return "", "", false +} + +func SessionCommandInputPath(path string) bool { + switch path { + case "rename", "cd", "goal/set", "goal/edit", "goal/budget": + return true + } + return false +} diff --git a/internal/codex/session_goal_commands_unix.go b/internal/codex/session_goal_commands_unix.go new file mode 100644 index 00000000..dfd59e94 --- /dev/null +++ b/internal/codex/session_goal_commands_unix.go @@ -0,0 +1,179 @@ +//go:build unix + +package codex + +import ( + "context" + "errors" + "fmt" + "strconv" + "strings" + "unicode/utf8" + + "github.com/gorilla/websocket" +) + +func (p *daemonStatusProvider) commandGoalMenu(ctx context.Context, thread commandThread, path string) (SessionCommandMenu, error) { + goal, err := p.readSessionGoal(ctx, thread.ID) + menu := SessionCommandMenu{Title: "/goal", Revision: goalIdentity(goal), Choices: []SessionCommandChoice{}} + if err != nil { + return menu, fmt.Errorf("goal state unavailable; check shared app-server goal support: %w", err) + } + summary := goalCommandSummary(goal) + if goal != nil && path != "goal" { + budget := "unlimited" + if goal.TokenBudget != nil { + budget = strconv.FormatInt(*goal.TokenBudget, 10) + } + // Progress is live telemetry, not a different requested mutation. Keep + // action help/IDs stable while only token/time counters advance. + summary = fmt.Sprintf("%s\nObjective: %s\nTotal token budget: %s", goal.Label(), SanitizeSessionContext(goal.Objective), budget) + } + menu.Help = summary + "\nGoal changes affect only this session. Creating, editing or resuming an active goal can start work and consume quota. No automatic retries." + if goal != nil && (!knownGoalStatus(goal.Status) || goal.Stale) { + return menu, errors.New("current goal state is unknown; refresh before changing it") + } + if path == "goal" { + if goal != nil { + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: goal.Label(), Help: goalCommandSummary(goal)}) + } + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: "Set goal", Help: "Set an objective and activate pursuit. May start an idle turn. Existing token budget is retained; use Budget to change it.", Next: "goal/set"}) + if goal != nil { + menu.Choices = append(menu.Choices, + SessionCommandChoice{Label: "Edit goal", Help: "Edit the objective. Paused/stalled states are retained; editing a completed or budget-limited goal reactivates it.", Next: "goal/edit"}, + SessionCommandChoice{Label: "Token budget", Help: "Set a total goal-token budget, or unlimited. This is not an account quota limit.", Next: "goal/budget"}) + if goal.Status == "active" { + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: "Pause goal", Help: "Pause continued pursuit; does not interrupt a running turn.", Next: "goal/pause"}) + } else { + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: "Resume goal", Help: "Resume pursuit. May start work; server budget and usage limits still apply.", Next: "goal/resume"}) + } + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: "Clear goal", Help: "Remove this session's goal. Does not delete the session or interrupt its current turn.", Next: "goal/clear"}) + } + return menu, nil + } + parent, value, reviewing := SessionCommandInputValue(path) + if !reviewing { + parent = path + } + if parent == "goal/set" || parent == "goal/edit" || parent == "goal/budget" { + if parent != "goal/set" && goal == nil { + return menu, errors.New("no goal is set for this session") + } + if !reviewing { + menu.Input, menu.InputLabel, menu.InputLimit = true, "Goal objective", SessionGoalInputLimit + if parent == "goal/edit" { + menu.Value = goal.Objective + } else if parent == "goal/budget" { + menu.InputLabel, menu.InputLimit, menu.Value = "Token budget (or unlimited)", 32, "unlimited" + if goal.TokenBudget != nil { + menu.Value = strconv.FormatInt(*goal.TokenBudget, 10) + } + } + return menu, nil + } + params := map[string]any{"threadId": thread.ID, "origin": "user"} + label := "Apply goal objective" + if parent == "goal/budget" { + label = "Apply goal token budget" + if strings.EqualFold(value, "unlimited") { + params["tokenBudget"] = nil + } else { + budget, err := strconv.ParseInt(value, 10, 64) + if err != nil || budget <= 0 || budget > 9007199254740991 { + return menu, errors.New("budget must be a positive integer up to 9007199254740991, or unlimited") + } + params["tokenBudget"] = budget + } + menu.Help += "\nNew total token budget: " + value + ". A stopped goal is not automatically resumed." + } else { + if !utf8.ValidString(value) || utf8.RuneCountInString(value) > SessionGoalInputLimit || strings.TrimSpace(value) == "" || SanitizeSessionContext(value) != value { + return menu, errors.New("goal objective must be safe non-empty text within the input limit") + } + params["objective"] = value + status := "active" + if parent == "goal/edit" && goal.Status != "complete" && goal.Status != "budgetLimited" { + status = goal.Status + } + params["status"] = status + menu.Help += "\nRequested objective: " + value + "\nRequested status: " + status + ". Existing token budget is retained." + } + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: label, Help: menu.Help, method: "thread/goal/set", params: params}) + return menu, nil + } + if goal == nil { + return menu, errors.New("no goal is set for this session") + } + params := map[string]any{"threadId": thread.ID, "origin": "user"} + method, label := "thread/goal/set", "" + switch path { + case "goal/pause": + label, params["status"] = "Pause goal", "paused" + menu.Help += "\nPausing stops continued pursuit, not an already-running turn." + case "goal/resume": + label, params["status"] = "Resume goal", "active" + menu.Help += "\nResuming may immediately start further turns and consume quota. Budget and account limits still apply." + case "goal/clear": + label, method = "Clear goal", "thread/goal/clear" + menu.Help += "\nThis removes the goal, not the conversation. A running turn is not interrupted." + default: + return menu, ErrSessionCommand + } + menu.Choices = append(menu.Choices, SessionCommandChoice{Label: label, Help: menu.Help, method: method, params: params}) + return menu, nil +} + +func (p *daemonStatusProvider) executeGoalCommand(ctx context.Context, conn *websocket.Conn, id string, choice SessionCommandChoice) error { + p.mu.Lock() + _, subscribed := p.subscribed[id] + current := p.connection == conn + p.mu.Unlock() + if !current || !subscribed { + return ErrSessionCommand + } + var result struct { + Goal *SessionGoal + Cleared *bool + } + if err := p.requestOn(ctx, conn, choice.method, choice.params, &result); err != nil { + return err // Never retry a possibly applied goal mutation. + } + if choice.method == "thread/goal/clear" { + if result.Cleared == nil { + return errors.New("goal clear acknowledgement unavailable; check Codex") + } + } else { + if result.Goal == nil || validateSessionGoal(result.Goal, id) != nil { + return errors.New("goal change acknowledgement unavailable; check Codex") + } + if status, ok := choice.params["status"].(string); ok && result.Goal.Status != status { + return errors.New("goal status acknowledgement differs; check Codex") + } + } + goal, err := p.readSessionGoal(ctx, id) + if err != nil { + return errors.New("goal change unconfirmed; check Codex before retrying") + } + if choice.method == "thread/goal/clear" { + if goal != nil { + return errors.New("goal clear unconfirmed; check Codex") + } + return nil + } + if goal == nil { + return errors.New("goal change unconfirmed; check Codex") + } + if objective, ok := choice.params["objective"].(string); ok && goal.Objective != objective { + return errors.New("goal objective update unconfirmed; check Codex") + } + if budget, changing := choice.params["tokenBudget"]; changing { + if budget == nil && goal.TokenBudget != nil || budget != nil && (goal.TokenBudget == nil || *goal.TokenBudget != budget.(int64)) { + return errors.New("goal budget update unconfirmed; check Codex") + } + } + // Active pursuit can legitimately become blocked/limited/complete after + // the acknowledged update but before the verification read. + if desired, ok := choice.params["status"].(string); ok && desired != "active" && goal.Status != desired { + return errors.New("goal status update unconfirmed; check Codex") + } + return nil +} diff --git a/internal/codex/session_goal_test.go b/internal/codex/session_goal_test.go new file mode 100644 index 00000000..ce4dd92e --- /dev/null +++ b/internal/codex/session_goal_test.go @@ -0,0 +1,84 @@ +package codex + +import ( + "net/url" + "strings" + "testing" + "time" +) + +func TestSessionGoalLabelsAndCloning(t *testing.T) { + for status, label := range map[string]string{"active": "PURSUING GOAL", "blocked": "GOAL STALLED", "paused": "GOAL PAUSED", "usageLimited": "GOAL USAGE LIMITED", "budgetLimited": "GOAL BUDGET LIMITED", "complete": "GOAL COMPLETE", "future": "GOAL STATUS UNKNOWN"} { + g := &SessionGoal{Status: status} + if g.Label() != label { + t.Fatal(status, g.Label()) + } + g.Stale = true + if g.Label() != "GOAL STALE" { + t.Fatal("stale observation advertised live goal state") + } + } + budget := int64(100) + g := &SessionGoal{TokenBudget: &budget, TokensUsed: 4} + clone := g.Clone() + *clone.TokenBudget = 999 + if *g.TokenBudget != 100 || g.Usage() != "4 / 100 TOKENS" || (*SessionGoal)(nil).Clone() != nil { + t.Fatal("goal clone aliased its budget or lost usage") + } +} + +func TestSessionGoalDoesNotMergeAcrossLinkedAgents(t *testing.T) { + now := time.Now() + r := &LiveUsageReader{files: map[string]*rolloutCursor{ + "root": {threadID: "root", lastModified: now}, + "child": {threadID: "child", parentThreadID: "root", nonRoot: true, lastModified: now}, + }, daemonGoals: map[string]*SessionGoal{ + "child": {ThreadID: "child", Status: "active", Objective: "Child objective"}, + }} + sessions, _, _ := r.sessionSnapshots(now, nil, false, nil) + if len(sessions) != 1 || sessions[0].Goal != nil { + t.Fatal("child goal leaked into the grouped root") + } + r.daemonGoals["root"] = &SessionGoal{ThreadID: "root", Status: "paused", Objective: "Root objective"} + sessions, _, _ = r.sessionSnapshots(now, nil, false, nil) + if sessions[0].Goal == nil || sessions[0].Goal.Objective != "Root objective" { + t.Fatal("root lost its own goal") + } + sessions[0].Goal.Objective = "Changed projection" + if r.daemonGoals["root"].Objective != "Root objective" { + t.Fatal("session projection aliased the goal cache") + } +} + +func TestGoalCommandInputBounds(t *testing.T) { + for _, parent := range []string{"goal/set", "goal/edit"} { + value := strings.Repeat("界", SessionGoalInputLimit) + path := parent + "/" + url.PathEscape(value) + if !ValidSessionCommandPath(path) { + t.Fatal("Unicode goal at the input limit rejected") + } + p, v, ok := SessionCommandInputValue(path) + if !ok || p != parent || v != value || !SessionCommandInputPath(parent) { + t.Fatal("goal input path did not round-trip") + } + if ValidSessionCommandPath(parent + "/" + url.PathEscape(value+"x")) { + t.Fatal("oversized goal accepted") + } + } + if !ValidSessionCommandPath("/goal "+strings.Repeat("😀", SessionGoalInputLimit)) || ValidSessionCommandPath("goal/edit/%zz") { + t.Fatal("direct/encoded goal input bounds differ") + } +} + +func TestGoalReviewsAreNotCachedAsCatalogues(t *testing.T) { + for _, path := range []string{"goal/set/Objective", "goal/edit/Objective", "goal/budget/1000", "goal An objective", "goal pause"} { + if cacheableCommandPath(path) { + t.Fatal("goal input/review cached as a catalogue branch:", path) + } + } + for _, path := range []string{"goal", "goal/edit", "goal/budget", "goal/pause"} { + if !cacheableCommandPath(path) { + t.Fatal("goal menu lost normal in-memory browsing:", path) + } + } +} diff --git a/internal/codex/session_goal_unix.go b/internal/codex/session_goal_unix.go new file mode 100644 index 00000000..a4dec3de --- /dev/null +++ b/internal/codex/session_goal_unix.go @@ -0,0 +1,185 @@ +//go:build unix + +package codex + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net/url" + "strings" + "time" + "unicode/utf8" +) + +const goalRefreshEvery = 30 * time.Second + +type goalObservation struct { + goal *SessionGoal + at time.Time + failed bool +} + +func goalIdentity(goal *SessionGoal) string { + if goal == nil { + return commandDigest(nil) + } + return commandDigest([]any{goal.ThreadID, goal.Objective, goal.Status, goal.TokenBudget, goal.CreatedAt, goal.Stale}) +} + +func validateSessionGoal(goal *SessionGoal, id string) error { + if goal == nil { + return nil + } + if goal.ThreadID != id || !utf8.ValidString(goal.Objective) || utf8.RuneCountInString(goal.Objective) > SessionGoalInputLimit || + goal.Objective == "" || goal.TokensUsed < 0 || goal.TimeUsedSeconds < 0 || goal.TokenBudget != nil && *goal.TokenBudget <= 0 { + return errors.New("goal observation unavailable or invalid") + } + return nil +} + +func (p *daemonStatusProvider) observeGoalLocked(id string, goal *SessionGoal, at time.Time) { + if p.goals == nil { + p.goals = make(map[string]goalObservation) + p.goalVersions = make(map[string]uint64) + } + if _, known := p.goals[id]; !known && len(p.goals) >= 256 { + return + } + p.goals[id] = goalObservation{goal: goal.Clone(), at: at} + p.goalVersions[id]++ +} + +// Poll snapshots to cover startup/missed notifications; normal changes arrive +// on the existing daemon stream. Never persist or infer goal state locally. +func (p *daemonStatusProvider) readSessionGoal(ctx context.Context, id string) (*SessionGoal, error) { + p.mu.Lock() + conn, version, generation := p.connection, p.goalVersions[id], p.goalGeneration + unsupported := p.goalsUnsupported + p.mu.Unlock() + if conn == nil || unsupported { + return nil, errors.New("goals require a connected app-server with goal support") + } + var response struct{ Goal json.RawMessage } + err := p.requestOn(ctx, conn, "thread/goal/get", map[string]any{"threadId": id}, &response) + if err != nil { + p.mu.Lock() + if p.connection == conn { + var rpc *daemonResponseError + if errors.As(err, &rpc) { + var wire struct{ Code int } + if json.Unmarshal([]byte(rpc.payload), &wire) == nil && wire.Code == -32601 { + p.goalsUnsupported = true + } + } + } + p.mu.Unlock() + return nil, err + } + if len(response.Goal) == 0 { + return nil, errors.New("goal response unavailable") + } + var goal *SessionGoal + if json.Unmarshal(response.Goal, &goal) != nil || validateSessionGoal(goal, id) != nil { + return nil, errors.New("goal response invalid") + } + if goal != nil { + goal.Stale = false + } + p.mu.Lock() + defer p.mu.Unlock() + if p.connection != conn || p.goalGeneration != generation { + return nil, errors.New("goal connection changed") + } + if p.goalVersions[id] != version { + current := p.goals[id] + if current.failed { + return nil, errors.New("newer goal observation unavailable") + } + return current.goal.Clone(), nil // A newer successful observation wins. + } + p.observeGoalLocked(id, goal, time.Now()) + return goal.Clone(), nil +} + +func (p *daemonStatusProvider) refreshSessionGoals(ctx context.Context, ids []string) { + for _, id := range ids { + p.mu.Lock() + observation, known := p.goals[id] + conn, version := p.connection, p.goalVersions[id] + _, subscribed := p.subscribed[id] + refresh := subscribed && !p.goalsUnsupported && (!known || time.Since(observation.at) >= goalRefreshEvery) + p.mu.Unlock() + if !refresh || ctx.Err() != nil { + continue + } + if _, err := p.readSessionGoal(ctx, id); err != nil { + p.mu.Lock() + // Back off failed reads too; preserve the last value as stale, never + // substitute "no goal" or claim pursuit after an unavailable read. + if current := p.goals[id]; p.connection == conn && p.goalVersions[id] == version && current.at == observation.at { + goal := current.goal.Clone() + if goal != nil { + goal.Stale = true + } + p.observeGoalLocked(id, goal, time.Now()) + if failed, stored := p.goals[id]; stored { + failed.failed = true + p.goals[id] = failed + } + } + p.mu.Unlock() + } + } +} + +func (p *daemonStatusProvider) goalNotificationLocked(method string, raw json.RawMessage) { + if method != "thread/goal/updated" && method != "thread/goal/cleared" { + return + } + var event struct { + ThreadID string `json:"threadId"` + Goal *SessionGoal `json:"goal"` + } + if json.Unmarshal(raw, &event) != nil || event.ThreadID == "" { + return + } + if _, subscribed := p.subscribed[event.ThreadID]; !subscribed { + return + } + if method == "thread/goal/updated" && (event.Goal == nil || validateSessionGoal(event.Goal, event.ThreadID) != nil) { + return + } + if method == "thread/goal/cleared" { + event.Goal = nil + } else { + event.Goal.Stale = false + } + p.observeGoalLocked(event.ThreadID, event.Goal, time.Now()) +} + +func goalCommandSummary(goal *SessionGoal) string { + if goal == nil { + return "No goal is set for this session. Set an objective to let Codex pursue it across turns." + } + return fmt.Sprintf("%s\nObjective: %s\n%s", goal.Label(), SanitizeSessionContext(goal.Objective), goal.Usage()) +} + +func goalCommandPath(path string) string { + input, found := strings.CutPrefix(path, "goal ") + if !found { + return path + } + input = strings.TrimSpace(input) + for _, action := range []string{"edit", "budget"} { + if value, found := strings.CutPrefix(input, action+" "); found { + return "goal/" + action + "/" + url.PathEscape(strings.TrimSpace(value)) + } + } + switch strings.ToLower(input) { + case "pause", "resume", "clear", "edit", "budget": + return "goal/" + strings.ToLower(input) + } + return "goal/set/" + url.PathEscape(input) +} diff --git a/internal/codex/session_goal_unix_test.go b/internal/codex/session_goal_unix_test.go new file mode 100644 index 00000000..45cd4266 --- /dev/null +++ b/internal/codex/session_goal_unix_test.go @@ -0,0 +1,226 @@ +//go:build unix + +package codex + +import ( + "context" + "encoding/json" + "net/url" + "strings" + "testing" + "time" +) + +func goalFixture(t *testing.T) (*daemonStatusProvider, *quotaDaemonFixture) { + t.Helper() + p, f := newQuotaDaemon(t) + budget := int64(10000) + f.goals = map[string]*SessionGoal{ + "one": {ThreadID: "one", Objective: "Fix the flaky tests", Status: "active", TokenBudget: &budget, TokensUsed: 200, CreatedAt: 1}, + "two": {ThreadID: "two", Objective: "Other session objective", Status: "paused", CreatedAt: 2}, + } + if _, ok := p.Fetch(context.Background(), []string{"one", "two"}); !ok { + t.Fatal("goal fixture did not connect") + } + return p, f +} + +func applyGoalCommand(t *testing.T, p *daemonStatusProvider, path string) { + t.Helper() + menu, err := p.SessionCommands(context.Background(), "one", path) + if err != nil || len(menu.Choices) != 1 || !menu.Choices[0].Action || menu.Choices[0].Reversible { + t.Fatal("goal action unavailable or incorrectly reversible", path, menu, err) + } + if err := p.ExecuteSessionCommand(context.Background(), "one", menu.Path, menu.Revision, menu.Choices[0].ID); err != nil { + t.Fatal("goal mutation failed", path, err) + } +} + +func TestGoalCommandsLifecycleAndSessionScope(t *testing.T) { + p, f := goalFixture(t) + root, err := p.SessionCommands(context.Background(), "one", "goal") + if err != nil || !strings.Contains(root.Help, "200 / 10000") || len(root.Choices) < 5 { + t.Fatal("goal summary/options missing", root, err) + } + applyGoalCommand(t, p, "goal pause") + edit, err := p.SessionCommands(context.Background(), "one", "goal edit") + if err != nil || !edit.Input || edit.Value != "Fix the flaky tests" || edit.ReversibleInput { + t.Fatal("goal edit did not retain the objective/confirmation") + } + applyGoalCommand(t, p, "goal/edit/"+url.PathEscape("Preserve spaces / Unicode 界")) + if f.goals["one"].Status != "paused" { + t.Fatal("editing a paused goal resumed it") + } + applyGoalCommand(t, p, "goal budget 20000") + applyGoalCommand(t, p, "goal resume") + applyGoalCommand(t, p, "goal/budget/unlimited") + if f.goals["one"].Objective != "Preserve spaces / Unicode 界" || f.goals["one"].Status != "active" || f.goals["one"].TokenBudget != nil { + t.Fatal("goal state/budget wrong", f.goals["one"]) + } + applyGoalCommand(t, p, "goal clear") + if p.statusSnapshotLocked([]string{"one"}).Goals["one"] != nil { + t.Fatal("cleared goal remained visible") + } + f.commandStatus = "active" + applyGoalCommand(t, p, "goal New objective while a turn is running") + if f.goals["one"].Objective != "New objective while a turn is running" || f.goals["two"].Objective != "Other session objective" { + t.Fatal("goal update lost its target") + } + for i, write := range f.goalWrites { + if write["threadId"] != "one" || write["origin"] != "user" || !strings.HasPrefix(f.goalMethods[i], "thread/goal/") { + t.Fatal("goal changed another session or omitted user provenance", write) + } + } +} + +func TestGoalReviewIgnoresProgressButRejectsSemanticDrift(t *testing.T) { + for _, drift := range []string{"progress", "objective", "status", "budget"} { + t.Run(drift, func(t *testing.T) { + p, f := goalFixture(t) + menu, err := p.SessionCommands(context.Background(), "one", "goal/pause") + if err != nil { + t.Fatal(err) + } + f.mu.Lock() + g := f.goals["one"] + switch drift { + case "progress": + g.TokensUsed, g.TimeUsedSeconds, g.UpdatedAt = 999, 100, 42 + f.commandStatus = "active" + case "objective": + g.Objective = "Different objective" + case "status": + g.Status = "blocked" + case "budget": + budget := int64(20000) + g.TokenBudget = &budget + } + f.mu.Unlock() + err = p.ExecuteSessionCommand(context.Background(), "one", menu.Path, menu.Revision, menu.Choices[0].ID) + wantWrites := 0 + if drift == "progress" { + wantWrites = 1 + } + if (err == nil) != (drift == "progress") || len(f.goalWrites) != wantWrites { + t.Fatal("incorrect goal revision/choice validation", drift, err, f.goalWrites) + } + }) + } +} + +func TestGoalWritesRequireVerifiedEffectAndNeverRetry(t *testing.T) { + p, f := goalFixture(t) + menu, _ := p.SessionCommands(context.Background(), "one", "goal/pause") + f.ignoreGoal = true + if err := p.ExecuteSessionCommand(context.Background(), "one", menu.Path, menu.Revision, menu.Choices[0].ID); err == nil || len(f.goalWrites) != 1 { + t.Fatal("ignored goal update was reported successful or retried") + } + f.goalReadError = map[string]any{"code": -1, "message": "unavailable"} + if err := p.ExecuteSessionCommand(context.Background(), "one", menu.Path, menu.Revision, menu.Choices[0].ID); err == nil || len(f.goalWrites) != 1 { + t.Fatal("unavailable state allowed another write") + } +} + +func TestGoalObservationNotificationsStaleAndClear(t *testing.T) { + p, f := goalFixture(t) + before := p.statusSnapshotLocked([]string{"one", "two"}) + f.mu.Lock() + f.goalReadHook = func() { + p.mu.Lock() + defer p.mu.Unlock() + raw, _ := json.Marshal(map[string]any{"threadId": "one", "goal": &SessionGoal{ThreadID: "one", Objective: "Newer streamed objective", Status: "blocked"}}) + p.goalNotificationLocked("thread/goal/updated", raw) + } + f.mu.Unlock() + g, err := p.readSessionGoal(context.Background(), "one") + if err != nil || g.Label() != "GOAL STALLED" || g.Objective != "Newer streamed objective" || before.Goals["one"].Status != "active" { + t.Fatal("older read displaced stream state or snapshots aliased", g, err) + } + f.mu.Lock() + f.goalReadHook = nil + f.goalReadError = map[string]any{"code": -1, "message": "temporary read failure"} + f.mu.Unlock() + p.mu.Lock() + obs := p.goals["one"] + obs.at = time.Now().Add(-time.Minute) + p.goals["one"] = obs + p.mu.Unlock() + p.refreshSessionGoals(context.Background(), []string{"one"}) + if goal := p.statusSnapshotLocked([]string{"one"}).Goals["one"]; goal == nil || !goal.Stale || goal.Label() != "GOAL STALE" { + t.Fatal("failed goal read did not retain a stale observation") + } + p.mu.Lock() + p.goalNotificationLocked("thread/goal/cleared", json.RawMessage(`{"threadId":"one"}`)) + p.mu.Unlock() + if snapshot := p.statusSnapshotLocked([]string{"one", "two"}); snapshot.Goals["one"] != nil || snapshot.Goals["two"] == nil { + t.Fatal("clear affected the wrong session") + } +} + +func TestGoalReadCannotResurrectClearedOrClosedSession(t *testing.T) { + for _, closed := range []bool{false, true} { + p, f := goalFixture(t) + f.mu.Lock() + f.goalReadHook = func() { + p.mu.Lock() + defer p.mu.Unlock() + if closed { + p.promptLifecycleLocked("thread/closed", json.RawMessage(`{"threadId":"one"}`)) + } else { + p.goalNotificationLocked("thread/goal/cleared", json.RawMessage(`{"threadId":"one"}`)) + } + } + f.mu.Unlock() + g, err := p.readSessionGoal(context.Background(), "one") + if g != nil || closed && err == nil || p.statusSnapshotLocked([]string{"one"}).Goals["one"] != nil { + t.Fatal("late goal read resurrected a cleared/closed goal", closed, g, err) + } + } +} + +func TestGoalConcurrentFailedObservationCannotVerifyChange(t *testing.T) { + for _, existing := range []bool{false, true} { + p, f := goalFixture(t) + f.mu.Lock() + f.goalReadHook = func() { + p.mu.Lock() + defer p.mu.Unlock() + var retained *SessionGoal + if existing { + retained = p.goals["one"].goal.Clone() + retained.Stale = true + } + p.observeGoalLocked("one", retained, time.Now()) + observation := p.goals["one"] + observation.failed = true + p.goals["one"] = observation + } + f.mu.Unlock() + if _, err := p.readSessionGoal(context.Background(), "one"); err == nil { + t.Fatal("an overlapping failed refresh was treated as verified goal state", existing) + } + } +} + +func TestGoalUnsupportedServerAndInvalidInputs(t *testing.T) { + p, f := newQuotaDaemon(t) + p.Fetch(context.Background(), []string{"one", "two"}) + if f.goalReads != 1 || !p.goalsUnsupported || len(p.statusSnapshotLocked([]string{"one"}).Goals) != 0 { + t.Fatal("unsupported goal API was not gracefully suppressed", f.goalReads) + } + p, f = goalFixture(t) + for _, path := range []string{"goal/budget/0", "goal/budget/-1", "goal/budget/1.5", "goal/budget/9007199254740992", "goal/edit/%zz", "goal/set/%1b%5b31munsafe"} { + if _, err := p.SessionCommands(context.Background(), "one", path); err == nil || len(f.goalWrites) != 0 { + t.Fatal("invalid goal input accepted", path) + } + } +} + +func TestGoalMaximumObjectiveHasCompleteActionableReview(t *testing.T) { + p, _ := goalFixture(t) + objective := strings.Repeat("界", SessionGoalInputLimit) + menu, err := p.SessionCommands(context.Background(), "one", "goal/set/"+url.PathEscape(objective)) + if err != nil || len(menu.Choices) != 1 || !menu.Choices[0].Action || !strings.Contains(menu.Help, objective) || !strings.Contains(menu.Choices[0].Help, objective) { + t.Fatal("maximum objective was clipped or lost its guarded action", err) + } +} diff --git a/internal/codex/session_prompt_unix.go b/internal/codex/session_prompt_unix.go index 0b7d35ad..f7c92639 100644 --- a/internal/codex/session_prompt_unix.go +++ b/internal/codex/session_prompt_unix.go @@ -53,6 +53,9 @@ func (p *daemonStatusProvider) promptLifecycleLocked(method string, raw json.Raw case "thread/closed": delete(p.statuses, event.ThreadID) delete(p.subscribed, event.ThreadID) + delete(p.goals, event.ThreadID) + delete(p.goalVersions, event.ThreadID) + p.goalGeneration++ return default: return diff --git a/internal/codex/session_settings_unix_test.go b/internal/codex/session_settings_unix_test.go index ac555184..797babea 100644 --- a/internal/codex/session_settings_unix_test.go +++ b/internal/codex/session_settings_unix_test.go @@ -38,6 +38,13 @@ type quotaDaemonFixture struct { hookReads []map[string]any threadHooks map[string]any hookError map[string]any + goals map[string]*SessionGoal + goalReads int + goalWrites []map[string]any + goalMethods []string + ignoreGoal bool + goalReadError map[string]any + goalReadHook func() } func TestQuotaEffortDefaultFallback(t *testing.T) { @@ -142,6 +149,54 @@ func newQuotaDaemonTransport(t *testing.T, compressed bool) (*daemonStatusProvid status = "idle" } result["thread"] = map[string]any{"id": id, "cwd": "/work", "status": map[string]any{"type": status}, "name": fixture.names[id], "environments": fixture.environments} + case "thread/goal/get": + fixture.goalReads++ + if fixture.goals == nil { + failure = true + failureDetail = map[string]any{"code": -32601, "message": "method unavailable"} + } else if fixture.goalReadError != nil { + failure, failureDetail = true, fixture.goalReadError + } else { + result["goal"] = fixture.goals[id].Clone() + } + if fixture.goalReadHook != nil { + fixture.goalReadHook() + } + case "thread/goal/set", "thread/goal/clear": + fixture.goalWrites = append(fixture.goalWrites, req.Params) + fixture.goalMethods = append(fixture.goalMethods, req.Method) + if fixture.goals == nil { + failure = true + break + } + goal := fixture.goals[id].Clone() + if req.Method == "thread/goal/clear" { + result["cleared"] = goal != nil + if !fixture.ignoreGoal { + delete(fixture.goals, id) + } + break + } + if goal == nil { + goal = &SessionGoal{ThreadID: id, Status: "active", CreatedAt: 100} + } + if !fixture.ignoreGoal { + if text, ok := req.Params["objective"].(string); ok { + goal.Objective = text + } + if status, ok := req.Params["status"].(string); ok { + goal.Status = status + } + if budget, exists := req.Params["tokenBudget"]; exists { + goal.TokenBudget = nil + if budget != nil { + n := int64(budget.(float64)) + goal.TokenBudget = &n + } + } + fixture.goals[id] = goal + } + result["goal"] = fixture.goals[id].Clone() case "thread/name/set": fixture.nameWrites = append(fixture.nameWrites, req.Params) failure = fixture.fail == "rename" diff --git a/internal/i18n/locales/da.json b/internal/i18n/locales/da.json index 7d2b04fb..a52cc4a1 100644 --- a/internal/i18n/locales/da.json +++ b/internal/i18n/locales/da.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "ARBEJDER MOD MÅL", + "GOAL STALLED": "MÅLET ER GÅET I STÅ", + "GOAL PAUSED": "MÅL SAT PÅ PAUSE", + "GOAL USAGE LIMITED": "MÅLETS FORBRUGSGRÆNSE", + "GOAL BUDGET LIMITED": "MÅLETS BUDGETGRÆNSE", + "GOAL COMPLETE": "MÅL FULDFØRT", + "GOAL STALE": "FORÆLDEDE MÅLDATA", + "GOAL STATUS UNKNOWN": "UKENDT MÅLSTATUS", + "Goal updated.": "Målet er opdateret.", "MODEL UNAVAILABLE": "MODEL UTILGÆNGELIG", "CAPACITY RESTRICTED": "BEGRÆNSET KAPACITET", "ERRORS": "FEJL", diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 42e8b868..ea9de2c3 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "ZIEL WIRD VERFOLGT", + "GOAL STALLED": "ZIEL BLOCKIERT", + "GOAL PAUSED": "ZIEL PAUSIERT", + "GOAL USAGE LIMITED": "ZIEL: NUTZUNGSLIMIT", + "GOAL BUDGET LIMITED": "ZIEL: BUDGETLIMIT", + "GOAL COMPLETE": "ZIEL ERREICHT", + "GOAL STALE": "ZIELDATEN VERALTET", + "GOAL STATUS UNKNOWN": "ZIELSTATUS UNBEKANNT", + "Goal updated.": "Ziel aktualisiert.", "MODEL UNAVAILABLE": "MODELL NICHT VERFÜGBAR", "CAPACITY RESTRICTED": "KAPAZITÄT BESCHRÄNKT", "ERRORS": "FEHLER", diff --git a/internal/i18n/locales/en-GB.json b/internal/i18n/locales/en-GB.json index 4a909e2a..cde81cfb 100644 --- a/internal/i18n/locales/en-GB.json +++ b/internal/i18n/locales/en-GB.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "PURSUING GOAL", + "GOAL STALLED": "GOAL STALLED", + "GOAL PAUSED": "GOAL PAUSED", + "GOAL USAGE LIMITED": "GOAL USAGE LIMITED", + "GOAL BUDGET LIMITED": "GOAL BUDGET LIMITED", + "GOAL COMPLETE": "GOAL COMPLETE", + "GOAL STALE": "GOAL STALE", + "GOAL STATUS UNKNOWN": "GOAL STATUS UNKNOWN", + "Goal updated.": "Goal updated.", "MODEL UNAVAILABLE": "MODEL UNAVAILABLE", "CAPACITY RESTRICTED": "CAPACITY RESTRICTED", "ERRORS": "ERRORS", diff --git a/internal/i18n/locales/es.json b/internal/i18n/locales/es.json index a5742345..fc831c32 100644 --- a/internal/i18n/locales/es.json +++ b/internal/i18n/locales/es.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "PERSIGUIENDO OBJETIVO", + "GOAL STALLED": "OBJETIVO ATASCADO", + "GOAL PAUSED": "OBJETIVO EN PAUSA", + "GOAL USAGE LIMITED": "OBJETIVO: LÍMITE DE USO", + "GOAL BUDGET LIMITED": "OBJETIVO: LÍMITE DE PRESUPUESTO", + "GOAL COMPLETE": "OBJETIVO COMPLETADO", + "GOAL STALE": "DATOS DEL OBJETIVO DESACTUALIZADOS", + "GOAL STATUS UNKNOWN": "ESTADO DEL OBJETIVO DESCONOCIDO", + "Goal updated.": "Objetivo actualizado.", "MODEL UNAVAILABLE": "MODELO NO DISPONIBLE", "CAPACITY RESTRICTED": "CAPACIDAD RESTRINGIDA", "ERRORS": "ERRORES", diff --git a/internal/i18n/locales/et.json b/internal/i18n/locales/et.json index 02451d1d..fa927e12 100644 --- a/internal/i18n/locales/et.json +++ b/internal/i18n/locales/et.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "EESMÄRGI TÄITMINE", + "GOAL STALLED": "EESMÄRK ON TAKERDUNUD", + "GOAL PAUSED": "EESMÄRK PEATATUD", + "GOAL USAGE LIMITED": "EESMÄRGI KASUTUSPIIR", + "GOAL BUDGET LIMITED": "EESMÄRGI EELARVEPIIR", + "GOAL COMPLETE": "EESMÄRK TÄIDETUD", + "GOAL STALE": "EESMÄRGI ANDMED AEGUNUD", + "GOAL STATUS UNKNOWN": "EESMÄRGI OLEK TEADMATA", + "Goal updated.": "Eesmärk uuendatud.", "MODEL UNAVAILABLE": "MUDEL POLE SAADAVAL", "CAPACITY RESTRICTED": "VÕIMSUS PIIRATUD", "ERRORS": "VEAD", diff --git a/internal/i18n/locales/fi.json b/internal/i18n/locales/fi.json index 0f518da9..4799b7b8 100644 --- a/internal/i18n/locales/fi.json +++ b/internal/i18n/locales/fi.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "TAVOITETTA EDISTETÄÄN", + "GOAL STALLED": "TAVOITE JUMISSA", + "GOAL PAUSED": "TAVOITE TAUOLLA", + "GOAL USAGE LIMITED": "TAVOITTEEN KÄYTTÖRAJA", + "GOAL BUDGET LIMITED": "TAVOITTEEN BUDJETTIRAJA", + "GOAL COMPLETE": "TAVOITE SAAVUTETTU", + "GOAL STALE": "TAVOITTEEN TIEDOT VANHENTUNEET", + "GOAL STATUS UNKNOWN": "TAVOITTEEN TILA TUNTEMATON", + "Goal updated.": "Tavoite päivitetty.", "MODEL UNAVAILABLE": "MALLI EI SAATAVILLA", "CAPACITY RESTRICTED": "KAPASITEETTI RAJOITETTU", "ERRORS": "VIRHEET", diff --git a/internal/i18n/locales/fr.json b/internal/i18n/locales/fr.json index 51b2e19b..f234edf7 100644 --- a/internal/i18n/locales/fr.json +++ b/internal/i18n/locales/fr.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "OBJECTIF EN COURS", + "GOAL STALLED": "OBJECTIF BLOQUÉ", + "GOAL PAUSED": "OBJECTIF EN PAUSE", + "GOAL USAGE LIMITED": "OBJECTIF : LIMITE D’UTILISATION", + "GOAL BUDGET LIMITED": "OBJECTIF : LIMITE DE BUDGET", + "GOAL COMPLETE": "OBJECTIF ATTEINT", + "GOAL STALE": "DONNÉES D’OBJECTIF PÉRIMÉES", + "GOAL STATUS UNKNOWN": "ÉTAT D’OBJECTIF INCONNU", + "Goal updated.": "Objectif mis à jour.", "MODEL UNAVAILABLE": "MODÈLE INDISPONIBLE", "CAPACITY RESTRICTED": "CAPACITÉ RESTREINTE", "ERRORS": "ERREURS", diff --git a/internal/i18n/locales/it.json b/internal/i18n/locales/it.json index 0199e9e7..db7e7436 100644 --- a/internal/i18n/locales/it.json +++ b/internal/i18n/locales/it.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "OBIETTIVO IN CORSO", + "GOAL STALLED": "OBIETTIVO BLOCCATO", + "GOAL PAUSED": "OBIETTIVO IN PAUSA", + "GOAL USAGE LIMITED": "OBIETTIVO: LIMITE DI UTILIZZO", + "GOAL BUDGET LIMITED": "OBIETTIVO: LIMITE DI BUDGET", + "GOAL COMPLETE": "OBIETTIVO COMPLETATO", + "GOAL STALE": "DATI OBIETTIVO OBSOLETI", + "GOAL STATUS UNKNOWN": "STATO OBIETTIVO SCONOSCIUTO", + "Goal updated.": "Obiettivo aggiornato.", "MODEL UNAVAILABLE": "MODELLO NON DISPONIBILE", "CAPACITY RESTRICTED": "CAPACITÀ LIMITATA", "ERRORS": "ERRORI", diff --git a/internal/i18n/locales/ja.json b/internal/i18n/locales/ja.json index 6ed7fa64..03b1edaa 100644 --- a/internal/i18n/locales/ja.json +++ b/internal/i18n/locales/ja.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "目標を追求中", + "GOAL STALLED": "目標が停滞中", + "GOAL PAUSED": "目標を一時停止", + "GOAL USAGE LIMITED": "目標の使用上限", + "GOAL BUDGET LIMITED": "目標の予算上限", + "GOAL COMPLETE": "目標達成", + "GOAL STALE": "目標情報が古い", + "GOAL STATUS UNKNOWN": "目標の状態が不明", + "Goal updated.": "目標を更新しました。", "MODEL UNAVAILABLE": "モデル利用不可", "CAPACITY RESTRICTED": "ポリシーによる容量制限", "ERRORS": "エラー", diff --git a/internal/i18n/locales/nb.json b/internal/i18n/locales/nb.json index f7181801..e37e7e3b 100644 --- a/internal/i18n/locales/nb.json +++ b/internal/i18n/locales/nb.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "JOBBER MOT MÅL", + "GOAL STALLED": "MÅLET HAR STANSET", + "GOAL PAUSED": "MÅL PAUSET", + "GOAL USAGE LIMITED": "MÅLETS BRUKSGRENSE", + "GOAL BUDGET LIMITED": "MÅLETS BUDSJETTGRENSE", + "GOAL COMPLETE": "MÅL FULLFØRT", + "GOAL STALE": "UTDATERTE MÅLDATA", + "GOAL STATUS UNKNOWN": "UKJENT MÅLSTATUS", + "Goal updated.": "Målet er oppdatert.", "MODEL UNAVAILABLE": "MODELL UTILGJENGELIG", "CAPACITY RESTRICTED": "BEGRENSET KAPASITET", "ERRORS": "FEIL", diff --git a/internal/i18n/locales/nl.json b/internal/i18n/locales/nl.json index 84d7a090..e590dc8e 100644 --- a/internal/i18n/locales/nl.json +++ b/internal/i18n/locales/nl.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "DOEL NASTREVEN", + "GOAL STALLED": "DOEL VASTGELOPEN", + "GOAL PAUSED": "DOEL GEPAUZEERD", + "GOAL USAGE LIMITED": "DOEL: GEBRUIKSLIMIET", + "GOAL BUDGET LIMITED": "DOEL: BUDGETLIMIET", + "GOAL COMPLETE": "DOEL VOLTOOID", + "GOAL STALE": "DOELGEGEVENS VEROUDERD", + "GOAL STATUS UNKNOWN": "DOELSTATUS ONBEKEND", + "Goal updated.": "Doel bijgewerkt.", "MODEL UNAVAILABLE": "MODEL NIET BESCHIKBAAR", "CAPACITY RESTRICTED": "CAPACITEIT BEPERKT", "ERRORS": "FOUTEN", diff --git a/internal/i18n/locales/pt-BR.json b/internal/i18n/locales/pt-BR.json index 2d562530..91b1d764 100644 --- a/internal/i18n/locales/pt-BR.json +++ b/internal/i18n/locales/pt-BR.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "BUSCANDO OBJETIVO", + "GOAL STALLED": "OBJETIVO BLOQUEADO", + "GOAL PAUSED": "OBJETIVO PAUSADO", + "GOAL USAGE LIMITED": "OBJETIVO: LIMITE DE USO", + "GOAL BUDGET LIMITED": "OBJETIVO: LIMITE DE ORÇAMENTO", + "GOAL COMPLETE": "OBJETIVO CONCLUÍDO", + "GOAL STALE": "DADOS DO OBJETIVO DESATUALIZADOS", + "GOAL STATUS UNKNOWN": "ESTADO DO OBJETIVO DESCONHECIDO", + "Goal updated.": "Objetivo atualizado.", "MODEL UNAVAILABLE": "MODELO INDISPONÍVEL", "CAPACITY RESTRICTED": "CAPACIDADE RESTRITA", "ERRORS": "ERROS", diff --git a/internal/i18n/locales/pt-PT.json b/internal/i18n/locales/pt-PT.json index c6df8e62..4bd4ae4d 100644 --- a/internal/i18n/locales/pt-PT.json +++ b/internal/i18n/locales/pt-PT.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "A PROSSEGUIR OBJETIVO", + "GOAL STALLED": "OBJETIVO BLOQUEADO", + "GOAL PAUSED": "OBJETIVO EM PAUSA", + "GOAL USAGE LIMITED": "OBJETIVO: LIMITE DE UTILIZAÇÃO", + "GOAL BUDGET LIMITED": "OBJETIVO: LIMITE DE ORÇAMENTO", + "GOAL COMPLETE": "OBJETIVO CONCLUÍDO", + "GOAL STALE": "DADOS DO OBJETIVO DESATUALIZADOS", + "GOAL STATUS UNKNOWN": "ESTADO DO OBJETIVO DESCONHECIDO", + "Goal updated.": "Objetivo atualizado.", "MODEL UNAVAILABLE": "MODELO INDISPONÍVEL", "CAPACITY RESTRICTED": "CAPACIDADE RESTRITA", "ERRORS": "ERROS", diff --git a/internal/i18n/locales/ru.json b/internal/i18n/locales/ru.json index 89031ead..fbfcf7ea 100644 --- a/internal/i18n/locales/ru.json +++ b/internal/i18n/locales/ru.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "ЦЕЛЬ ВЫПОЛНЯЕТСЯ", + "GOAL STALLED": "ЦЕЛЬ ЗАБЛОКИРОВАНА", + "GOAL PAUSED": "ЦЕЛЬ НА ПАУЗЕ", + "GOAL USAGE LIMITED": "ЛИМИТ ИСПОЛЬЗОВАНИЯ ЦЕЛИ", + "GOAL BUDGET LIMITED": "ЛИМИТ БЮДЖЕТА ЦЕЛИ", + "GOAL COMPLETE": "ЦЕЛЬ ДОСТИГНУТА", + "GOAL STALE": "ДАННЫЕ ЦЕЛИ УСТАРЕЛИ", + "GOAL STATUS UNKNOWN": "СТАТУС ЦЕЛИ НЕИЗВЕСТЕН", + "Goal updated.": "Цель обновлена.", "MODEL UNAVAILABLE": "МОДЕЛЬ НЕДОСТУПНА", "CAPACITY RESTRICTED": "ДОСТУП К МОЩНОСТИ ОГРАНИЧЕН", "ERRORS": "ОШИБКИ", diff --git a/internal/i18n/locales/sv.json b/internal/i18n/locales/sv.json index fa995c4f..cc231986 100644 --- a/internal/i18n/locales/sv.json +++ b/internal/i18n/locales/sv.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "ARBETAR MOT MÅL", + "GOAL STALLED": "MÅLET HAR FASTNAT", + "GOAL PAUSED": "MÅL PAUSAT", + "GOAL USAGE LIMITED": "MÅLETS ANVÄNDNINGSGRÄNS", + "GOAL BUDGET LIMITED": "MÅLETS BUDGETGRÄNS", + "GOAL COMPLETE": "MÅL SLUTFÖRT", + "GOAL STALE": "MÅLDATA INAKTUELLA", + "GOAL STATUS UNKNOWN": "OKÄND MÅLSTATUS", + "Goal updated.": "Målet uppdaterades.", "MODEL UNAVAILABLE": "MODELL EJ TILLGÄNGLIG", "CAPACITY RESTRICTED": "BEGRÄNSAD KAPACITET", "ERRORS": "FEL", diff --git a/internal/i18n/locales/tr.json b/internal/i18n/locales/tr.json index 5c33a0a0..30c0ff05 100644 --- a/internal/i18n/locales/tr.json +++ b/internal/i18n/locales/tr.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "HEDEF İZLENİYOR", + "GOAL STALLED": "HEDEF DURAKLADI", + "GOAL PAUSED": "HEDEF DURAKLATILDI", + "GOAL USAGE LIMITED": "HEDEF KULLANIM SINIRI", + "GOAL BUDGET LIMITED": "HEDEF BÜTÇE SINIRI", + "GOAL COMPLETE": "HEDEF TAMAMLANDI", + "GOAL STALE": "HEDEF BİLGİLERİ GÜNCEL DEĞİL", + "GOAL STATUS UNKNOWN": "BİLİNMEYEN HEDEF DURUMU", + "Goal updated.": "Hedef güncellendi.", "MODEL UNAVAILABLE": "MODEL KULLANILAMIYOR", "CAPACITY RESTRICTED": "KAPASİTE KISITLI", "ERRORS": "HATALAR", diff --git a/internal/i18n/locales/zh-Hans.json b/internal/i18n/locales/zh-Hans.json index cae28a69..d99291f3 100644 --- a/internal/i18n/locales/zh-Hans.json +++ b/internal/i18n/locales/zh-Hans.json @@ -1,4 +1,13 @@ { + "PURSUING GOAL": "正在推进目标", + "GOAL STALLED": "目标已停滞", + "GOAL PAUSED": "目标已暂停", + "GOAL USAGE LIMITED": "目标使用受限", + "GOAL BUDGET LIMITED": "目标预算已用尽", + "GOAL COMPLETE": "目标已完成", + "GOAL STALE": "目标信息已过期", + "GOAL STATUS UNKNOWN": "目标状态未知", + "Goal updated.": "目标已更新。", "MODEL UNAVAILABLE": "模型不可用", "CAPACITY RESTRICTED": "容量受策略限制", "ERRORS": "错误", diff --git a/internal/ui/model.go b/internal/ui/model.go index 5ff5efd9..34b9498f 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -270,6 +270,7 @@ type monitorSessionDismissal struct { } type monitorSession struct { + goal *codex.SessionGoal name string averageRate int64 modelSettings codex.SessionModelSettings @@ -2591,6 +2592,7 @@ func (m *Model) startMonitorSessions(usage codex.LiveUsageSnapshot, observedAt t lastActivity: session.LastActivity, agentCount: session.AgentCount, active: session.Active, working: session.Working, attention: session.Attention, preview: session.Context, + goal: session.Goal.Clone(), displayed: session.Active, unattributed: session.Unattributed, callSequence: latestModelCallSequence(session.ModelCalls), turnSequence: latestTurnTimingSequence(session.TurnTimings), @@ -2626,6 +2628,10 @@ func (m *Model) syncMonitorSessions(usage codex.LiveUsageSnapshot, observedAt ti } }() for index := range m.monitorSessionData { + if goal := m.monitorSessionData[index].goal.Clone(); goal != nil { + goal.Stale = true + m.monitorSessionData[index].goal = goal + } m.monitorSessionData[index].active = false m.monitorSessionData[index].working = false m.monitorSessionData[index].attention = codex.SessionAttentionNone @@ -2644,6 +2650,7 @@ func (m *Model) syncMonitorSessions(usage codex.LiveUsageSnapshot, observedAt ti lastActivity: update.LastActivity, agentCount: update.AgentCount, active: update.Active, working: update.Working, attention: update.Attention, preview: update.Context, + goal: update.Goal.Clone(), displayed: update.Active || update.TotalTokens > 0 || len(update.ModelCalls) > 0 || len(update.TurnTimings) > 0, unattributed: update.Unattributed, } @@ -2664,6 +2671,7 @@ func (m *Model) syncMonitorSessions(usage codex.LiveUsageSnapshot, observedAt ti session.attention = update.Attention session.preview = update.Context session.modelSettings = update.ModelSettings + session.goal = update.Goal.Clone() session.name = update.Name session.displayed = session.displayed || update.Active || update.TotalTokens > session.baseline || len(update.ModelCalls) > 0 || len(update.TurnTimings) > 0 diff --git a/internal/ui/monitor.go b/internal/ui/monitor.go index 628ff297..dc0df77e 100644 --- a/internal/ui/monitor.go +++ b/internal/ui/monitor.go @@ -361,6 +361,9 @@ func (m Model) renderMonitorSessionMetrics(width, height int, session monitorSes lines = append(lines, colors.label().Bold(true).Render(ansi.Truncate(field, innerWidth, "…"))) } } + if goal := m.monitorGoalStatus(session, colors); goal != "" && len(lines) < bodyRows { + lines = append(lines, ansi.Truncate(goal, innerWidth, "…")) + } appendPriority := func(value string) { if value != "" && len(lines) < bodyRows { lines = append(lines, colors.label().Bold(true).Render(ansi.Truncate(value, innerWidth, ""))) diff --git a/internal/ui/monitor_commands.go b/internal/ui/monitor_commands.go index 01e4f279..1d8c105e 100644 --- a/internal/ui/monitor_commands.go +++ b/internal/ui/monitor_commands.go @@ -143,7 +143,7 @@ func (m *Model) navigateMonitorCommands(path string) tea.Cmd { func (m Model) monitorCommandsCanBack() bool { p := m.monitorCommands - inputReview := strings.HasPrefix(p.menu.Path, "rename/") || strings.HasPrefix(p.menu.Path, "cd/") + inputReview := commandInputReview(p.menu.Path) return (p.detail && !inputReview) || p.reviewedChoice != "" || len(p.history) > 0 } @@ -155,7 +155,7 @@ func (m *Model) backMonitorCommands() tea.Cmd { p.notice = "" return nil } - inputReview := strings.HasPrefix(p.menu.Path, "rename/") || strings.HasPrefix(p.menu.Path, "cd/") + inputReview := commandInputReview(p.menu.Path) if p.detail && !inputReview { p.detail = false p.scroll = 0 @@ -397,6 +397,8 @@ func (m Model) monitorCommandRows(width, height int) []commandDisplayRow { text += "\nOnly this session's saved name changes. Confirm after reviewing the new name." } else if strings.HasPrefix(p.menu.Path, "cd/") { text += "\nOnly this session’s directory changes; project configuration is not reloaded. Confirm after reviewing both paths." + } else if strings.HasPrefix(p.menu.Path, "goal/") { + text += "\nThis changes only the selected session's goal. Active goals may immediately start work and consume quota. Confirm only after reviewing the objective, state and budget." } else { text += "\nNo change sent yet. Model, reasoning and speed settings can change token usage and cost." text += "\nChanges apply to subsequent turns of this session. They are not global defaults. Confirm only after reviewing the option. Automatic quota thresholds may later supersede model settings." @@ -677,6 +679,8 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { m.monitorPrompt.notice = "Session renamed." } else if strings.HasPrefix(r.path, "cd/") { m.monitorPrompt.notice = "Working directory changed." + } else if strings.HasPrefix(r.path, "goal/") { + m.monitorPrompt.notice = "Goal updated." } return m, cmd, true } else { @@ -689,6 +693,11 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { m.monitorPrompt.input.CursorEnd() } p.menu = r.menu + if parent, value, ok := codex.SessionCommandInputValue(p.menu.Path); ok && p.inline { + p.prefix = m.inlineCommandPrefix(parent) + m.monitorPrompt.input.SetValue(p.prefix + value) + m.monitorPrompt.input.CursorEnd() + } if p.menu.Path == "" || p.menu.Path == "help" { p.menu = m.withLocalCommands(p.menu) } @@ -734,7 +743,7 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { cmd := p.input.Focus() return m, cmd, true } - if (strings.HasPrefix(p.menu.Path, "rename/") || strings.HasPrefix(p.menu.Path, "cd/")) && len(p.menu.Choices) == 1 { + if commandInputReview(p.menu.Path) && len(p.menu.Choices) == 1 { if o := p.menu.Choices[0]; o.Action && !m.confirmations.Required(confirmation.Command(o.Reversible)) { return m.executeMonitorCommand(o) } @@ -972,7 +981,7 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { func (m Model) reviewMonitorCommandInput() (Model, tea.Cmd, bool) { p := &m.monitorCommands - if !p.menu.Input || (p.menu.Path != "rename" && p.menu.Path != "cd") || p.busy { + if !p.menu.Input || !codex.SessionCommandInputPath(p.menu.Path) || p.busy { return m, nil, true } name := strings.TrimSpace(p.input.Value()) diff --git a/internal/ui/monitor_commands_inline.go b/internal/ui/monitor_commands_inline.go index 089b89ca..bc0c137a 100644 --- a/internal/ui/monitor_commands_inline.go +++ b/internal/ui/monitor_commands_inline.go @@ -9,6 +9,9 @@ import ( ) func (m Model) inlineCommandPrefix(path string) string { + if path == "goal/set" { + return "/goal " + } if strings.HasPrefix(path, "tier/") { if m.monitorCommands.menu.Path == path && m.monitorCommands.menu.Picker { return m.monitorCommands.menu.Title + " " @@ -51,7 +54,8 @@ func (m Model) commandChoiceIndices() []int { } func commandInputReview(path string) bool { - return strings.HasPrefix(path, "rename/") || strings.HasPrefix(path, "cd/") + _, _, ok := codex.SessionCommandInputValue(path) + return ok } func (m *Model) restoreCommandDraft() { @@ -115,6 +119,9 @@ func (m Model) updateInlineCommands(msg tea.Msg) (Model, tea.Cmd, bool) { if p.busy || p.notice != "" { return m, nil, true } + if p.menu.Path == "goal" && !p.detail && m.commandQuery() != "" { + return m.openMonitorCommands("goal " + m.commandQuery()) + } if p.menu.Input { return m.reviewMonitorCommandInput() } @@ -171,7 +178,7 @@ func (m Model) updateInlineCommands(msg tea.Msg) (Model, tea.Cmd, bool) { if commandInputReview(p.menu.Path) { // Editing a reviewed name/path must obtain a new capability; // never confirm the previous value behind an edited draft. - parent := strings.SplitN(p.menu.Path, "/", 2)[0] + parent, _, _ := codex.SessionCommandInputValue(p.menu.Path) if n := len(p.history); n > 0 && p.history[n-1].path == parent { p.history = append([]monitorCommandLevel(nil), p.history[:n-1]...) } diff --git a/internal/ui/monitor_context.go b/internal/ui/monitor_context.go index 7eae67fe..a8b246df 100644 --- a/internal/ui/monitor_context.go +++ b/internal/ui/monitor_context.go @@ -228,6 +228,7 @@ func (m Model) renderMonitorContextDetail(width, height int, colors palette) str action := m.renderMonitorNavigation(width, m.monitorContextDetail, true, colors) title := m.monitorDetailTitle(width, colors) copyLabel := m.renderMonitorCopy(width, m.monitorContextDetail, colors) + copyLabel = m.monitorGoalFooter(width, copyLabel, colors) panel := frameSizedWithActions(width, rows, title, action, copyLabel, body, colors.primary, colors) if m.dashboardLayout().footerSpacer { return m.withMonitorStatusLine(panel, width, copyLabel, colors) diff --git a/internal/ui/monitor_goal.go b/internal/ui/monitor_goal.go new file mode 100644 index 00000000..8f57e2a3 --- /dev/null +++ b/internal/ui/monitor_goal.go @@ -0,0 +1,53 @@ +package ui + +import ( + "strings" + + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/i18n" +) + +func (m Model) monitorGoalStatus(s monitorSession, colors palette) string { + goal := s.goal.Clone() + if goal == nil { + return "" + } + if m.monitorError != "" || m.monitorState != monitorRunning { + goal.Stale = true + } + style := colors.label().Bold(true).Foreground(colors.primary) + if goal.Stale { + style = colors.dimmed() + } else { + switch goal.Status { + case "active": + style = style.Foreground(colors.success) + case "blocked", "usageLimited", "budgetLimited": + style = style.Foreground(colors.warning) + } + } + return style.Render(i18n.Text(goal.Label())) +} + +// Keep existing buttons anchored at the far right. Goal status is display-only +// and occupies only spare border space before those controls. +func (m Model) monitorGoalFooter(width int, controls string, colors palette) string { + s, ok := m.contextDetailSession() + if !ok || m.hasSessionProfile(s) { + return controls + } + goal := m.monitorGoalStatus(s, colors) + if goal == "" { + return controls + } + parts := []string{goal} + if controls != "" { + parts = append(parts, controls) + } + footer := strings.Join(parts, " ") + spare := width - ansi.StringWidth(footer) - 6 + if spare < 0 || spare < 12 && m.monitorStatusLineText(width, controls) != "" { + return controls + } + return footer +} diff --git a/internal/ui/monitor_goal_test.go b/internal/ui/monitor_goal_test.go new file mode 100644 index 00000000..d3b48fdd --- /dev/null +++ b/internal/ui/monitor_goal_test.go @@ -0,0 +1,148 @@ +package ui + +import ( + "context" + "net/url" + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" +) + +type goalUIClient struct{ *commandTestClient } + +func (f *goalUIClient) SessionCommands(_ context.Context, _ string, path string) (codex.SessionCommandMenu, error) { + if strings.HasPrefix(path, "goal ") { + path = "goal/set/" + url.PathEscape(strings.TrimPrefix(path, "goal ")) + } + menu := codex.SessionCommandMenu{Title: "/goal", Path: path, Revision: "goal-r"} + if codex.SessionCommandInputPath(path) { + menu.Input, menu.InputLimit, menu.Value = true, 4096, "Current objective" + } else if commandInputReview(path) { + menu.Choices = []codex.SessionCommandChoice{{ID: "goal-change", Label: "Apply goal", Action: true}} + } + return menu, nil +} + +func TestMonitorGoalInputReviewRetainsNestedParent(t *testing.T) { + for _, path := range []string{"goal/set", "goal/edit", "goal/budget", "goal A new objective"} { + m, base := suggestionTestModel(t) + f := &goalUIClient{base.commandTestClient} + m.fetcher = f + m.monitorPrompt.input.SetValue("/goal") + m, cmd, _ := m.openMonitorCommands(path) + next, _ := m.Update(cmd()) + m = next.(Model) + parent := path + if !commandInputReview(m.monitorCommands.menu.Path) { + if !m.monitorCommands.menu.Input || !m.monitorPrompt.input.Focused() { + t.Fatal("goal editor left the composer") + } + next, cmd = m.Update(tea.KeyPressMsg{Code: tea.KeyEnter}) + m = next.(Model) + next, _ = m.Update(cmd()) + m = next.(Model) + } else { + parent = "goal/set" + } + if !m.monitorCommands.detail || f.calls != 0 || !strings.HasPrefix(m.monitorPrompt.input.Value(), m.inlineCommandPrefix(parent)) { + t.Fatal("goal mutation bypassed review or leaked an encoded path") + } + next, cmd = m.Update(key('x')) + m = next.(Model) + if cmd == nil || m.monitorCommands.detail || m.monitorCommands.menu.Path != parent { + t.Fatal("editing a goal review did not return to its exact editor parent", path, m.monitorCommands.menu.Path) + } + } +} + +func TestMonitorGoalFollowsConfiguredFields(t *testing.T) { + m := completedCopyModel() + m.monitorStatusLine = []string{"model-with-reasoning", "used-tokens"} + s := m.monitorSessionData[0] + s.modelSettings = codex.SessionModelSettings{Model: "test-model", ReasoningEffort: "high"} + s.latest = 1200 + s.goal = &codex.SessionGoal{Status: "active", Objective: "A separate objective"} + out := ansi.Strip(m.renderMonitorSessionMetrics(48, 12, s, "", paletteFor(m.theme))) + before := -1 + for _, text := range []string{"TURN COMPLETE", "test-model high", "1.2K tokens", "PURSUING GOAL"} { + at := strings.Index(out, text) + if at <= before || strings.Count(out, text) != 1 { + t.Fatalf("goal/state order or duplication for %q:\n%s", text, out) + } + before = at + } + if strings.Contains(out, s.goal.Objective) { + t.Fatal("objective cluttered row telemetry") + } + for _, height := range []int{3, 4, 5, 8} { + out := m.renderMonitorSessionMetrics(30, height, s, "", paletteFor(m.theme)) + if lipgloss.Height(out) != height || lipgloss.Width(out) > 30 { + t.Fatal("goal caused compact telemetry overflow") + } + } +} + +func TestMonitorGoalFooterKeepsCopyTarget(t *testing.T) { + for _, width := range []int{24, 60, 120, 180} { + m := completedCopyModel() + m.width = width + m.setRowContext("root-one", contextFull) + m.monitorSessionData[0].modelSettings = codex.SessionModelSettings{Model: "test-model", ReasoningEffort: "high"} + before := m.render() + m.monitorSessionData[0].goal = &codex.SessionGoal{Status: "blocked", Objective: "Find a fix"} + out := ansi.Strip(m.render()) + if width >= 120 { + goalAt, copyAt := strings.Index(out, "GOAL STALLED"), strings.Index(out, benchmarkDetailCopyLabel) + if goalAt < 0 || copyAt < goalAt || strings.Contains(out[goalAt:copyAt], "\n") { + t.Fatal("goal not on bottom border immediately before Copy", out) + } + } + if strings.Contains(ansi.Strip(before), benchmarkDetailCopyLabel) { + x, y := renderedTextStart(t, m, benchmarkDetailCopyLabel) + if m.monitorContextAt(x, y) != "copy:root-one" { + t.Fatal("goal displaced Copy hit target") + } + } + if lipgloss.Width(out) > width || lipgloss.Height(out) > m.height { + t.Fatal("goal footer overflowed terminal") + } + } +} + +func TestMonitorGoalStatusStaleAndSync(t *testing.T) { + m := completedCopyModel() + usage := codex.LiveUsageSnapshot{Sessions: []codex.LiveUsageSession{{ID: "root-one", Active: true, Goal: &codex.SessionGoal{Status: "active", Objective: "Goal"}}}} + now := time.Now() + m.startMonitorSessions(usage, now) + if m.monitorSessionData[0].goal == nil { + t.Fatal("startup dropped goal") + } + usage.Sessions[0].Goal.Status = "paused" + if m.monitorSessionData[0].goal.Status != "active" { + t.Fatal("goal aliased source snapshot") + } + usage.Sessions = append(usage.Sessions, codex.LiveUsageSession{ID: "new", Active: true, Goal: &codex.SessionGoal{Status: "blocked", Objective: "Other"}}) + m.syncMonitorSessions(usage, now) + if m.monitorSessionData[0].goal.Status != "paused" || m.monitorSessionData[1].goal.Status != "blocked" { + t.Fatal("refresh/new session dropped goal") + } + m.syncMonitorSessions(codex.LiveUsageSnapshot{}, now) + if !m.monitorSessionData[0].goal.Stale { + t.Fatal("missing observation claimed current goal") + } + m.monitorError = "disconnected" + if got := ansi.Strip(m.monitorGoalStatus(m.monitorSessionData[1], paletteFor(m.theme))); got != "GOAL STALE" { + t.Fatal("disconnected goal not stale:", got) + } + m.monitorError = "" + usage.Sessions[0].Goal = nil + m.syncMonitorSessions(usage, now) + if m.monitorSessionData[0].goal != nil { + t.Fatal("clear retained old goal") + } +} diff --git a/internal/ui/monitor_statusline.go b/internal/ui/monitor_statusline.go index 4af668e1..f58f8391 100644 --- a/internal/ui/monitor_statusline.go +++ b/internal/ui/monitor_statusline.go @@ -117,7 +117,9 @@ func (m Model) monitorStatusLineVisible(width int) bool { if m.meterView != viewMonitor || m.monitorContextDetail == "" || m.contextTargetHidden() || m.monitorQueue.open { return false } - return m.monitorStatusLineText(width, m.renderMonitorCopy(width, m.monitorContextDetail, paletteFor(m.theme))) != "" + colors := paletteFor(m.theme) + controls := m.monitorGoalFooter(width, m.renderMonitorCopy(width, m.monitorContextDetail, colors), colors) + return m.monitorStatusLineText(width, controls) != "" } // Write into the existing bottom border; dashboard geometry reserves a blank diff --git a/internal/web/control_commands.go b/internal/web/control_commands.go index baccacd9..bac370bb 100644 --- a/internal/web/control_commands.go +++ b/internal/web/control_commands.go @@ -60,6 +60,8 @@ func (c *control) handleCommands(w http.ResponseWriter, r *http.Request, body ac message = "Session renamed." } else if strings.HasPrefix(q.Path, "cd/") { message = "Working directory changed." + } else if strings.HasPrefix(q.Path, "goal/") { + message = "Goal updated." } _ = json.NewEncoder(w).Encode(map[string]string{"message": message}) return diff --git a/internal/web/dist/assets/index-CoCF2Nd3.js b/internal/web/dist/assets/index-CoCF2Nd3.js deleted file mode 100644 index 07b272d5..00000000 --- a/internal/web/dist/assets/index-CoCF2Nd3.js +++ /dev/null @@ -1,47 +0,0 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,E=1<<19,D=1<<20,ee=1<<25,te=1<<21,O=1<<22,ne=1<<23,k=Symbol(`$state`),re=Symbol(`component`),ie=Symbol(`legacy props`),ae=Symbol(``),oe=Symbol(`attributes`),se=Symbol(`class`),A=Symbol(`style`),ce=Symbol(`text`),le=Symbol(`form reset`),ue=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},de=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),fe={},j=Symbol(`uninitialized`),pe=`http://www.w3.org/1999/xhtml`;function me(){console.warn(`https://svelte.dev/e/derived_inert`)}function he(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ge(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function _e(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var M=!1;function ve(e){M=e}var N;function ye(e){if(e===null)throw he(),fe;return N=e}function be(){return ye(on(N))}function P(e){if(M){if(on(N)!==null)throw he(),fe;N=e}}function xe(e=1){if(M){for(var t=e,n=N;t--;)n=on(n);N=n}}function Se(e=!0){for(var t=0,n=N;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=on(n);e&&n.remove(),n=i}}function Ce(e){if(!e||e.nodeType!==8)throw he(),fe;return e.data}function we(e){return e===this.v}function Te(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Ee(e){return!Te(e,this.v)}function De(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Oe(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ke(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ae(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function je(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Me(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ne(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Pe(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Fe(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ie(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Le(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Re(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ze=!1;function Be(){ze=!0}var Ve=null;function He(e){Ve=e}function Ue(e,t=!1,n){Ve={p:Ve,i:!1,c:null,e:null,s:e,x:null,r:G,l:ze&&!t?{s:null,u:null,$:[]}:null}}function We(e){var t=Ve,n=t.e;if(n!==null){t.e=null;for(var r of n)yn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ve=t.p,Ge(e)}function Ge(e={}){return i(e,re,{value:!0}),e}function Ke(){return!ze||Ve!==null&&Ve.l===null}var qe=[];function Je(){var e=qe;qe=[],m(e)}function Ye(e){if(qe.length===0&&!Ct){var t=qe;queueMicrotask(()=>{t===qe&&Je()})}qe.push(e)}function Xe(){for(;qe.length>0;)Je()}var Ze=~(y|b|v);function Qe(e,t){e.f=e.f&Ze|t}function $e(e){e.f&512||e.deps===null?Qe(e,v):Qe(e,b)}function et(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),Qe(e,v)}function tt(e){M&&an(e)!==null&&sn(e)}var nt=!1;function rt(){nt||(nt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[le]?.()})},{capture:!0}))}function it(e){var t=W,n=G;Un(null),Wn(null);try{return e()}finally{Un(t),Wn(n)}}function at(e,t,n,r=n){e.addEventListener(t,()=>it(n));let i=e[le];e[le]=i?()=>{i(),r(!0)}:()=>r(!0),rt()}function ot(e,t,n,r){let i=Ke()?ut:pt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=G,c=st(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){fn(e,s)}ct()}}var d=lt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>ft(e))).then(u).catch(e=>fn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ct()}):f()}function st(){var e=G,t=W,n=Ve,r=I;return function(i=!0){Wn(e),Un(t),He(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ct(e=!0){Wn(null),Un(null),He(null),e&&I?.deactivate()}function lt(){var e=G,t=e.b,n=I,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function ut(e){var t=2|y;return G!==null&&(G.f|=E),{ctx:Ve,deps:null,effects:null,equals:we,f:t,fn:e,reactions:null,rv:0,v:j,wv:0,parent:G,ac:null}}var dt=Symbol(`obsolete`);function ft(e,t,n){let r=G;r===null&&Oe();var i=void 0,a=Bt(j),o=!W,s=new Set;return Cn(()=>{var t=G,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ue&&n.reject(e)}).finally(ct)}catch(e){n.reject(e),ct()}var c=I;if(o){if(t.f&32768)var l=lt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(dt);else for(let e of s.values())e.reject(dt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==dt&&(c.activate(),t?(a.f|=ne,Wt(a,t)):(a.f&8388608&&(a.f^=ne),Wt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),_n(()=>{for(let e of s)e.reject(dt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function F(e){let t=ut(e);return Kn(t),t}function pt(e){let t=ut(e);return t.equals=Ee,t}function mt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ue),t.ac=null}),t.fn!==null&&(t.teardown=f),sr(t,0),On(t))}function vt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&cr(t)}var yt=null,I=null,bt=null,xt=null,St=null,Ct=!1,wt=!1,Tt=null,Et=null,Dt=0,Ot=1,kt=class e{id=Ot++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){yt===null?yt=this:(yt.#n=this,this.#t=yt),yt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)Qe(r,y),t(r);for(r of n.m)Qe(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),Qe(e,y),this.schedule(e);for(let e of this.#d)Qe(e,b),this.schedule(e);this.apply();for(var t=Tt=[],n=[],r=Et=[];this.#c.length>0;){Dt++>1e3&&(this.#S(),jt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw It(e),this.#h()||this.discard(),t}}if(I=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Tt=null,Et=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Ft(e,t);r.length>0&&I.#_();return}let a=this.#y();if(a)this.#x(n),this.#x(t),a.#b(this);else{this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),bt=this,Nt(n),Nt(t),bt=null,this.#s?.resolve();var o=I;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(Rt.clear(),o.#_())}}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):nr(r)&&(i&16&&this.#d.add(r),cr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),Qe(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),I=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(I===null){let t=I=new e;!wt&&!Ct&&Ye(()=>{t.#e||t.flush()})}return I}apply(){xt=null}schedule(e){St=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)?e.b.defer_effect(e):this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?yt=e:t.#t=e,this.linked=!1}}};function At(e){var t=Ct;Ct=!0;try{var n;for(e&&(I!==null&&!I.is_fork&&I.flush(),n=e());;){if(Xe(),I===null)return n;I.flush()}}finally{Ct=t}}function jt(){try{Ne()}catch(e){fn(e,St)}}var Mt=null;function Nt(e){var t=e.length;if(t!==0){for(var n=0;n0)){Rt.clear();for(let e of Mt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Mt.has(n)&&(Mt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||cr(n)}}Mt.clear()}}Mt=null}}function Pt(e){I.schedule(e)}function Ft(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),Qe(e,v);for(var n=e.first;n!==null;)Ft(n,t),n=n.next}}function It(e){Qe(e,v);for(var t=e.first;t!==null;)It(t),t=t.next}var Lt=new Set,Rt=new Map,zt=!1;function Bt(e,t){return{f:0,v:e,reactions:null,equals:we,rv:0,wv:0}}function L(e,t){let n=Bt(e,t);return Kn(n),n}function Vt(e,t=!1,n=!0){let r=Bt(e);return t||(r.equals=Ee),ze&&n&&Ve!==null&&Ve.l!==null&&(Ve.l.s??=[]).push(r),r}function R(e,t,n=!1){return W!==null&&(!Hn||W.f&131072)&&Ke()&&W.f&4325394&&(Gn===null||!Gn.has(e))&&Le(),Wt(e,n?Yt(t):t,Et)}var Ht=null,Ut=0;function Wt(e,t,n=null){if(!e.equals(t)){Bn?Rt.set(e,t):Rt.has(e)||Rt.set(e,e.v);var r=kt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&ht(t),xt===null&&$e(t)}e.wv=tr(),Ht=null,Ut=0,Jt(e,y,n),Ht=null,Ke()&&G!==null&&G.f&1024&&!(G.f&96)&&(Yn===null?Xn([e]):Yn.push(e)),!r.is_fork&&Lt.size>0&&!zt&&Gt()}return t}function Gt(){zt=!1;for(let e of Lt){e.f&1024&&Qe(e,b);let t;try{t=nr(e)}catch{t=!0}t&&cr(e)}Lt.clear()}function Kt(e,t=1){var n=K(e),r=t===1?n++:n--;return R(e,n),r}function qt(e){R(e,e.v+1)}function Jt(e,t,n){var r=e.reactions;if(r!==null){var i=Ke(),a=r.length;if(Ut+=a,Ut>1e5&&Ht===null&&(Ht=new Set),Ht!==null){if(Ht.has(e))return;Ht.add(e)}for(var o=0;o{if($n===d)return e();var t=W,n=$n;Un(null),er(d);var r=e();return Un(t),er(n),r};return i&&r.set(`length`,L(t.length,u)),new Proxy(t,{defineProperty(e,t,n){`value`in n&&n.configurable!==!1&&n.enumerable!==!1&&n.writable!==!1||Fe();var i=r.get(t);return i===void 0?f(()=>{var e=L(n.value,u);return r.set(t,e),e}):R(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>L(j,u));r.set(t,e),qt(o)}}else R(n,j),qt(o);return!0},get(e,n,i){if(n===k)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>L(Yt(s?e[n]:j),u)),r.set(n,o)),o!==void 0){var c=K(o);return c===j?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=K(i);if(a===j)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===k)return!0;var n=r.get(t),i=n!==void 0&&n.v!==j||Reflect.has(e,t);return(n!==void 0||G!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>L(i?Yt(e[t]):j,u)),r.set(t,n)),K(n)===j)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dL(j,u)),r.set(d+``,p)):R(p,j)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>L(void 0,u)),R(c,Yt(n)),r.set(t,c));else{l=c.v!==j;var m=f(()=>Yt(n));R(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&R(g,_+1)}qt(o)}return!0},ownKeys(e){K(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==j});for(var[n,i]of r)i.v!==j&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ie()}})}function Xt(e){try{if(typeof e==`object`&&e&&k in e)return e[k]}catch{}return e}function Zt(e,t){return Object.is(Xt(e),Xt(t))}var Qt,$t,en,tn;function nn(){if(Qt===void 0){Qt=window,$t=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;en=a(t,`firstChild`).get,tn=a(t,`nextSibling`).get,u(e)&&(e[se]=void 0,e[oe]=null,e[A]=void 0,e.__e=void 0),u(n)&&(n[ce]=void 0)}}function rn(e=``){return document.createTextNode(e)}function an(e){return en.call(e)}function on(e){return tn.call(e)}function z(e,t){if(!M)return an(e);var n=an(N);if(n===null)n=N.appendChild(rn());else if(t&&n.nodeType!==3){var r=rn();return n?.before(r),ye(r),r}return t&&un(n),ye(n),n}function B(e,t=!1){if(!M){var n=an(e);return n instanceof Comment&&n.data===``?on(n):n}if(t){if(N?.nodeType!==3){var r=rn();return N?.before(r),ye(r),r}un(N)}return N}function V(e,t=!1){if(!M)return an(e);var n=z(e,t);return P(e),n}function H(e,t=1,n=!1){let r=M?N:e;for(var i;t--;)i=r,r=on(r);if(!M)return r;if(n){if(r?.nodeType!==3){var a=rn();return r===null?i?.after(a):r.before(a),ye(a),a}un(r)}return ye(r),r}function sn(e){e.textContent=``}function cn(){return!1}function ln(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function un(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function dn(e){var t=G;if(t===null)return W.f|=ne,e;if(!(t.f&32768)&&!(t.f&4))throw e;fn(e,t)}function fn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function pn(e){G===null&&(W===null&&Me(e),je()),Bn&&Ae(e)}function mn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function hn(e,t){var n=G;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ve,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};I?.register_created_effect(r);var i=r;if(e&4)Tt===null?kt.ensure().schedule(r):Tt.push(r);else if(t!==null){try{cr(r)}catch(e){throw An(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&mn(i,n),W!==null&&W.f&2&&!(e&64))){var a=W;(a.effects??=[]).push(i)}return r}function gn(){return W!==null&&!Hn}function _n(e){let t=hn(8,null);return Qe(t,v),t.teardown=e,t}function vn(e){pn(`$effect`);var t=G.f;if(!W&&t&32&&Ve!==null&&!Ve.i){var n=Ve;(n.e??=[]).push(e)}else return yn(e)}function yn(e){return hn(4|D,e)}function bn(e){return pn(`$effect.pre`),hn(8|D,e)}function xn(e){kt.ensure();let t=hn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Nn(t,()=>{An(t),n(void 0)}):(An(t),n(void 0))})}function Sn(e){return hn(4,e)}function Cn(e){return hn(O|E,e)}function wn(e,t=0){return hn(8|t,e)}function U(e,t=[],n=[],r=[]){ot(r,t,n,t=>{hn(8,()=>{e(...t.map(K))})})}function Tn(e,t=0){return hn(16|t,e)}function En(e){return hn(32|E,e)}function Dn(e){var t=e.teardown;if(t!==null){let n=Bn,r=W;Vn(!0),Un(null);try{t.call(null)}catch(t){fn(t,e.parent)}finally{Vn(n),Un(r)}}}function On(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&it(()=>{e.abort(ue)});var r=n.next;n.f&64?n.parent=null:An(n,t),n=r}}function kn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||An(t),t=n}}function An(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(jn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,On(e,t&&!n),sr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Dn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Mn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function jn(e,t){for(;e!==null;){var n=e===t?null:on(e);e.remove(),e=n}}function Mn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Nn(e,t,n=!0){var r=[];e.f|=256,Pn(e,r,!0);var i=()=>{n&&An(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Pn(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Pn(i,t,o?n:!1)}i=a}}}function Fn(e){e.f&=-257,In(e,!0)}function In(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(Qe(e,y),kt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);In(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Ln(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:on(n);t.append(n),n=i}}var Rn=null,zn=!1,Bn=!1;function Vn(e){Bn=e}var W=null,Hn=!1;function Un(e){W=e}var G=null;function Wn(e){G=e}var Gn=null;function Kn(e){W!==null&&(W.f&2097152||W.f&2)&&(Gn??=new Set).add(e)}var qn=null,Jn=0,Yn=null;function Xn(e){Yn=e}var Zn=1,Qn=0,$n=Qn;function er(e){$n=e}function tr(){return++Zn}function nr(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&xt===null&&Qe(e,v)}return!1}function rr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Gn!==null&&Gn.has(e)))for(var i=0;i{e.ac.abort(ue)}),e.ac=null);try{e.f|=te;var u=e.fn,d=u();e.f|=C;var f=ar(e);if(Ke()&&Yn!==null&&!Hn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Jn+qn.length,r=0;r{s.ac.abort(ue),s.ac=null,Qe(s,y)}),_t(s),sr(s,0)}}function sr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Ye(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function xr(e,t,n,r,i){var a={capture:r,passive:i},o=br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&_n(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function q(e,t,n){(t[_r]??={})[e]=n}function Sr(e){for(var t=0;t{wr=!1,Cr=null}));var s=0,c=Cr===e&&e[_r];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[_r]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=W,f=G;Un(null),Wn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[_r]?.[r];h==null||o.disabled&&e.target!==o||h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[_r]=t,delete e.currentTarget,Un(d),Wn(f)}}}var Er=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Dr(e){return Er?.createHTML(e)??e}function Or(e){var t=ln(`template`);return t.innerHTML=Dr(e.replaceAll(``,``)),t.content}function kr(e,t){var n=G;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function J(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(M)return kr(N,null),N;i===void 0&&(i=Or(a?e:``+e),n||(i=an(i)));var t=r||$t?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=an(t),s=t.lastChild;kr(o,s)}else kr(t,t);return t}}function Ar(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(M)return kr(N,null),N;if(!o){var e=an(Or(a));if(i)for(o=document.createDocumentFragment();an(e);)o.appendChild(an(e));else o=an(e)}var t=o.cloneNode(!0);if(i){var n=an(t),r=t.lastChild;kr(n,r)}else kr(t,t);return t}}function jr(e,t){return Ar(e,t,`svg`)}function Mr(e=``){if(!M){var t=rn(e+``);return kr(t,t),t}var n=N;return n.nodeType===3?un(n):(n.before(n=rn()),ye(n)),kr(n,n),n}function Nr(){if(M)return kr(N,null),N;var e=document.createDocumentFragment(),t=document.createComment(``),n=rn();return e.append(t,n),kr(t,n),e}function Y(e,t){if(M){var n=G;n.f&32768&&n.nodes.end!==null||(n.nodes.end=N),be()}else e!==null&&e.before(t)}function Pr(){if(M&&N&&N.nodeType===8&&N.textContent?.startsWith(`$`)){let e=N.textContent.substring(1);return be(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Fr(e){let t=0,n=Bt(0),r;return()=>{gn()&&(K(n),wn(()=>(t===0&&(r=fr(()=>e(()=>qt(n)))),t+=1,()=>{Ye(()=>{--t,t===0&&(r?.(),r=void 0,qt(n))})})))}}var Ir=T|E;function Lr(e,t,n,r){new Rr(e,t,n,r)}var Rr=class{parent;is_pending=!1;transform_error;#e;#t=M?N:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Fr(()=>(this.#m=Bt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=G;t.b=this,t.f|=128,n(e)},this.parent=G.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Tn(()=>{if(M){let e=this.#t;be();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Ir),M&&(this.#e=N)}#g(){try{this.#a=En(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Ye(r),t&&(this.#s=En(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{t?_e():(t=!0,n&&Re(),this.#s!==null&&Nn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()}))};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){fn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=En(()=>e(this.#e)),Ye(()=>{var e=this.#c=document.createDocumentFragment(),t=rn(),n=!1;e.append(t),this.#a=this.#S(()=>{try{return En(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){fn(e,this.#i.parent)}return null}}),this.#a===null?(this.#c=null,n&&this.#x(I)):this.#u===0&&(this.#e.before(e),this.#c=null,Nn(this.#o,()=>{this.#o=null}),this.#x(I))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=En(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Ln(this.#a,e);let t=this.#n.pending;this.#o=En(()=>t(this.#e))}else this.#x(I)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){et(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=G,n=W,r=Ve;Wn(this.#i),Un(this.#i),He(this.#i.ctx);try{return kt.ensure(),e()}finally{Wn(t),Un(n),He(r)}}#C(e,t){this.has_pending_snippet()?(this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Nn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))):this.parent&&this.parent.#C(e,t)}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Ye(()=>{this.#d=!1,this.#m&&Wt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),K(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;I?.is_fork?(this.#a&&I.skip_effect(this.#a),this.#o&&I.skip_effect(this.#o),this.#s&&I.skip_effect(this.#s),I.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(An(this.#a),null),this.#o&&=(An(this.#o),null),this.#s&&=(An(this.#s),null),M&&(ye(this.#t),xe(),ye(Se()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return En(()=>{var r=G;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return fn(e,this.#i.parent),null}}))};Ye(()=>{var t;try{t=this.transform_error(e)}catch(e){fn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>fn(e,this.#i&&this.#i.parent)):n(t)})}};function X(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[ce]??=e.nodeValue)&&(e[ce]=n,e.nodeValue=`${n}`)}function zr(e,t){return Vr(e,t)}var Br=new Map;function Vr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){nn();var l=void 0,u=xn(()=>{var s=n??t.appendChild(rn());Lr(s,{pending:()=>{}},t=>{Ue({});var n=Ve;if(o&&(n.c=o),a&&(i.$$events=a),M&&kr(t,null),l=e(t,i)||Ge(),M&&(G.nodes.end=N,N===null||N.nodeType!==8||N.data!==`]`))throw he(),fe;We()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Br.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Tr),r.delete(e),r.size===0&&Br.delete(n)):r.set(e,i)}yr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Hr.set(l,u),l}var Hr=new WeakMap,Ur=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Fn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Fn(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(An(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Ln(r,t),t.append(rn()),this.#n.set(e,{effect:r,fragment:t})}else An(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Nn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(An(n.effect),this.#n.delete(e))};ensure(e,t){var n=I,r=cn();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=rn();i.append(a),this.#n.set(e,{effect:En(()=>t(a)),fragment:i})}else this.#t.set(e,En(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else M&&(this.anchor=N),this.#a(n)}};function Z(e,t,n=!1){var r;M&&(r=N,be());var i=new Ur(e),a=n?T:0;function o(e,t){if(M){var n=Ce(r);if(e!==parseInt(n.substring(1))){var a=Se();ye(a),i.anchor=a,ve(!1),i.ensure(e,t),ve(!0);return}}i.ensure(e,t)}Tn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Wr=Symbol(`NaN`);function Gr(e,t,n){M&&be();var r=new Ur(e),i=!Ke();Tn(()=>{var e=t();e!==e&&(e=Wr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function Kr(e,t){return t}function qr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Jr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;sn(d),d.append(u),e.items.clear()}Jr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Jr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Qr(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=ee,ei(d,null,c)):Fn(d):Nn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Tn(()=>{p=K(f);var e=p.length;let t=!1;M&&Ce(c)===`[!`!=(e===0)&&(c=Se(),ye(c),ve(!1),t=!0);for(var r=new Set,u=I,v=cn(),y=0;ys(c)):(d=En(()=>s(Yr??=rn())),d.f|=ee)),e>r.size&&ke(``,``,``),M&&e>0&&ye(Se()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&ve(!0),K(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,M&&(c=N)}function Zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Qr(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var E=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function $r(e,t,n,r,i,a,o,s){var c=o&1?o&16?Bt(n):Vt(n,!1,!1):null,l=o&2?Bt(i):null;return{v:c,i:l,e:En(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ei(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=on(r);if(a.before(r),r===i)return;r=o}}function ti(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ni(e,t,n){var r;M&&(r=N,be());var i=new Ur(e);Tn(()=>{var e=t()??null;if(M&&Ce(r)===`[`!=(e!==null)){var a=Se();ye(a),i.anchor=a,ve(!1),i.ensure(e,e&&(t=>n(t,e))),ve(!0)}else i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` -\r\f\xA0\v`];function ii(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),_n(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;at(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,I!==null&&r.add(I)}),Sn(()=>{var a=t();if(e===document.activeElement){var o=I;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=de?`link`:`LINK`;function xi(e){if(M){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[le]=n,Ye(n),rt()}}function Si(e,t){var n=Ci(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=Ci(e);M&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ae]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ti(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Ci(e){return e[oe]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===pe}}var wi=new Map;function Ti(e){var t=e.getAttribute(`is`)||e.nodeName,n=wi.get(t);if(n)return n;wi.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Ei(e,t,n=t){var r=new WeakSet;at(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ji(e)?Mi(a):a,n(a),I!==null&&r.add(I),await lr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(M&&e.defaultValue!==e.value||fr(t)==null&&e.value)&&(n(ji(e)?Mi(e.value):e.value),I!==null&&r.add(I)),wn(()=>{var n=t();if(e===document.activeElement){var i=I;if(r.has(i))return}ji(e)&&n===Mi(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Di=new Set;function Oi(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),at(n,`change`,()=>{var e=n.__value;a&&(e=Ai(o,e,n.checked)),i(e)},()=>i(a?[]:null)),wn(()=>{var e=r();M&&n.defaultChecked!==n.checked?s=!0:a?(e||=[],n.checked=e.includes(n.__value)):n.checked=Zt(n.__value,e)}),_n(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Di.has(o)||(Di.add(o),Ye(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Di.delete(o)})),Ye(()=>{if(s){var e=a?Ai(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function ki(e,t,n=t){at(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(M&&e.defaultChecked!==e.checked||fr(t)==null)&&n(e.checked),wn(()=>{e.checked=!!t()})}function Ai(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Pi(e,t,n){var r=Ni.observe(e,()=>n(e[t]));Sn(()=>(fr(()=>n(e[t])),r))}function Fi(e,t){return e===t||e?.[k]===t}function Ii(e=Ge(),t,n,r){var i=Ve.r,a=G;return Sn(()=>{var o,s;return wn(()=>{o=s,s=r?.()||[],fr(()=>{Fi(n(...s),e)||(t(e,...s),o&&Fi(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Fi(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Li(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?wn(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&_n(()=>{n.removeEventListener(t,a)})}function Ri(e=!1){let t=Ve,n=t.l.u;if(!n)return;let r=()=>pr(t.s);if(e){let e=0,n={},i=ut(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>K(i)}n.b.length&&bn(()=>{zi(t,r),m(n.b)}),vn(()=>{let e=fr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&vn(()=>{zi(t,r),m(n.a)})}function zi(e,t){if(e.l.s)for(let t of e.l.s)K(t);t()}var Bi=!1;function Vi(e){var t=Bi;try{return Bi=!1,[e(),Bi]}finally{Bi=t}}var Hi={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===k||t===ie)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Ui(...e){return new Proxy({props:e},Hi)}function Wi(e,t,n,r){var i=!ze||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ut(r),K(u)):(l&&(l=!1,c=s?fr(r):r),c);let f;if(o){var p=k in e||ie in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Vi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Pe(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?ut:pt)(()=>(v=!1,g()));o&&K(y);var b=G;return(function(e,t){if(arguments.length>0){let n=t?K(y):i&&o?Yt(e):e;return R(y,n),v=!0,c!==void 0&&(c=n),e}return Bn&&v||b.f&16384?y.v:K(y)})}function Gi(e){Ve===null&&De(`onMount`),ze&&Ve.l!==null?qi(Ve).m.push(e):vn(()=>{let t=fr(e);if(typeof t==`function`)return t})}function Ki(e){Ve===null&&De(`onDestroy`),Gi(()=>()=>fr(e))}function qi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Ji(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Yi=new class{#e=L(Xi());get _loc(){return K(this.#e)}set _loc(e){R(this.#e,e)}#t=F(()=>this._loc.location);get _location(){return K(this.#t)}set _location(e){R(this.#t,e)}#n=F(()=>this._loc.querystring);get _querystring(){return K(this.#n)}set _querystring(e){R(this.#n,e)}#r=L(void 0);get _params(){return K(this.#r)}set _params(e){R(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Xi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Xi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}async function Zi(e){if(!e||e.length<1||e.charAt(0)!=`/`&&e.indexOf(`#/`)!==0)throw Error(`Invalid parameter location`);await lr();let t=(e.charAt(0)==`#`?``:`#`)+e;try{let e={...history.state};delete e.__svelte_spa_router_scrollX,delete e.__svelte_spa_router_scrollY,window.history.replaceState(e,``,t)}catch{console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event(`hashchange`))}function Qi(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function $i(e,t){Ue(t,!0);let n=Wi(t,`routes`,19,()=>({})),r=Wi(t,`prefix`,3,``),i=Wi(t,`restoreScrollState`,3,!1),a=Wi(t,`onConditionsFailed`,3,()=>{}),o=Wi(t,`onRouteLoaded`,3,()=>{}),s=Wi(t,`onRouteLoading`,3,()=>{}),c=Wi(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Ji(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=L(null),f=L(null),p=L({}),m=null,h=null;vn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),vn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await lr(),e(t)}vn(()=>{let e=Yi.loc,t=!1;return fr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Nr(),y=B(v),b=e=>{let t=F(()=>K(d));var n=Nr(),r=B(n),i=e=>{var n=Nr();ni(B(n),()=>K(t),(e,t)=>{t(e,Ui({get params(){return K(f)},get onRouteEvent(){return c()}},()=>K(p)))}),Y(e,n)},a=e=>{var n=Nr();ni(B(n),()=>K(t),(e,t)=>{t(e,Ui({get onRouteEvent(){return c()}},()=>K(p)))}),Y(e,n)};Z(r,e=>{K(f)?e(i):e(a,-1)}),Y(e,n)};Z(y,e=>{K(d)&&e(b)}),Y(e,v),We()}var ea=[`bars`,`pace`,`pie`,`fuel`,`resets`,`thresholds`];function ta(e){return e===`zone`||e===`consumption-pace`?`pace`:typeof e==`string`&&ea.includes(e)?e:`bars`}var na=`codexometer.web.preferences.v1`,ra={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function ia(){try{let e=JSON.parse(localStorage.getItem(na)||`null`);return!e||typeof e!=`object`?ra:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:ta(e.view),selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ra}}var aa=Yt(ia()),oa=Yt({open:!1}),sa=Yt({requests:0});function ca(){let e=JSON.stringify(aa);try{localStorage.setItem(na,e)}catch{}}function la(){return aa.tab===`quota`?`/quota/`+aa.view:`/`+aa.tab}function ua(e){return aa.layouts.find(t=>t.id===e)?.level??aa.defaultDetail}function da(e){aa.defaultDetail=e,aa.layouts=[]}function fa(e,t){aa.layouts=[...aa.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Yt({data:null,connected:!1,error:``}),pa=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),ma=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ha=`codexometer.web.session`,ga=class extends Error{},_a;async function va(e,t,n){if(!_a||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await _a(e,t,n)}function ya(){let e=new AbortController,t,n=``;_a=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new ga(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ha)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+la()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(ha,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}n?await o():$.error=`Open the private pairing link printed by codexometer --web in your terminal.`}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(ha)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` - -`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{_a=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Be();var ba=J(`

Quota refresh failed. Policy state is based on the last successful - observation.

`),xa=J(`

`),Sa=J(`

The longest Codex quota window selects one active model profile. ASK - creates a per-session review; AUTO applies the profile on the next - eligible check.

`,1),Ca=J(`

No threshold-based model steps were configured at launch.

`);function wa(e,t){Ue(t,!1),Ri();var n=Nr(),r=B(n),i=e=>{var t=Sa(),n=B(t),r=V(n),i=H(n,2),a=e=>{Y(e,ba())};Z(i,e=>{$.data.quotaError&&e(a)});var o=H(i,2),s=z(o),c=V(s),l=H(s,4);Xr(l,5,()=>$.data.thresholds,Kr,(e,t)=>{var n=xa();let r;var i=z(n),a=V(i),o=H(i,2),s=z(o),c=V(s,!0),l=V(H(s,2));P(o);var u=H(o,2),d=V(u,!0),f=V(H(u,2));P(n),U((e,i)=>{r=ci(n,1,``,null,r,{active:K(t).state===`ACTIVE`,next:K(t).state===`NEXT`}),X(a,`${K(t).threshold??``}%`),X(c,K(t).model),X(l,`${e??``} REASONING // ${i??``} - SPEED`),X(d,K(t).mode),X(f,`${K(t).state??``}${K(t).state===`NEXT`?` // ${K(t).remaining||0} PP TO GO`:``}`)},[()=>K(t).effort.toUpperCase(),()=>K(t).speed.toUpperCase()]),Y(e,n)}),P(l),P(o),U(e=>{X(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),X(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>ma($.data.quotaAt)]),Y(e,t)},a=e=>{Y(e,Ca())};Z(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),Y(e,n),We()}var Ta=jr(` `,1),Ea=jr(` `,1),Da=jr(` `,1),Oa=jr(` `,1),ka=J(`
`,1),Aa=J(` `),ja=J(`
Quota observations
Observed atPeriod elapsedConsumedTrail segment
`),Ma=J(`
OBSERVATION DATA
`),Na=J(`
CONSUMPTIONQUOTA PERIOD ELAPSED
`,1);function Pa(e,t){let n=Pr();Ue(t,!0);let r=Wi(t,`trail`,19,()=>[]),i=L(!1),a=L(!0),o=L(`window`),s=[0,25,50,75,100],c={off:0,halfHour:30,hour:60,day:1440,window:0},l=L(400),u=L(240),d=F(()=>K(l)-24),f=F(()=>K(u)-48),p=F(()=>Math.max(1,K(d)-48)),m=F(()=>Math.max(1,K(f)-20)),h=F(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*K(p));function g(e){return K(f)-(e-0)/100*K(m)}let _=F(()=>g(t.used)),v=F(()=>t.used-t.elapsed),y=F(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*K(p)} ${g(e.used)}`).join(` `)),b=F(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),x=F(()=>K(b).length<2?0:Math.max(0,Date.parse(K(b).at(-1).at)-Date.parse(K(b)[0].at)));function S(e){if(K(x)Date.parse(e.at)>=t).length>=2}let C=F(()=>({off:!0,halfHour:S(18e5),hour:S(36e5),day:S(864e5),window:Number.isFinite(t.elapsed)&&t.elapsed>0&&Number.isFinite(t.used)}));vn(()=>{K(o)!==`window`&&!K(C)[K(o)]&&R(o,`window`)});function w(e){if(e===`off`||!K(C)[e])return[];let t=c[e]*6e4,n=Date.parse(K(b).at(-1).at)-t,r=K(b).findIndex(e=>Date.parse(e.at)>=n);return r<0?[]:K(b).slice(r)}function T(e){if(e.length<2)return null;let t=e.reduce((e,t)=>e+t.elapsed,0)/e.length,n=e.reduce((e,t)=>e+t.used,0)/e.length,r=0,i=0;for(let a of e)r+=(a.elapsed-t)*(a.used-n),i+=(a.elapsed-t)**2;return i>0?Math.max(0,r/i):null}let E=F(()=>{let e=K(o)===`window`&&K(C).window?t.used/t.elapsed:T(w(K(o)));if(e===null||!t.duration)return null;let n=t.used+e*(100-t.elapsed),r=K(o)===`window`?0:t.used-e*t.elapsed,i=e,a=Math.max(0,t.elapsed-c[K(o)]/t.duration*100);K(o)===`window`&&(a=0);let s=100;if(i!==0){let e=(0-r)/i,t=(100-r)/i;a=Math.max(a,Math.min(e,t)),s=Math.min(100,Math.max(e,t))}if(a>s)return null;let l=r+i*a,u=r+i*s,d=Math.hypot((s-a)/100*K(p),(u-l)/100*K(m)),f=Math.max(3,Math.min(9,Math.floor(d/65)+2));return{path:`M${Array.from({length:f},(e,t)=>{let n=a+(s-a)*t/(f-1),r=l+(u-l)*t/(f-1);return`${48+n/100*K(p)} ${g(r)}`}).join(` L`)}`,projected:n,safe:n<=100}}),D=F(()=>{if(K(b).length===0)return`NO OBSERVATIONS`;if(K(b).length===1)return`ONE OBSERVATION`;let e=Math.floor(K(x)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var ee=Na(),te=B(ee),O=z(te);let ne;var k=z(O),re=z(k),ie=H(re);P(k);var ae=H(k),oe=H(ae);Xr(oe,17,()=>s,Kr,(e,t)=>{var n=Ta(),r=B(n),i=H(r),a=V(i);U(()=>{Q(r,`x1`,48+K(t)/100*K(p)),Q(r,`x2`,48+K(t)/100*K(p)),Q(r,`y2`,K(f)),Q(i,`x`,48+K(t)/100*K(p)),Q(i,`y`,K(f)+20),X(a,`${K(t)??``}%`)}),Y(e,n)});var se=H(oe);Xr(se,17,()=>s,Kr,(e,t)=>{var n=Ea(),r=B(n),i=H(r),a=V(i);U((e,n,o)=>{Q(r,`y1`,e),Q(r,`x2`,K(d)),Q(r,`y2`,n),Q(i,`y`,o),X(a,`${K(t)??``}%`)},[()=>g(K(t)),()=>g(K(t)),()=>g(K(t))+4]),Y(e,n)});var A=H(se),ce=H(A),le=H(ce),ue=e=>{var t=Da(),n=B(t),i=H(n),a=H(i),o=V(z(a));P(a),U((e,t)=>{Q(n,`d`,K(y)),Q(i,`d`,K(y)),Q(a,`cx`,48+r()[0].elapsed/100*K(p)),Q(a,`cy`,e),X(o,`First observation: ${t??``}`)},[()=>g(r()[0].used),()=>ma(r()[0].at)]),Y(e,t)};Z(le,e=>{K(a)&&r().length&&e(ue)});var de=H(le),fe=e=>{var t=Oa(),r=B(t),i=H(r),a=V(z(i));P(i),U(e=>{Q(r,`d`,K(E).path),Q(i,`d`,K(E).path),Q(i,`marker-mid`,`url(#${n}-trend-arrow)`),X(a,`${K(o)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>K(E).projected.toFixed(1)]),Y(e,t)};Z(de,e=>{K(E)&&e(fe)});var j=H(de,2),pe=H(j),me=H(pe),he=V(z(me));P(me),P(O),P(te);var ge=H(te,2),_e=z(ge),M=z(_e),ve=H(M,3),N=V(ve,!0),ye=H(ve,2),be=e=>{var t=ka(),n=V(H(B(t)));U(e=>X(n,`TREND // ${e??``}`),[()=>K(E).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${K(E).projected.toFixed(1)}% PROJECTED AT RESET`]),Y(e,t)};Z(ye,e=>{K(E)&&e(be)}),P(_e);var Se=H(_e,2),Ce=z(Se),we=z(Ce);xi(we),xe(),P(Ce);var Te=H(Ce,2),Ee=H(z(Te),2),De=z(Ee);De.value=De.__value=`off`;var Oe=H(De),ke=V(Oe);Oe.value=Oe.__value=`halfHour`;var Ae=H(Oe),je=V(Ae);Ae.value=Ae.__value=`hour`;var Me=H(Ae),Ne=V(Me);Me.value=Me.__value=`day`;var Pe=H(Me),Fe=V(Pe);Pe.value=Pe.__value=`window`,P(Ee),mi(Ee),P(Te);var Ie=V(H(Te,2));P(Se),P(ge);var Le=H(ge,2),Re=e=>{var t=Ma(),n=H(z(t),2),a=e=>{var t=ja(),n=z(t),i=H(z(n),2);Xr(i,21,r,Kr,(e,t,n)=>{var r=Aa(),i=z(r),a=z(i),o=V(a,!0);P(i);var s=H(i),c=V(s),l=H(s),u=V(l),d=V(H(l),!0);P(r),U((e,r)=>{Q(a,`datetime`,K(t).at),X(o,e),X(c,`${r??``}%`),X(u,`${K(t).used??``}%`),X(d,n===0?`First observation`:K(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>ma(K(t).at),()=>K(t).elapsed.toFixed(1)]),Y(e,r)}),P(i),P(n),P(t),Y(e,t)};Z(n,e=>{K(i)&&e(a)}),P(t),Li(`open`,`toggle`,t,e=>R(i,e),()=>K(i)),Y(e,t)};Z(Le,e=>{r().length&&e(Re)}),U((e,r,i,a,o,s)=>{Q(O,`viewBox`,`0 0 ${K(l)} ${K(u)}`),Q(O,`aria-label`,e),ne=ui(O,``,ne,{"--trend-color":K(E)?.safe?`#115b35`:`#7f1825`}),Q(re,`id`,n),Q(ie,`id`,n+`-trend-arrow`),Q(ae,`width`,K(p)),Q(ae,`height`,K(m)),Q(ae,`fill`,`url(#${n})`),Q(A,`d`,`M48 20 V${K(f)} H${K(d)}`),Q(ce,`y1`,r),Q(ce,`x2`,K(d)),Q(ce,`y2`,i),Q(j,`x`,48+K(p)/2),Q(j,`y`,K(u)-5),Q(pe,`cx`,K(h)),Q(pe,`cy`,K(_)),Q(me,`cx`,K(h)),Q(me,`cy`,K(_)),X(he,`${t.used??``}% consumed // ${a??``}% of period elapsed`),X(M,`${t.used??``}% USED // ${o??``}% TIME ELAPSED`),X(N,s),Oe.disabled=!K(C).halfHour,X(ke,`LAST 30 MINUTES${K(C).halfHour?``:` — UNAVAILABLE`}`),Ae.disabled=!K(C).hour,X(je,`LAST HOUR${K(C).hour?``:` — UNAVAILABLE`}`),Me.disabled=!K(C).day,X(Ne,`LAST 24 HOURS${K(C).day?``:` — UNAVAILABLE`}`),Pe.disabled=!K(C).window,X(Fe,`FROM WINDOW START${K(C).window?``:` — NO TIME ELAPSED`}`),X(Ie,`HISTORY // ${K(D)??``}`)},[()=>`Pace: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${K(v)>0?`Above`:K(v)<0?`Below`:`On`} the steady-consumption line.${K(a)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>g(0),()=>g(100),()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(K(v))<.05?`ON PACE`:K(v)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Pi(te,`clientWidth`,e=>R(l,e)),Pi(te,`clientHeight`,e=>R(u,e)),ki(we,()=>K(a),e=>R(a,e)),hi(Ee,()=>K(o),e=>R(o,e)),Y(e,ee),We()}var Fa=J(` `),Ia=J(`

Quota refresh failed. Values below are the last successful observation.

`),La=J(`

`),Ra=J(`

Expiry details unavailable. No listed expiry does not mean no expiry.

`),za=J(`

`),Ba=J(`

Read-only preview. Use the terminal to redeem a reset.

The backend may return only some credits. This list does not establish - redemption order.

`),Va=J(` `,1),Ha=jr(``),Ua=jr(``),Wa=J(`
`),Ga=J(`

Cycle duration or reset date unavailable — position cannot be - plotted.

`),Ka=J(`
EMPTYFULL
`),qa=J(`

`,1),Ja=J(`
`,1),Ya=J(`

`),Xa=J(`

`),Za=J(`

No quota windows reported yet.

`),Qa=J(`
`,1),$a=J(`

All reported windows are shown. API-equivalent learning and quota status - scoring remain in the terminal for this first preview.

`,1),eo=J(` `,1);function to(e,t){Ue(t,!0);let n=Wi(t,`params`,19,()=>({})),r=F(()=>ea.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=L(Yt(Date.now())),a=F(()=>K(r).includes(ta(n().view))?ta(n().view):`bars`);Gi(()=>{let e=setInterval(()=>R(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-K(i))/(e.duration*6e4))))}vn(()=>{aa.view=K(a),(n().view===`zone`||n().view===`consumption-pace`)&&Zi(`/quota/pace`)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=eo(),l=B(c);Xr(l,21,()=>K(r),Kr,(e,t)=>{var n=Fa();let r;var i=V(n,!0);U(e=>{Q(n,`href`,`#/quota/`+K(t)),Q(n,`aria-current`,K(a)===K(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:K(a)===K(t)}),X(i,e)},[()=>K(t)===`fuel`?`FUEL TANK`:K(t).toUpperCase()]),Y(e,n)}),P(l);var u=H(l,2),d=e=>{var t=$a(),n=B(t),r=e=>{Y(e,Ia())};Z(n,e=>{$.data.quotaError&&e(r)});var i=H(n,2),c=e=>{var t=La(),n=V(t);U(()=>X(n,`Last usage accounting issue: - ${$.data.usageDiagnostic??``}`)),Y(e,t)};Z(i,e=>{$.data.usageDiagnostic&&e(c)});var l=H(i,2),u=V(l),d=H(l,2),f=e=>{wa(e,{})},p=e=>{var t=Ba(),n=z(t),r=V(n),i=H(n,4),a=e=>{Y(e,Ra())};Z(i,e=>{$.data.credits.length||e(a)}),Xr(H(i,2),17,()=>$.data.credits,Kr,(e,t)=>{var n=za(),r=z(n),i=V(r),a=V(H(r,2),!0);P(n),U(e=>{X(i,`${(K(t).title||`Quota reset`)??``} // ${K(t).status??``}`),X(a,e)},[()=>K(t).expiryKnown?K(t).expires?`EXPIRES `+ma(K(t).expires):`Does not expire`:`Expiry information unavailable`]),Y(e,n)}),xe(2),P(t),U(()=>X(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),Y(e,t)},m=e=>{var t=Qa(),n=B(t);let r;Xr(n,21,()=>$.data.meters,Kr,(e,t)=>{let n=F(()=>o(K(t)));var r=Xa(),i=z(r),c=V(i,!0),l=H(i,2),u=z(l),d=e=>{var n=Va(),r=B(n),i=V(r),a=V(H(r));U(()=>{X(i,`FREE ${100-K(t).used}%`),X(a,`USED ${K(t).used??``}%`)}),Y(e,n)},f=e=>{var n=Va(),r=B(n),i=V(r),a=V(H(r));U(()=>{X(i,`USED ${K(t).used??``}%`),X(a,`FREE ${100-K(t).used}%`)}),Y(e,n)};Z(u,e=>{K(a)===`fuel`?e(d):e(f,-1)}),P(l);var p=H(l,2);let m;var h=z(p),g=e=>{var n=Wa(),r=z(n),i=H(z(r)),a=e=>{Y(e,Ha())},o=e=>{var n=Ua();U(e=>Q(n,`d`,e),[()=>s(K(t).used)]),Y(e,n)};Z(i,e=>{K(t).used>=100?e(a):K(t).used>0&&e(o,1)}),P(r),P(n),U(()=>Q(r,`aria-label`,`${K(t).used}% quota used`)),Y(e,n)},_=e=>{var r=Nr(),i=B(r),a=e=>{{let r=F(()=>K(t).trail||[]);Pa(e,{get used(){return K(t).used},get elapsed(){return K(n)},get trail(){return K(r)},get duration(){return K(t).duration}})}},o=e=>{Y(e,Ga())};Z(i,e=>{K(n)===null?e(o,-1):e(a)}),Y(e,r)},v=e=>{var r=Ja(),i=B(r),o=z(i);let s;P(i);var c=H(i,2),l=e=>{Y(e,Ka())};Z(c,e=>{K(a)===`fuel`&&e(l)});var u=H(c,2),d=e=>{var t=qa(),r=B(t),i=V(r),o=H(r,2),s=z(o);let c;P(o),U(e=>{X(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${K(a)===`fuel`?100-K(n):K(n)}%`})},[()=>Math.floor(K(n))]),Y(e,t)};Z(u,e=>{K(n)!==null&&e(d)}),U(()=>{Q(i,`aria-label`,K(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,K(a)===`fuel`?100-K(t).used:K(t).used),s=ui(o,``,s,{width:`${K(a)===`fuel`?100-K(t).used:K(t).used}%`})}),Y(e,r)};Z(h,e=>{K(a)===`pie`?e(g):K(a)===`pace`?e(_,1):e(v,-1)}),P(p);var y=H(p,2),b=V(y),x=H(y,2),S=e=>{var n=Ya(),r=V(n,!0);U(()=>X(r,K(t).details)),Y(e,n)};Z(x,e=>{K(t).details&&e(S)}),P(r),U(e=>{X(c,K(t).name),m=ci(p,1,`meter-graphic`,null,m,{"bar-graphic":K(a)===`bars`||K(a)===`fuel`}),X(b,`RESETS // ${e??``}`)},[()=>ma(K(t).reset)]),Y(e,r)}),P(n);var i=H(n,2),c=e=>{Y(e,Za())};Z(i,e=>{$.data.meters.length||e(c)}),U(()=>r=ci(n,1,`quota-grid`,null,r,{radial:K(a)===`pie`,zone:K(a)===`pace`})),Y(e,t)};Z(d,e=>{K(a)===`thresholds`?e(f):K(a)===`resets`?e(p,1):e(m,-1)}),xe(2),U(e=>X(u,`QUOTA // OBSERVED ${e??``}`),[()=>ma($.data.quotaAt)]),Y(e,t)};Z(u,e=>{$.data&&e(d)}),Y(e,c),We()}var no=J(`
`),ro=J(`

`,1);function io(e,t){Ue(t,!0);let n=Wi(t,`values`,19,()=>[]),r=Wi(t,`label`,3,`Token activity`),i=Wi(t,`capacity`,3,0),a=F(()=>Math.max(0,...n())),o=F(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=ro(),c=B(s),l=V(c),u=H(c,2);Xr(u,21,()=>K(o),Kr,(e,t)=>{var n=no();let r;U((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>K(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*K(t)/Math.max(1,K(a))}%`]),Y(e,n)}),P(u),U((e,t)=>{X(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>K(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${K(a).toLocaleString(`en-GB`)} tokens.`]),Y(e,s),We()}function ao(e){if(!e||![`LAST REPLY`,`LAST ACTIVITY`].includes(e.contextKind))return``;let t=e.text||e.contextKind===`LAST ACTIVITY`&&e.workingCommand||``;return t.trim()?t:``}var oo=J(` `),so=J(``),co=J(`

`),lo=J(`

`,1),uo=J(`

`),fo=J(`

Loading / sending…

`),po=J(`
`),mo=J(`

`),ho=J(`

 
`),go=J(`
`),_o=J(`
`),vo=J(`

Review expired. Press Enter to review again.

`),yo=J(`

`,1),bo=J(`

`,1),xo=J(`

No available matching commands.

`),So=J(` `,1),Co=J(`

`),wo=J(`

Review expired. Review the option again.

`),To=J(``),Eo=J(``),Do=J(``),Oo=J(``),ko=J(``),Ao=J(``),jo=J(`
`),Mo=J(`
`);function No(e,t){let n=Pr();Ue(t,!0);let r=e=>{var t=Nr();Xr(B(t),19,()=>K(fe),e=>e.id,(e,t,r)=>{var i=so();let o;var s=z(i),c=V(s,!0),l=H(s),u=V(l),d=H(l),f=e=>{var n=oo(),r=V(n,!0);U(()=>X(r,K(t).help)),Y(e,n)};Z(d,e=>{(K(v)?.path===``||K(A))&&e(f)}),P(i),U((e,s)=>{Q(i,`id`,`${n}-${K(r)}`),Q(i,`role`,K(A)?`option`:void 0),Q(i,`aria-selected`,K(A)?K(T)===K(r):void 0),Q(i,`tabindex`,K(A)?-1:void 0),i.disabled=K(g)||K(he)&&!a(),Q(i,`title`,K(t).help),Q(i,`aria-label`,e),o=ci(i,1,`svelte-7bfwr9`,null,o,{suggested:K(T)===K(r)}),X(c,K(t).label),X(u,`${K(A)&&K(t).selected?` // CURRENT`:``}${s??``}`)},[()=>K(t).label+(K(A)&&K(t).selected?` // CURRENT`:``)+ie(K(t)),()=>ie(K(t))]),xr(`focus`,i,()=>{K(A)||_e(K(r))}),q(`click`,i,()=>{_e(K(r)),ye(K(t))}),Y(e,i)}),Y(e,t)},i=Wi(t,`query`,3,``),a=Wi(t,`localOnly`,3,!1),o=Wi(t,`oncopy`,3,()=>{}),s=Wi(t,`onchange`,3,()=>{}),c=Wi(t,`oncomplete`,3,e=>{}),l=[`statusline`,`usage`,`copy`,`theme`,`exit`,`quit`];function u(){return[{id:`local-statusline`,label:`/statusline`,help:`Choose fields for Codexometer’s detail footer.`,next:`statusline`},{id:`local-usage`,label:`/usage`,help:`Open Codexometer’s usage history. Quota and reset views remain available.`,next:`usage`},{id:`local-copy`,label:`/copy`,help:`Copy the selected session’s observed reply or activity with its Copy control.`,next:`copy`},{id:`local-theme`,label:`/theme`,help:`Open the existing Codexometer theme selector. Saved browser display preferences only.`,next:`theme`},{id:`local-exit`,label:`/exit`,help:`Leave session detail and return to Sessions. The local server remains running.`,next:`exit`},{id:`local-quit`,label:`/quit`,help:`Alias for /exit: return to Sessions. The local server remains running.`,next:`quit`}]}function d(){return{title:`/ COMMANDS`,help:`Local Codexometer commands remain available without session control.`,path:``,revision:``,choices:u()}}function f(){R(b,``),R(O,``),R(x,0),R(ne,[],!0)}function p(){w++,R(g,!1),R(h,!1),R(E,i()),f(),R(_,``),K(ue)?s()():c()(i())}async function m(e){if(!l.includes(e))return!1;if(e===`copy`&&!ao($.data?.sessions.find(e=>e.id===t.session)))return R(_,`No reply or activity text is available to copy for this session.`),!0;if(e===`copy`){let e=o()();p(),await e}else p(),e===`usage`?location.hash=`/usage`:e===`theme`?sa.requests++:e===`statusline`?oa.open=!0:location.hash=`/sessions`;return!0}let h=L(!1),g=L(!1),_=L(``),v=L(null),y=L(null),b=L(``),x=L(0),S=L(Yt(Date.now())),C=L(``),w=0,T=L(0),E=L(null),D=L(void 0),ee=L(void 0),te=L(void 0),O=L(``),ne=L(Yt([])),k=F(()=>K(v)?.path.startsWith(`rename/`)||K(v)?.path.startsWith(`cd/`)),re=F(()=>!!K(y)&&!K(k)||!!K(O)||K(ne).length>0);function ie(e){return e.unavailable?e.unavailable.startsWith(`Waiting for idle.`)?` // WAITING FOR IDLE`:` // UNAVAILABLE`:e.next?` →`:e.action?``:` // HELP`}async function ae(e){K(v)&&!(K(ge)&&K(de))&&R(ne,[...K(ne),{path:K(v).path,index:K(T),input:K(C)}],!0),await N(e)}async function oe(){if(!K(re))return;if(w++,R(g,!1),R(b,``),R(x,0),R(_,``),K(O)){R(O,``),K(D)?.focus();return}if(K(y)&&!K(k)){R(y,null),await lr(),K(D)?.focus();return}let e=K(ne).at(-1);e&&(R(ne,K(ne).slice(0,-1),!0),await N(e.path,e))}function se(){K(v)&&K(C).trim()&&!K(g)&&!K(he)&&ae(K(v).path+`/`+encodeURIComponent(K(C).trim()))}let A=F(()=>K(h)&&!!K(v)?.picker&&!K(y)),ce=F(()=>K(h)&&!K(v)?.input&&!K(y)),le=setInterval(()=>{R(S,Date.now(),!0)},1e3);Ki(()=>{clearInterval(le),w++});let ue=F(()=>i().trim().startsWith(`/`)&&!i().trim().startsWith(`//`)),de=F(()=>K(v)?.path===``&&K(ue)?i().trim().slice(1).toLowerCase():``),fe=F(()=>(K(v)?.choices||[]).filter(e=>!K(de)||e.label.toLowerCase().startsWith(`/`+K(de)))),j=F(()=>K(y)||K(fe)[K(T)]),pe=F(()=>!!K(b)&&K(S)K(fe).find(e=>e.id===K(O))),he=F(()=>!$.connected||!!$.data?.sessionsError),ge=F(()=>K(h)&&K(ue)&&(!K(v)||K(v).path===``)&&!K(y));vn(()=>{i(),R(T,0)}),vn(()=>{let e=K(T);K(fe),K(ce)&&lr().then(()=>{let t=K(D)?.children[e];if(!t||!K(D))return;let n=K(D).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(K(D).scrollTop+=r.bottom-n.bottom)})});function _e(e){K(T)!==e&&K(v)?.picker&&(R(O,``),R(b,``),R(x,0),R(_,``),w++),R(T,e,!0)}function M(){w++,R(g,!1),R(h,!1),R(E,i()),f(),c()(i())}function ve(e){let t=!!K(ee)?.contains(e.target);if(!K(h)||!K(ce)&&!K(y)&&!K(v)?.input||!K(ue)&&!t||K(he)&&!a()||e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return;if(K(v)?.input){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),M());return}let n=e.key===`ArrowLeft`,r=e.key.toLowerCase()===`f`,i=e.key.toLowerCase()===`c`;if((i||r||n)&&!t||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!i&&!r&&!n||e.key===`Tab`&&(K(y)||K(v)?.path!==``||e.shiftKey)||e.key===`Enter`&&e.target instanceof Element&&e.target.closest(`button`)&&!K(D)?.contains(e.target)&&!e.target.closest(`[data-command-confirm]`)||K(y)&&!t||K(y)&&[`ArrowUp`,`ArrowDown`].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){M();return}if(K(g)||e.repeat&&(i||e.key===`Enter`))return;if(n){K(re)&&oe();return}if(r){N(K(v)?.path||``,void 0,!0);return}if(i){(K(y)?.action||K(A)&&K(O))&&xe();return}if(K(y)){e.key===`Enter`&&K(y).action&&!K(pe)&&!K(_)&&be(K(y));return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){_e(Math.min(Math.max(K(T)+(e.key===`ArrowUp`?-1:1),0),Math.max(K(fe).length-1,0))),!K(A)&&K(D)?.contains(e.target)&&lr().then(()=>(K(D)?.children[K(T)])?.focus());return}let o=K(fe)[K(T)];o&&(e.key===`Tab`?c()(o.label):K(A)?be(o):ye(o))}vn(()=>{K(he)&&!a()&&(w++,R(g,!1),f(),K(h)&&(R(h,!1),R(E,i())),R(v,null),R(y,null))}),vn(()=>{K(ue)&&!K(h)&&i()!==K(E)&&(!K(he)||a())&&(f(),R(h,!0),N(``))});async function N(e,n,r=!1){let i=++w;if(K(v)&&R(v,{...K(v),path:e},!0),n&&R(C,n.input,!0),R(g,!0),R(y,null),R(O,``),R(b,``),R(x,0),R(_,``),a())R(v,d(),!0),R(T,n?.index??0,!0),R(g,!1);else try{let a=await va(`commands`,{session:t.session,command:{mode:`list`,path:e,...r?{refresh:!0}:{}}});i===w&&((e===``||e===`help`)&&(a.choices=[...a.choices.filter(e=>!l.includes(e.label.replace(/^\//,``))),...u()]),R(v,a,!0),R(T,n?Math.min(n.index,Math.max(a.choices.length-1,0)):a.picker?Math.max(a.choices.findIndex(e=>e.selected),0):0,!0),a.picker&&lr().then(()=>K(D)?.focus()),R(C,n?.input??a.value??``,!0),n&&lr().then(()=>{a.input?K(ee)?.querySelector(`input`)?.focus():K(D)?.focus()}),(a.path.startsWith(`rename/`)||a.path.startsWith(`cd/`))&&a.choices.length===1&&(R(g,!1),ye(a.choices[0])))}catch{i===w&&(R(_,`Command catalogue unavailable. Use Codex.`),e===``||e===`help`?(R(v,d(),!0),R(_,``)):R(v,{title:`/`+e,help:``,path:e,revision:``,choices:[]},!0))}finally{i===w&&R(g,!1)}}async function ye(e){e.unavailable||K(g)||e.next&&await m(e.next)||K(_)||(K(v)?.picker?(_e(K(fe).findIndex(t=>t.id===e.id)),e.action&&(e.reversible||$.data?.noConfirm)?await be(e):K(D)?.focus()):e.next?await ae(e.next):await be(e))}async function be(e){if(K(g)||K(he)||!K(v)||e.unavailable||K(_))return;let n=e.action&&(e.reversible||$.data?.noConfirm);if(K(v).picker){if(K(pe)&&K(O)===e.id)return;R(O,e.id,!0)}else n||(R(y,e,!0),lr().then(()=>K(te)?.focus()));if(R(b,``),R(x,0),R(_,``),!e.action)return;let r=++w;R(g,!0);try{let n=await va(`commands`,{session:t.session,command:{mode:`prepare`,path:K(v).path,revision:K(v).revision,choice:e.id}});if(r===w){let e=Date.parse(n.expires);if(!n.confirmation||!Number.isFinite(e)||Date.now()>=e)throw Error(`Review confirmation unavailable`);R(b,n.confirmation,!0),R(x,e,!0)}}catch{r===w&&R(_,`Option changed or unavailable. Refresh before retrying.`)}finally{r===w&&R(g,!1)}n&&r===w&&K(b)&&await xe()}async function xe(){if(!K(b)||K(he)||K(g)||Date.now()>=K(x)||!K(v)||K(v).picker&&K(O)!==K(fe)[K(T)]?.id)return;let e=K(b);R(b,``),R(g,!0);let n=++w;try{let r=await va(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:K(v).path}});n===w&&(R(_,r.message,!0),R(h,!1),R(v,null),R(y,null),f(),R(E,null),s()())}catch{n===w&&R(_,`Change unconfirmed. Check Codex before retrying.`)}finally{n===w&&R(g,!1)}}var Se={handleKey:ve},Ce=Mo(),we=z(Ce),Te=H(we,2),Ee=e=>{var t=co(),n=V(t,!0);U(()=>X(n,K(_))),Y(e,t)};Z(Te,e=>{K(_)&&!K(h)&&e(Ee)});var De=H(Te,2),Oe=e=>{var i=jo();let o;var s=z(i),c=e=>{var t=lo(),n=B(t),r=V(n,!0),i=V(H(n,2),!0);U(()=>{X(r,K(v)?.title||`/ COMMANDS`),X(i,K(v)?.help||`Loading live options…`)}),Y(e,t)};Z(s,e=>{K(ge)||e(c)});var l=H(s,2),u=e=>{var t=uo(),n=V(t,!0);U(()=>X(n,K(_))),Y(e,t)};Z(l,e=>{K(_)&&e(u)});var d=H(l,2),f=e=>{Y(e,fo())};Z(d,e=>{K(g)&&e(f)});var p=H(d,2),m=e=>{var t=po(),r=z(t),i=z(r),o=H(i);xi(o),P(r),P(t),U(e=>{Q(t,`id`,`${n}-input`),X(i,`${e??``} `),Q(o,`aria-label`,K(v).inputLabel||`Session name`),Q(o,`maxlength`,K(v).inputLimit||512),o.disabled=K(g)||K(he)&&!a()},[()=>(K(v).inputLabel||`Session name`).toUpperCase()]),xr(`submit`,t,e=>{e.preventDefault(),se()}),Ei(o,()=>K(C),e=>R(C,e)),Y(e,t)},h=e=>{var n=ho(),r=z(n),i=V(r,!0),a=H(r,2),o=V(a,!0),s=H(a,2),c=e=>{var n=mo(),r=z(n),i=H(r),a=e=>{Y(e,Mr(`Only this session's saved - name changes.`))},o=F(()=>K(v)?.path.startsWith(`rename/`)),s=e=>{Y(e,Mr(`Only this session’s - directory changes; project configuration is not reloaded.`))},c=F(()=>K(v)?.path.startsWith(`cd/`)),l=e=>{Y(e,Mr(`No change sent yet. Model, reasoning and speed settings can - change token usage and cost. Changes affect subsequent turns of - this session, not global defaults. Automatic quota thresholds - may later supersede model settings.`))};Z(i,e=>{K(o)?e(a):K(c)?e(s,1):e(l,-1)}),P(n),U(()=>X(r,`TARGET // ${t.session??``}. `)),Y(e,n)};Z(s,e=>{K(y).action&&e(c)}),P(n),Ii(n,e=>R(te,e),()=>K(te)),U(()=>{X(i,K(y).label),X(o,K(y).help||`No additional help supplied by Codex.`)}),Y(e,n)},w=e=>{var t=So(),i=B(t),a=e=>{var t=go(),i=z(t);r(i),P(t),Ii(t,e=>R(D,e),()=>K(D)),U(()=>Q(t,`aria-activedescendant`,`${n}-${K(T)}`)),Y(e,t)},o=e=>{var t=_o();let n;var i=z(t);r(i),P(t),Ii(t,e=>R(D,e),()=>K(D)),U(()=>n=ci(t,1,`command-options svelte-7bfwr9`,null,n,{vertical:K(ge)})),Y(e,t)};Z(i,e=>{K(A)?e(a):e(o,-1)});var s=H(i,2),c=e=>{var t=bo(),n=B(t),r=V(n,!0),i=H(n,2),a=e=>{var t=yo(),n=B(t),r=V(n),i=H(n,2),a=e=>{Y(e,vo())};Z(i,e=>{K(b)&&K(S)>=K(x)&&e(a)}),U(()=>X(r,`REVIEW // ${K(me).label??``}. No change sent yet.`)),Y(e,t)};Z(i,e=>{K(me)&&e(a)}),U(()=>X(r,K(fe)[K(T)]?.help)),Y(e,t)};Z(s,e=>{K(A)&&e(c)});var l=H(s,2),u=e=>{Y(e,xo())};Z(l,e=>{!K(g)&&!K(fe).length&&e(u)}),Y(e,t)};Z(p,e=>{K(v)?.input?e(m):K(y)?e(h,1):e(w,-1)});var E=H(p,2),O=e=>{var t=Co(),n=V(t,!0);U(()=>X(n,K(j).unavailable)),Y(e,t)};Z(E,e=>{K(j)?.unavailable&&e(O)});var ne=H(E,2),k=e=>{Y(e,wo())};Z(ne,e=>{K(b)&&K(S)>=K(x)&&!K(A)&&e(k)});var ie=H(ne,2),ae=z(ie),ce=e=>{var t=Nr(),r=B(t),i=e=>{var t=To(),r=V(t,!0);U(e=>{Q(t,`form`,`${n}-input`),t.disabled=e,X(r,K(v).reversibleInput||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)},[()=>K(g)||K(he)||!K(C).trim()]),Y(e,t)},o=e=>{var t=Nr(),n=B(t),r=e=>{var t=Eo();U(()=>t.disabled=K(g)||K(he)&&!a()),q(`click`,t,xe),Y(e,t)},i=e=>{var t=Do(),n=V(t,!0);U(()=>{t.disabled=K(g)||K(he)&&!a(),X(n,K(j).reversible||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)}),q(`click`,t,()=>{K(j)&&be(K(j))}),Y(e,t)};Z(n,e=>{K(pe)&&!K(j).reversible&&!$.data?.noConfirm?e(r):e(i,-1)}),Y(e,t)},s=e=>{var t=Do(),n=V(t);U(()=>{t.disabled=K(g)||K(he)&&!a(),X(n,`ENTER ${K(j).next?`OPEN`:`HELP`}`)}),q(`click`,t,()=>{K(j)&&ye(K(j))}),Y(e,t)};Z(r,e=>{K(v)?.input?e(i):K(j)?.action&&!K(j).unavailable?e(o,1):!K(y)&&K(j)&&!K(j).unavailable&&e(s,2)}),Y(e,t)};Z(ae,e=>{K(_)||e(ce)});var le=H(ae,2),ue=e=>{var t=Oo();U(()=>t.disabled=K(g)),q(`click`,t,oe),Y(e,t)};Z(le,e=>{K(re)&&e(ue)});var de=H(le,2),_e=e=>{var t=ko();U(()=>t.disabled=K(g)),q(`click`,t,()=>N(K(v)?.path||``,void 0,!0)),Y(e,t)};Z(de,e=>{K(ge)||e(_e)});var Se=H(de,2);P(ie);var Ce=H(ie,2),we=e=>{var t=Ao(),n=V(t);U(()=>X(n,`↑/↓ select${K(ge)?` · Tab complete`:``}`)),Y(e,t)};Z(Ce,e=>{!K(v)?.input&&!K(y)&&e(we)}),P(i),Ii(i,e=>R(ee,e),()=>K(ee)),U(()=>{Q(i,`aria-label`,K(ge)?`Slash command suggestions`:`Session command options`),o=ci(i,1,`svelte-7bfwr9`,null,o,{"command-popup":K(ge)})}),q(`keydown`,i,ve),q(`click`,Se,M),Y(e,i)};return Z(De,e=>{K(h)&&e(Oe)}),P(Ce),U(()=>we.disabled=K(he)&&!a()||K(g)),q(`click`,we,()=>{R(h,!K(h)),R(E,K(h)?null:i(),!0),R(b,``),K(h)?(R(ne,[],!0),N(``)):M()}),Y(e,Ce),We(Se)}Sr([`click`,`keydown`]);var Po=J(` `,1),Fo=J(`
`),Io=J(`
/
`);function Lo(e,t){Ue(t,!0);let n=F(()=>t.lines.filter(e=>e.kind===`addition`).length),r=F(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=Io(),a=z(i),o=z(a),s=V(o),c=V(H(o,2));P(a),Xr(H(a,2),17,()=>t.lines,Kr,(e,t)=>{var n=Fo();let r;var i=z(n),a=e=>{var n=Po(),r=B(n),i=V(r,!0),a=V(H(r),!0);U(()=>{X(i,K(t).old||``),X(a,K(t).new||``)}),Y(e,n)};Z(i,e=>{K(t).kind!==`heading`&&K(t).kind!==`metadata`&&e(a)});var o=V(H(i),!0);P(n),U(()=>{r=ci(n,1,`diff-line svelte-x4gtb6`,null,r,{added:K(t).kind===`addition`,removed:K(t).kind===`removal`,heading:K(t).kind===`heading`}),X(o,K(t).text)}),Y(e,n)}),P(i),U(()=>{Q(a,`aria-label`,`${K(n)} lines added, ${K(r)} lines removed`),X(s,`+${K(n)??``}`),X(c,`−${K(r)??``}`)}),Y(e,i),We()}var Ro=J(`

`),zo=J(`

Send this saved prompt now? This starts Codex work and consumes quota.

`,1),Bo=J(``),Vo=J(`

 

In memory only. Follows session model, reasoning and speed. Closing - Codexometer cancels pending work.

`),Ho=J(`

CURRENT PROFILE

MODEL / REASONING LEVEL / SPEED

 

PROPOSED PROFILE

MODEL / REASONING LEVEL / SPEED

 

Applied settings remain after Codexometer closes.

`,1),Uo=J(`

`),Wo=J(`

 
`,1),Go=J(`

Command unavailable from this observation. Open Codex to inspect the - request.

`),Ko=J(`

Session controls temporarily unavailable. Check Codex for current state.

`),qo=J(`

Checking session controls…

`),Jo=J(`

`),Yo=J(`
About browser controls

Controls require a supported live request from a connected shared - app-server session. Local observations alone cannot provide them.

`),Xo=J(` `,1),Zo=J(` `),Qo=J(`Grants permission beyond this one action. Check the scope - carefully.`),$o=J(``),es=J(``),ts=J(``),ns=J(``),rs=J(`

Not before this time; when quota and idle allow.

`),is=J(`

`,1),as=J(`

The existing trigger remains active until saved or deleted. If - it changes or sends while you edit, saving is blocked.

`),os=J(` `,1),ss=J(``),cs=J(``),ls=J(``),us=J(` `,1),ds=J(`
  • `),fs=J(`
    View fixed choices

    Type one of these choices exactly. Your answer stays masked.

      `),ps=J(` `,1),ms=J(`

      `),hs=J(`

      `,1),gs=J(` `,1),_s=J(``),vs=J(`

      `,1),ys=J(`

      `);function bs(e,t){Ue(t,!0);let n=[],r=Wi(t,`observedCommand`,3,``),i=Wi(t,`observedFileChanges`,19,()=>[]),a=Wi(t,`review`,3,``),o=Wi(t,`suspended`,3,!1),s=Wi(t,`openScheduler`,3,!1),c=Wi(t,`onProtectedChange`,3,e=>{}),l=Wi(t,`oncopy`,3,()=>{}),u=L(null),d=L(Yt([])),f=L(null),p=L(``),m=L(0),h=L(Yt(Date.now())),g=L(!1),_=L(``),v=L(!1),y=L(!1),b=L(``),x=L(!1),S=L(``),C=L(!1),w=L(``),T=L(`now`),E=L(60),D=L(``),ee=L(!1),te=L(``),O=L(Yt([])),ne=F(()=>K(O).find(e=>e.status!==`sent`)),k=L(void 0),re=L(void 0);function ie(e){if(K(x)){lr().then(()=>K(k)?.focus());return}if(e.status!==`pending`||K(g)||!K(u)?.id||K(u).kind!==`prompt`||K(u).questions?.length)return;R(x,!0),R(S,e.id,!0),lr().then(()=>K(k)?.focus()),R(d,[e.text],!0),R(T,e.trigger===`quota`?`quota`:`at`,!0),R(p,``),R(w,``);let t=new Date(e.at);e.trigger!==`quota`&&R(D,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}vn(()=>{s()&&K(ne)&&!K(C)&&K(u)?.id&&K(u).kind===`prompt`&&!K(u).questions?.length&&(R(C,!0),ie(K(ne)))});async function ae(){if(!a())try{R(O,await va(`schedules`,{session:t.session},M.signal),!0),K(x)&&!K(O).some(e=>e.id===K(S)&&e.status===`pending`)&&R(p,``),K(w)&&!K(O).some(e=>e.id===K(w)&&e.status===`pending`)&&(R(p,``),R(w,``))}catch{}}async function oe(e){try{R(O,await va(`schedules`,{session:t.session,cancelId:e},M.signal),!0),R(x,!1),R(p,``),R(w,``),R(d,[],!0)}catch(e){R(_,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}vn(()=>(c()(K(g)||K(d).some(e=>e.length>0)),()=>c()(!1)));let se=F(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),A=F(()=>!$.connected||!!$.data?.sessionsError),ce=F(()=>a()!==`profile`&&K(u)?.kind===`prompt`&&!K(u).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),le=F(()=>!K(A)&&!K(y)&&!!K(u)?.id&&K(u).kind===`approval`&&K(b)!==K(u).id),ue=F(()=>K(le)?K(u).command:r()),de=F(()=>!!K(p)&&K(h)K(u)?.questions?.length?K(u).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),j=F(()=>K(u)?.kind===`approval`||K(u)?.kind===`profile`?K(f)!==null:K(d).length===K(fe).length&&K(d).every((e,t)=>e.trim().length>0&&(K(fe)[t].freeText||K(fe)[t].options?.includes(e)))),pe=F(()=>K(u)?.kind===`prompt`&&!K(u).questions?.length&&K(T)!==`now`),me=F(()=>K(T)===`delay`?K(h)+K(E)*6e4:Date.parse(K(D))),he=F(()=>{if(!K(pe))return``;if(K(x)&&!K(O).some(e=>e.id===K(S)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!K(d)[0]?.trim())return`Enter a message to schedule.`;if(K(T)===`quota`)return``;if(!Number.isFinite(K(me))||K(me)<=K(h))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(K(h));return e.setFullYear(e.getFullYear()+1),K(me)>=e.getTime()?`Choose a time within one year.`:``});function ge(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function _e(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>K(h))return`Due in `+Math.ceil((Date.parse(e.at)-K(h))/6e4)+` min`;let t=K(A)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}vn(()=>{(K(A)||o()||K(ce)||K(h)>=K(m))&&R(p,``)});let M=new AbortController;Gi(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&K(ne)&&(e.preventDefault(),ie(K(ne)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{R(h,Date.now(),!0)},1e3);async function i(){await ae();try{let e=await va(`offer`,{session:t.session,...a()?{review:a()}:{}},M.signal);if(M.signal.aborted)return;R(y,!1),K(u)?.id!==e.id&&(R(p,``),R(f,null),R(d,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),R(u,e,!0),K(v)&&e.id&&e.id!==K(b)&&(R(_,``),R(v,!1))}catch{M.signal.aborted||(R(u,null),R(y,!0),R(p,``))}finally{M.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),M.abort(),clearTimeout(n),clearInterval(r)}});async function ve(e){if(!e&&K(u)?.kind===`prompt`&&!K(u).questions?.length&&K(d)[0]?.trim().startsWith(`/`)&&!K(d)[0]?.trim().startsWith(`//`)){R(_,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!K(u)?.id||K(g)||K(A)||o()||K(ce)||(e?!e.canSend:!K(j)||K(he)))return;let n=K(u).id;R(g,!0),R(_,``),R(v,!1),R(p,``),R(w,e?.id||``,!0);try{let r=!e&&K(u).kind===`prompt`&&!K(u).questions?.length&&K(T)!==`now`?{trigger:K(T)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...K(T)===`quota`?{}:{at:(K(T)===`delay`?new Date(Date.now()+K(E)*6e4):new Date(K(D))).toISOString()}}:void 0;R(ee,!!r),R(te,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:ge(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await va(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&K(x)?{editId:K(S)}:{},...K(u).kind===`approval`||K(u).kind===`profile`?{choice:K(f)}:{answers:e?[e.text]:[...K(d)]}},M.signal);K(u)?.id!==n||M.signal.aborted||K(A)||o()||K(ce)||(R(p,i.confirmation,!0),R(m,Date.parse(i.expires),!0))}catch(e){M.signal.aborted||R(_,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{R(g,!1)}$.data?.noConfirm&&K(p)&&!M.signal.aborted&&await N()}async function N(){if(!K(u)?.id||K(g)||o()||K(ce)||!K(de))return;let e=K(u).id,n=K(u).kind,r=K(p);R(p,``),R(g,!0),R(b,e,!0);try{await va(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},M.signal),R(v,!0),R(x,!1),K(ee)&&(R(b,``),await ae()),R(_,K(ee)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){R(_,e instanceof ga?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{R(g,!1),R(w,``),await ae(),R(d,[],!0),R(f,null)}}var ye=Xo(),be=B(ye),Se=e=>{var t=Nr();Xr(B(t),17,()=>K(O).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Vo(),r=z(n),i=V(r,!0),a=H(r,2),s=V(a),c=H(a,2),l=V(c,!0),d=H(c,2),f=V(d,!0),m=H(d,2),h=V(m,!0),v=H(m,2),y=e=>{var t=Ro(),n=V(t,!0);U(()=>X(n,K(_))),Y(e,t)};Z(v,e=>{K(_)&&e(y)});var b=H(v,4),x=H(b,2),S=H(x,2),C=e=>{var n=zo(),r=H(B(n),2),i=H(r,2);U(()=>r.disabled=K(g)||K(A)||!K(t).canSend),q(`click`,r,N),q(`click`,i,()=>{R(p,``),R(w,``)}),Y(e,n)},T=e=>{var n=Bo();U(()=>n.disabled=K(g)||K(A)||!K(t).canSend||o()),q(`click`,n,()=>ve(K(t))),Y(e,n)};Z(S,e=>{K(de)&&K(w)===K(t).id?e(C):e(T,-1)}),P(n),U((e,n)=>{X(i,K(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),X(s,`TARGET // ${K(t).session??``}`),X(l,e),X(f,n),X(h,K(t).text),b.disabled=K(g)||!K(u)?.id||K(u).kind!==`prompt`||!!K(u).questions?.length||K(t).status!==`pending`,x.disabled=K(g)||K(t).status===`sending`},[()=>K(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${ge(K(t).at)}`,()=>_e(K(t))]),q(`click`,b,()=>ie(K(t))),q(`click`,x,()=>oe(K(t).id)),Y(e,n)}),Y(e,t)},Ce=F(()=>!a()&&K(u)?.kind!==`approval`&&!K(u)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(K(se)||``));Z(be,e=>{K(Ce)&&e(Se)});var we=H(be,2),Te=e=>{var r=ys(),o=z(r),s=V(o,!0),c=H(o,2),S=e=>{var t=Ho(),n=B(t),r=V(n),i=H(n,6),a=V(i,!0),o=V(H(i,6),!0);xe(2),U(()=>{X(r,`Your ${K(u).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),X(a,K(u).profile.current),X(o,K(u).profile.proposed)}),Y(e,t)};Z(c,e=>{K(u)?.profile&&!K(A)&&!K(y)&&e(S)});var C=H(c,2),w=e=>{var t=Uo();let n;var r=V(t,!0);U(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!K(v),sent:K(v)}),X(r,K(_))}),Y(e,t)};Z(C,e=>{K(_)&&e(w)});var O=H(C,2),ne=e=>{Lo(e,{get lines(){return K(u).fileChanges}})},ie=e=>{Lo(e,{get lines(){return i()}})},ae=e=>{var t=Wo(),n=B(t),r=V(n,!0),i=V(H(n,2),!0);U(()=>{X(r,K(le)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),X(i,K(ue))}),Y(e,t)},oe=e=>{Y(e,Go())};Z(O,e=>{K(u)?.fileChanges?.length&&!K(A)&&!K(y)?e(ne):i().length?e(ie,1):K(ue)?e(ae,2):a()!==`profile`&&K(se)===`APPROVAL NEEDED`&&!K(v)&&e(oe,3)});var ce=H(O,2),pe=e=>{Y(e,Ko())},_e=e=>{Y(e,qo())},M=e=>{var t=Xo(),n=B(t),r=e=>{var t=Jo(),n=V(t,!0);U(e=>X(n,e),[()=>K(se)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(K(se)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),Y(e,t)};Z(n,e=>{(K(se)===`WORKING`||!K(v)&&!K(g))&&e(r)});var i=H(n,2),a=e=>{Y(e,Yo())},o=F(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(K(se)||``)&&!K(v));Z(i,e=>{K(o)&&e(a)}),Y(e,t)},ye=e=>{var r=vs(),i=B(r),o=V(i),s=H(i,2),c=z(s),_=V(c,!0),v=H(c,2),y=e=>{var r=Nr();Xr(B(r),17,()=>K(u).choices||[],Kr,(e,r,i)=>{var o=$o(),s=z(o);xi(s),s.value=s.__value=i;var c=H(s),l=H(c),u=e=>{var t=Zo(),n=V(t,!0);U(()=>X(n,K(r).detail)),Y(e,t)};Z(l,e=>{K(r).detail&&e(u)});var d=H(l,2),p=e=>{Y(e,Qo())};Z(d,e=>{K(r).persistent&&e(p)}),P(o),U(()=>{Q(s,`name`,`decision-`+t.session+`-`+a()),X(c,` ${K(r).label??``} `)}),Oi(n,[],s,()=>K(f),e=>R(f,e)),Y(e,o)}),Y(e,r)},b=e=>{var n=Xo(),r=B(n),i=e=>{var t=os(),n=B(t),r=H(z(n)),i=z(r),a=e=>{var t=es();t.value=t.__value=`now`,Y(e,t)};Z(i,e=>{K(x)||e(a)});var o=H(i);o.value=o.__value=`quota`;var s=H(o);s.value=s.__value=`delay`;var c=H(s);c.value=c.__value=`at`,P(r),mi(r),P(n);var l=H(n,2),u=e=>{var t=ts(),n=H(z(t));xi(n),P(t),Ei(n,()=>K(E),e=>R(E,e)),Y(e,t)};Z(l,e=>{K(T)===`delay`&&e(u)});var d=H(l,2),f=e=>{var t=ns(),n=H(z(t));xi(n),P(t),Ei(n,()=>K(D),e=>R(D,e)),Y(e,t)};Z(d,e=>{K(T)===`at`&&e(f)});var p=H(d,2),m=e=>{var t=is(),n=B(t),r=V(n),i=H(n,2),a=e=>{Y(e,rs())};Z(i,e=>{K(T)!==`quota`&&e(a)});var o=H(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. - One pending request per session; saving replaces it. Memory - only; Codexometer must stay running. Uses session model, - reasoning and speed.`,U(e=>X(r,`Will send: ${e??``}`),[()=>K(T)===`quota`?`when quota is available and this session is idle`:Number.isFinite(K(me))?ge(K(me)):`choose a date and time`]),Y(e,t)};Z(p,e=>{K(T)!==`now`&&e(m)});var h=H(p,2),g=e=>{Y(e,as())};Z(h,e=>{K(x)&&e(g)}),hi(r,()=>K(T),e=>R(T,e)),Y(e,t)};Z(r,e=>{K(u).questions?.length||e(i)}),Xr(H(r,2),17,()=>K(fe),Kr,(e,n,r)=>{var i=ps(),o=B(i),s=e=>{{let n=F(()=>K(d)[0]||``);Ii(No(e,{get session(){return t.session},get oncopy(){return l()},get query(){return K(n)},oncomplete:e=>{R(d,[e],!0),lr().then(()=>K(k)?.focus())},onchange:()=>{R(d,[``],!0),lr().then(()=>K(k)?.focus())}}),e=>R(re,e,!0),()=>K(re))}};Z(o,e=>{r===0&&a()!==`profile`&&K(u).kind===`prompt`&&!K(u).questions?.length&&e(s)});var c=H(o,2),f=z(c),p=H(f),m=e=>{var t=ss();xi(t),Ei(t,()=>K(d)[r],e=>K(d)[r]=e),Y(e,t)},h=e=>{var t=ls(),i=z(t);i.value=i.__value=``,Xr(H(i),17,()=>K(n).options||[],Kr,(e,t)=>{var n=cs(),r=V(n,!0),i={};U(()=>{X(r,K(t)),i!==(i=K(t))&&(n.value=(n.__value=i)??``)}),Y(e,n)}),P(t),mi(t),hi(t,()=>K(d)[r],e=>K(d)[r]=e),Y(e,t)},g=e=>{var t=us(),i=B(t);tt(i),Ii(i,e=>R(k,e),()=>K(k));var a=H(i,2),o=e=>{var t=Jo(),r=V(t);U(e=>X(r,`Suggested answers: ${e??``}`),[()=>K(n).options.join(` · `)]),Y(e,t)};Z(a,e=>{K(n).options?.length&&e(o)}),q(`keydown`,i,e=>{K(u)?.kind===`prompt`&&!K(u).questions?.length&&K(re)?.handleKey(e)}),Ei(i,()=>K(d)[r],e=>K(d)[r]=e),Y(e,t)};Z(p,e=>{K(n).secret?e(m):K(n).freeText?e(g,-1):e(h,1)}),P(c);var _=H(c,2),v=e=>{var t=fs(),r=H(z(t),4);Xr(r,21,()=>K(n).options||[],Kr,(e,t)=>{var n=ds(),r=V(n,!0);U(()=>X(r,K(t))),Y(e,n)}),P(r),P(t),Y(e,t)};Z(_,e=>{K(n).secret&&!K(n).freeText&&e(v)}),U(()=>X(f,`${K(n).text??``} `)),Y(e,i)}),Y(e,n)};Z(v,e=>{K(u).kind===`approval`||K(u).kind===`profile`?e(y):e(b,-1)}),P(s);var S=H(s,2),C=e=>{var t=hs(),n=B(t),r=e=>{var t=ms(),n=V(t);U(()=>X(n,`TRIGGER // ${K(te)??``}`)),Y(e,t)};Z(n,e=>{K(ee)&&e(r)});var i=H(n,2),a=V(i),o=H(i,2),s=V(o),c=H(o,2);U(e=>{X(a,`Check the target and ${K(u).kind===`profile`?`profile above`:K(u).kind===`approval`?K(u).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${K(ee)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. - Confirmation expires in ${e??``}s.`),o.disabled=K(g)||K(A),X(s,`CONFIRM ${(K(u).kind===`approval`||K(u).kind===`profile`?K(u).choices?.[K(f)]?.label:K(ee)?K(x)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((K(m)-K(h))/1e3))]),q(`click`,o,N),q(`click`,c,()=>{R(p,``)}),Y(e,t)},w=e=>{var t=gs(),n=B(t),r=e=>{var t=Ro(),n=V(t,!0);U(()=>X(n,K(he))),Y(e,t)};Z(n,e=>{K(he)&&e(r)});var i=H(n,2),a=V(i,!0);U(()=>{i.disabled=K(g)||K(A)||!K(j)||!!K(he),X(a,K(g)?`SENDING…`:$.data?.noConfirm?K(x)?`SAVE CHANGES`:K(u).kind===`approval`||K(u).kind===`profile`?`SEND DECISION`:K(u).kind===`prompt`&&!K(u).questions?.length&&K(T)!==`now`?`SET TRIGGER`:`SEND`:K(x)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),q(`click`,i,()=>ve()),Y(e,t)};Z(S,e=>{K(de)&&!$.data?.noConfirm?e(C):e(w,-1)});var O=H(S,2),ne=e=>{var t=_s();q(`click`,t,()=>{R(x,!1),R(p,``),R(d,[],!0)}),Y(e,t)};Z(O,e=>{K(x)&&e(ne)}),U(()=>{X(o,`TARGET // ${K(u).thread??``} // ${(K(u).directory||`Directory unavailable`)??``}`),s.disabled=K(g)||K(de)||K(A),X(_,K(u).kind===`approval`||K(u).kind===`profile`?`Choose a decision`:K(x)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),Y(e,r)};Z(ce,e=>{K(A)||K(y)?e(pe):K(u)?K(u).id?K(b)!==K(u).id&&e(ye,3):e(M,2):e(_e,1)}),P(r),U(()=>X(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),Y(e,r)};Z(we,e=>{!K(ce)&&(!K(ne)||K(x)||a()||K(u)?.kind!==`prompt`||K(u).questions?.length)&&e(Te)}),Y(e,ye),We()}Sr([`click`,`keydown`]);var xs=J(` `,1),Ss=J(`
      `),Cs=J(`

      STATUS LINE // CODEXOMETER

      Choose multiple fields and their order. These display preferences do not - change Codex CLI configuration. Missing values are omitted.

      `),ws=J(`

      `,1);function Ts(e,t){Ue(t,!0);let n=Wi(t,`stale`,3,!1),r=L(Yt([])),i=L(!1),a=F(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??K(a).filter(e=>e.default).map(e=>e.id))].filter(e=>K(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=F(()=>[...K(r).map(e=>K(a).find(t=>t.id===e)).filter(Boolean),...K(a).filter(e=>!K(r).includes(e.id))]);vn(()=>{oa.open&&!K(i)?(R(r,o(aa.statusLine),!0),R(i,!0)):oa.open||R(i,!1)});function l(e,t){R(r,t?[...K(r),e]:K(r).filter(t=>t!==e),!0)}function u(e,t){let n=K(r).indexOf(e),i=n+t;if(n<0||i<0||i>=K(r).length)return;let a=[...K(r)];[a[n],a[i]]=[a[i],a[n]],R(r,a,!0)}var d=ws(),f=B(d),p=e=>{var t=Cs(),n=H(z(t),4);Xr(n,21,()=>K(c),e=>e.id,(e,t)=>{var n=Ss(),i=z(n),a=z(i);xi(a);var o=H(a,1,!0),s=V(H(o),!0);P(i);var c=H(i,2),d=e=>{var n=xs(),i=B(n),a=H(i,2);U((e,n)=>{Q(i,`aria-label`,`Move `+K(t).label+` earlier`),i.disabled=e,Q(a,`aria-label`,`Move `+K(t).label+` later`),a.disabled=n},[()=>K(r).indexOf(K(t).id)===0,()=>K(r).indexOf(K(t).id)===K(r).length-1]),q(`click`,i,()=>u(K(t).id,-1)),q(`click`,a,()=>u(K(t).id,1)),Y(e,n)},f=F(()=>K(r).includes(K(t).id));Z(c,e=>{K(f)&&e(d)}),P(n),U(e=>{Q(i,`title`,K(t).help),Si(a,e),X(o,K(t).label),X(s,K(t).help)},[()=>K(r).includes(K(t).id)]),q(`change`,a,e=>l(K(t).id,e.currentTarget.checked)),Y(e,n)}),P(n);var i=H(n,2),a=V(i),o=H(i,2),d=H(o,2);P(t),U(e=>X(a,`Preview // ${e??``}`),[()=>s(K(r))||`—`]),q(`click`,o,()=>{aa.statusLine=[...K(r)],ca(),oa.open=!1}),q(`click`,d,()=>{oa.open=!1}),Y(e,t)};Z(f,e=>{oa.open&&e(p)});var m=H(f,2),h=z(m),g=V(h,!0),_=H(h,2);P(m),U((e,t)=>{Q(h,`title`,e),X(g,t)},[()=>s(aa.statusLine),()=>s(aa.statusLine)]),q(`click`,_,()=>{oa.open=!oa.open}),Y(e,d),We()}Sr([`change`,`click`]);var Es=J(`
      `);function Ds(e,t){Ue(t,!0);let n=Wi(t,`active`,3,!1),r=F(()=>ao(t.session)),i=F(()=>!!K(r)),a=L(!1),o=L(``),s=L(!1);vn(()=>{if(!K(s))return;let e=setTimeout(()=>{R(s,!1)},150);return()=>clearTimeout(e)}),vn(()=>{K(r),t.session.status,R(o,``)});async function c(){if(!K(i)||K(a))return;let e=K(r);R(a,!0),R(s,!0),R(o,``);try{await navigator.clipboard.writeText(e),K(r)===e&&R(o,`Copied.`)}catch{K(r)===e&&R(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{R(a,!1)}}function l(e){!n()||!K(i)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),c())}var u={copy:c},d=Nr();xr(`keydown`,Qt,l);var f=B(d),p=e=>{var t=Es(),n=z(t),r=V(n,!0),i=H(n,2);let l;P(t),U(()=>{X(r,K(o)),i.disabled=K(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:K(s)})}),q(`click`,i,c),Y(e,t)};return Z(f,e=>{K(i)&&e(p)}),Y(e,d),We(u)}Sr([`click`]);var Os=J(`

       
      `,1),ks=J(`

      LATEST GUIDANCE

       
      `,1),As=J(`

      CONTEXT

       

      `,1),js=J(`

      `),Ms=J(`

      `),Ns=J(`
       
      `),Ps=J(`

       
      `,1),Fs=J(`
       
      `),Is=J(`

      Command unavailable from this observation. Open Codex to inspect the - request.

      `),Ls=J(`

      `,1),Rs=J(`

      `),zs=J(` `,1),Bs=J(`
      `),Vs=J(`

      Session connection or refresh unavailable. Context and telemetry may be - stale.

      `),Hs=J(`

      Some quota profile checks are unavailable. Only sessions with freshly - verified quota and settings can be updated; previous outcome notices remain - visible.

      `),Us=J(` `),Ws=J(` `),Gs=J(` `),Ks=J(``),qs=J(`

      Read only — reply or approve in Codex.

      `),Js=J(`

      `),Ys=J(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Xs=J(`
      `),Zs=J(`
      `),Qs=J(`

      This session is no longer in the current observation. Return to sessions.

      `),$s=J(`

      `),ec=J(``),tc=J(`

      `),nc=J(` `),rc=J(`

      `),ic=J(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),ac=J(` `,1),oc=J(`

      `),sc=J(`

      TOKEN ACTIVITY // 30 SECOND SAMPLES

      `),cc=J(`

      TOKENS

      FULL DETAIL →
      `),lc=J(`

      No locally observed sessions yet. Keep Codex running alongside - Codexometer.

      `),uc=J(`

      ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

      `,1),dc=J(`

      SESSION TOTALS

      `,1);function fc(e,t){Ue(t,!0);let n=(e,t=f,n,r)=>{let i=pt(()=>g(n?.(),!0)),a=pt(()=>g(r?.(),!1));var o=zs(),s=B(o),c=e=>{var n=Os(),r=B(n),i=V(r,!0),a=V(H(r,2),!0);U(()=>{X(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),X(a,t().currentTask)}),Y(e,n)};Z(s,e=>{t().currentTask&&e(c)});var l=H(s,2),u=e=>{var n=ks(),r=V(H(B(n),2),!0);U(()=>X(r,t().latestGuidance)),Y(e,n)};Z(l,e=>{t().latestGuidance&&e(u)});var d=H(l,2),p=e=>{var n=As(),r=V(H(B(n),2),!0);xe(2),U(()=>X(r,t().approvalContext)),Y(e,n)};Z(d,e=>{K(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=H(d,2),h=e=>{var n=js();let r;var i=V(n,!0);U(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),X(i,e)},[()=>D(t())]),Y(e,n)},_=F(()=>D(t())&&(!K(a)||K(v)||t().status===`CHECK SESSION`||y(t())));Z(m,e=>{K(_)&&e(h)});var b=H(m,2),x=e=>{var n=Ms(),r=V(n,!0);U(e=>X(r,e),[()=>ee(t())]),Y(e,n)};Z(b,e=>{K(i)&&e(x)});var S=H(b,2),C=e=>{var n=Ns(),r=V(n,!0);U(()=>X(r,t().text||`No session context available.`)),Y(e,n)};Z(S,e=>{(t().text||!t().workingCommand)&&e(C)});var w=H(S,2),T=e=>{var n=Ps(),r=H(B(n),2),i=z(r),a=H(i),o=e=>{var n=Mr();U(()=>X(n,`// ${t().commandTiming??``}`)),Y(e,n)};Z(a,e=>{t().commandTiming&&e(o)});var s=H(a,2),c=e=>{var n=Mr();U(()=>X(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),Y(e,n)};Z(s,e=>{!K(v)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(c)});var l=H(s,2),u=e=>{Y(e,Mr(`+`))};Z(l,e=>{t().runningLimited&&e(u)}),P(r);var d=V(H(r,2),!0);U(e=>{X(i,`COMMAND // ${e??``} `),X(d,t().workingCommand)},[()=>K(v)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),Y(e,n)};Z(w,e=>{t().workingCommand&&e(T)});var E=H(w,2),te=e=>{Lo(e,{get lines(){return t().fileChanges}})},O=e=>{var n=Ls(),r=H(B(n),2),i=V(r,!0),a=H(r,2),o=e=>{var n=Fs(),r=V(n,!0);U(()=>X(r,t().command)),Y(e,n)},s=e=>{Y(e,Is())};Z(a,e=>{t().command?e(o):e(s,-1)}),U(()=>X(i,K(v)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),Y(e,n)};Z(E,e=>{(!K(a)||!$.data?.control)&&t().fileChanges?.length?e(te):K(a)&&$.data?.control||!t().command&&t().status!==`APPROVAL NEEDED`||e(O,1)});var ne=H(E,2),k=e=>{var n=Rs(),r=V(n);U(()=>X(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),Y(e,n)};Z(ne,e=>{K(a)||e(k)}),Y(e,o)},r=L(void 0),i=Wi(t,`params`,19,()=>({})),a=F(()=>$.data?.sessions||[]),o=F(()=>$.data?.control&&$.data.profiles||[]),s=F(()=>($.data?.triggers||[]).filter(e=>K(a).some(t=>t.id===e.session)));function c(e,t){i().id&&i().id!==t&&K(u)?e.preventDefault():w(t)}function l(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&K(s).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let u=L(!1);function d(e,t){i().id&&i().id!==t&&K(u)?e.preventDefault():w(t)}vn(()=>{let e=i().id;e&&fr(()=>{aa.selected=e,fa(e,2)})});let p=F(()=>K(a).find(e=>e.id===i().id)),m=F(()=>new URLSearchParams(Yi.querystring).get(`review`)===`profile`&&K(o).some(e=>e.session===i().id&&e.pending)),h=F(()=>K(a).some(e=>e.id===aa.selected)?aa.selected:K(a)[0]?.id),v=F(()=>!$.connected||!!$.data?.sessionsError);function y(e){return e.status!==`STALE`&&e.failed===!0}let b=F(()=>[[`OBSERVED TOKENS`,pa(K(a).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,pa(K(a).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`ERRORS`,`ERRORS`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,K(v)?`—`:pa(K(a).filter(e=>t===`ERRORS`?y(e):e.status===t).length)])]),x=F(()=>K(a).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`].includes(e.status)||y(e)).sort((e,t)=>S(e)-S(t)));function S(e){return e.status===`APPROVAL NEEDED`?0:e.status===`INPUT NEEDED`?1:2}let C=F(()=>K(a).filter(e=>e.status===`TURN COMPLETE`&&!K(s).some(t=>t.session===e.id)&&!K(o).some(t=>t.session===e.id&&t.pending)));function w(e){aa.selected=e,lr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function T(e,t){if(w(e),i().id){t<0&&(fa(e,2),location.hash=`/sessions`);return}let n=ua(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):fa(e,n)}function E(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&i().id)e.preventDefault(),T(i().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(i().id||K(h)))e.preventDefault(),T(i().id||K(h),e.key===`ArrowLeft`?-1:1);else if(!i().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&K(a).length){e.preventDefault();let t=K(a).findIndex(e=>e.id===K(h));w(K(a)[Math.max(0,Math.min(K(a).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function D(e){return K(v)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:y(e)?e.status===`MODEL BUSY`?`CONFIRMED TURN FAILURE — the selected model was at capacity. Choose another model with /model or retry when ready. This is not a quota-exhaustion signal.`:e.status===`MODEL UNAVAILABLE`?`CONFIRMED TURN FAILURE — the provider could not find the selected model. Choose an available model with /model. No automatic retry or model change.`:e.status===`CAPACITY RESTRICTED`?`CONFIRMED TURN FAILURE — capacity is unavailable on a policy-restricted route. Inspect the error before changing settings or retrying. This is not a quota-exhaustion signal; no automatic retry or policy change.`:`CONFIRMED TURN FAILURE — inspect the error below before sending another prompt. No automatic retry or model change.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function ee(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var te=dc();xr(`keydown`,Qt,E);var O=B(te),ne=V(H(z(O),2));P(O);var k=H(O,2);let re;Xr(k,21,()=>K(b),Kr,(e,t)=>{var n=F(()=>_(K(t),2));let r=()=>K(n)[0],i=()=>K(n)[1];var a=Bs();let o;var s=z(a),c=V(s,!0),l=V(H(s,2),!0);P(a),U(()=>{o=ci(a,1,`svelte-mm4wfe`,null,o,{failed:r()===`ERRORS`&&i()!==`0`&&i()!==`—`}),X(c,r()),X(l,i())}),Y(e,a)}),P(k);var ie=H(k,2),ae=V(ie),oe=H(ie,2),se=e=>{Y(e,Vs())};Z(oe,e=>{K(v)&&e(se)});var A=H(oe,2),ce=e=>{Y(e,Hs())};Z(A,e=>{$.data?.profileError&&e(ce)});var le=H(A,2),ue=e=>{var t=Ks(),n=z(t);Xr(n,17,()=>K(x),Kr,(e,t)=>{var n=Us();let r;var i=V(n);U((e,a,o)=>{r=ci(n,1,`button`,null,r,{approval:e}),Q(n,`href`,a),X(i,`${K(t).status??``} - ${o??``} // ${(K(t).name||K(t).directory||K(t).id)??``}`)},[()=>K(t).status===`APPROVAL NEEDED`||K(t).status===`INPUT NEEDED`||y(K(t)),()=>`#/sessions/`+encodeURIComponent(K(t).id),()=>Array.from(K(t).id).slice(-5).join(``).toUpperCase()]),q(`click`,n,()=>w(K(t).id)),Y(e,n)});var r=H(n,2);Xr(r,17,()=>K(o).filter(e=>e.pending&&K(a).some(t=>t.id===e.session)),Kr,(e,t)=>{var n=Ws(),r=V(n);U((e,a,o)=>{Q(n,`title`,i().id&&i().id!==K(t).session&&K(u)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),X(r,`QUOTA THRESHOLD ${a??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(K(t).session)+`?review=profile`,()=>Array.from(K(t).session).slice(-5).join(``).toUpperCase(),()=>K(a).find(e=>e.id===K(t).session)?.name||K(a).find(e=>e.id===K(t).session)?.directory||K(t).session]),q(`click`,n,e=>d(e,K(t).session)),Y(e,n)});var l=H(r,2);Xr(l,17,()=>K(C),Kr,(e,t)=>{var n=Gs(),r=V(n);U((e,i)=>{Q(n,`href`,e),X(r,`TURN COMPLETE ${i??``} // - ${(K(t).name||K(t).directory||K(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(K(t).id),()=>Array.from(K(t).id).slice(-5).join(``).toUpperCase()]),q(`click`,n,()=>w(K(t).id)),Y(e,n)}),Xr(H(l,2),17,()=>K(s),Kr,(e,t)=>{var n=Gs(),r=V(n);U((e,t,i)=>{Q(n,`href`,e),X(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(K(t).session),()=>Array.from(K(t).session).slice(-5).join(``).toUpperCase(),()=>K(a).find(e=>e.id===K(t).session)?.name||K(a).find(e=>e.id===K(t).session)?.directory]),q(`click`,n,e=>c(e,K(t).session)),Y(e,n)}),P(t),Y(e,t)},de=F(()=>(K(x).length||K(C).length||K(o).some(e=>e.pending)||K(s).length)&&!K(v));Z(le,e=>{K(de)&&e(ue)});var fe=H(le,2),j=e=>{var t=Nr(),a=B(t),s=e=>{var t=Zs(),a=z(t),s=z(a);let c;var d=z(s);let f;var h=H(d);P(s);var g=H(s,2);P(a);var _=H(a,2),b=e=>{var t=Rs(),n=V(t,!0);U(()=>X(n,K(p).directory)),Y(e,t)};Z(_,e=>{K(p).name&&K(p).directory&&e(b)});var x=H(_,2),S=V(x),C=H(x,2);let T;var E=z(C),D=z(E);n(D,()=>K(p),()=>!0,()=>!0),P(E);var ee=H(E,2),te=e=>{var t=Nr();Gr(B(t),()=>K(p).id,e=>{{let t=F(()=>new URLSearchParams(Yi.querystring).get(`schedule`)===`edit`),n=F(()=>K(p).fileChanges||[]);bs(e,{get session(){return K(p).id},oncopy:()=>K(r)?.copy(),get openScheduler(){return K(t)},get observedCommand(){return K(p).command},get observedFileChanges(){return K(n)},get suspended(){return K(m)},onProtectedChange:e=>{R(u,e,!0)}})}}),Y(e,t)},O=e=>{var t=qs();Gr(H(z(t),2),()=>K(p).id,e=>{No(e,{get session(){return K(p).id},localOnly:!0,oncopy:()=>K(r)?.copy()})}),P(t),Y(e,t)};Z(ee,e=>{$.data?.control?e(te):e(O,-1)}),P(C);var ne=H(C,2);Xr(ne,17,()=>K(o).filter(e=>e.session===K(p).id),e=>e.session,(e,t)=>{var n=Xs(),r=z(n),i=e=>{var n=Js(),r=V(n,!0);U(()=>X(r,K(t).notice)),Y(e,n)};Z(r,e=>{K(t).notice&&e(i)});var a=H(r,2),o=e=>{bs(e,{get session(){return K(p).id},review:`profile`})},s=e=>{var t=Ys();U(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(K(p).id)+`?review=profile`]),Y(e,t)};Z(a,e=>{K(t).pending&&K(m)?e(o):K(t).pending&&e(s,1)}),P(n),U(()=>Q(n,`id`,`quota-profile-`+K(p).id)),Y(e,n)});var k=H(ne,2),re=e=>{var t=Nr();Gr(B(t),()=>K(p).id,e=>{Ii(Ds(e,{get session(){return K(p)},active:!0}),e=>R(r,e,!0),()=>K(r))}),Y(e,t)};Z(k,e=>{K(m)||e(re)}),Gr(H(k,2),()=>K(p).id,e=>{Ts(e,{get session(){return K(p)},get stale(){return K(v)}})}),P(t),U((e,t,n,r)=>{c=ci(s,1,`svelte-mm4wfe`,null,c,{failed:e}),f=ci(d,1,`lamp lit svelte-mm4wfe`,null,f,{failed:t,working:K(p).status===`WORKING`&&!K(v)}),X(h,`${n??``} // ${(K(p).name||K(p).directory)??``}`),X(S,`${r??``} TOKENS // ${K(p).id??``} // CONTEXT SOURCE // ${(K(p).source||`LOCAL`)??``}`),T=ui(C,``,T,{display:K(m)?`none`:void 0})},[()=>y(K(p))&&!K(v)&&!K(m),()=>y(K(p))&&!K(v),()=>K(v)?`STALE`:K(m)?`QUOTA THRESHOLD`:l(K(p)),()=>pa(K(p).tokens)]),q(`click`,g,()=>{w(i().id),fa(i().id,2)}),Y(e,t)},c=e=>{Y(e,Qs())};Z(a,e=>{K(p)?e(s):e(c,-1)}),Y(e,t)},pe=e=>{var t=uc(),r=B(t),i=H(z(r),2),s=z(i),c=H(s,2);P(i),P(r);var u=H(r,2);Xr(u,17,()=>K(a),e=>e.id,(e,t)=>{let r=F(()=>ua(K(t).id));var i=cc();let a;var s=z(i),c=z(s),u=e=>{var n=$s(),r=z(n),i=V(r);P(n),U(e=>{Q(r,`aria-pressed`,K(h)===K(t).id),X(i,`${e??``} // ${K(t).name??``}`)},[()=>Array.from(K(t).id).slice(-5).join(``).toUpperCase()]),q(`click`,r,()=>w(K(t).id)),Y(e,n)};Z(c,e=>{K(t).name&&e(u)});var f=H(c,2),p=z(f);let m;var g=z(p);let _;var b=H(g,1,!0);P(p),P(f);var x=H(f,2),S=e=>{var n=ec(),r=V(n,!0);U(()=>{Q(n,`aria-pressed`,K(h)===K(t).id),X(r,K(t).directory||K(t).id)}),q(`click`,n,()=>w(K(t).id)),Y(e,n)};Z(x,e=>{K(t).name||e(S)});var C=H(x,2),E=z(C);xe(),P(C);var D=H(C,2),te=e=>{var n=Rs(),r=V(n,!0);U(()=>X(r,K(t).directory)),Y(e,n)};Z(D,e=>{K(t).name&&K(t).directory&&e(te)});var O=H(D,2),ne=V(O),k=H(O,2),re=V(k),ie=H(k,2),ae=z(ie),oe=H(ae,2),se=V(oe,!0),A=H(oe,2);P(ie);var ce=H(ie,2),le=H(ce,2),ue=e=>{var n=tc(),r=V(n,!0);U(e=>X(r,e),[()=>K(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:y(K(t))?`OPEN DETAIL FOR THE TURN ERROR`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:K(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`]),Y(e,n)},de=F(()=>!K(v)&&([`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(K(t).status)||y(K(t))));Z(le,e=>{K(de)&&e(ue)}),P(s);var fe=H(s,2),j=e=>{var r=oc(),i=z(r),a=z(i),s=V(a,!0),c=H(a,2),l=e=>{var n=nc(),r=V(n,!0);U(e=>{Q(n,`href`,e),X(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(K(t).id)]),Y(e,n)};Z(c,e=>{!K(v)&&K(t).status===`APPROVAL NEEDED`&&e(l)}),P(i);var u=H(i,2);n(u,()=>K(t),()=>!1);var f=H(u,2);Xr(f,17,()=>K(o).filter(e=>e.session===K(t).id),Kr,(e,n)=>{var r=ac(),i=B(r),a=e=>{var t=rc(),r=V(t,!0);U(()=>X(r,K(n).notice)),Y(e,t)};Z(i,e=>{K(n).notice&&e(a)});var o=H(i,2),s=e=>{var n=ic();U(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(K(t).id)+`?review=profile`]),q(`click`,n,e=>d(e,K(t).id)),Y(e,n)};Z(o,e=>{K(n).pending&&e(s)}),Y(e,r)});var p=H(f,2);{let e=F(()=>K(h)===K(t).id);Ds(p,{get session(){return K(t)},get active(){return K(e)}})}P(r),U(e=>X(s,e),[()=>ee(K(t))]),Y(e,r)};Z(fe,e=>{K(r)>0&&e(j)});var pe=H(fe,2),me=e=>{var n=sc(),r=H(z(n),2);{let e=F(()=>(K(t).samples||[]).map(e=>e.tokens));io(r,{get values(){return K(e)},capacity:120})}var i=V(H(r,2));P(n),U(()=>X(i,`LAST ${(K(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),Y(e,n)};Z(pe,e=>{K(r)<2&&e(me)}),P(i),U((e,n,o,s,c,l,u)=>{a=ci(i,1,`session-row`,null,a,{selected:K(h)===K(t).id,wide:K(r)===2,split:K(r)===1}),Q(i,`aria-label`,`Session `+(K(t).name||K(t).directory||K(t).id)),m=ci(p,1,`status-detail svelte-mm4wfe`,null,m,{failed:e}),Q(p,`href`,n),_=ci(g,1,`lamp lit svelte-mm4wfe`,null,_,{failed:o,working:K(t).status===`WORKING`&&!K(v)}),X(b,s),X(E,`${c??``} `),X(ne,`${K(t).agents??``} LINKED AGENTS`),X(re,`ACTIVE // ${l??``}`),ae.disabled=K(r)===0,Q(oe,`aria-expanded`,K(r)>0),X(se,K(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,u)},[()=>y(K(t))&&!K(v),()=>`#/sessions/`+encodeURIComponent(K(t).id),()=>y(K(t))&&!K(v),()=>K(v)?`STALE`:l(K(t)),()=>pa(K(t).tokens),()=>ma(K(t).activity),()=>`#/sessions/`+encodeURIComponent(K(t).id)]),q(`click`,p,()=>w(K(t).id)),q(`click`,ae,()=>T(K(t).id,-1)),q(`click`,oe,()=>{w(K(t).id),fa(K(t).id,+!K(r))}),q(`click`,A,()=>T(K(t).id,1)),q(`click`,ce,()=>w(K(t).id)),Y(e,i)});var f=H(u,2),p=e=>{Y(e,lc())};Z(f,e=>{K(a).length||e(p)}),q(`click`,s,()=>da(1)),q(`click`,c,()=>da(0)),Y(e,t)};Z(fe,e=>{i().id?e(j):e(pe,-1)}),U(e=>{X(ne,`OBSERVED ${e??``}`),re=ci(k,1,`session-totals`,null,re,{stale:K(v)}),X(ae,`${K(v)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens - observed since this server started for currently listed sessions; linked - agents are already included. Totals can decrease when a session leaves the - list. History samples every 30 seconds. Not account-wide totals.`)},[()=>ma($.data?.sessionsAt)]),Y(e,te),We()}Sr([`click`]);var pc=J(`

      `),mc=J(`

      Relative usage/credits are not tokens or quota percentages. Groupings - describe the same usage, not additional consumption.

      `,1),hc=J(`// APPROXIMATE`),gc=J(`

      Partial accounting: totals may still change.

      `),_c=J(`

      Percentage of this period's historical allowance, not today's limit. May - exceed 100%. This is not a manual/automatic reset log.

      `,1),vc=J(`

      `,1),yc=J(`

      This optional account report is unavailable. Token history remains - available; missing data does not mean zero usage.

      `),bc=J(`
      `),xc=J(`
      `),Sc=J(`

      No usage reported for this day.

      `),Cc=J(`

      Selected breakdown unavailable; missing does not mean zero.

      `),wc=J(`

      `,1);function Tc(e,t){Ue(t,!0);let n=L(`surface`),r=L(0),i=F(()=>t.reports?.daily),a=F(()=>t.reports?.plan),o=F(()=>t.mode===`breakdown`?K(i)?.days.length||0:K(a)?.periods.length||0),s=F(()=>Math.min(K(r),Math.max(0,K(o)-1))),c=F(()=>K(i)?.days[(K(i)?.days.length||0)-1-K(s)]),l=F(()=>K(a)?.periods[K(s)]),u=F(()=>t.mode===`breakdown`?K(i)?.units||``:`%`),d=F(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=K(c)?.groups[K(n)]||{};else{let t=K(n)===`feature`?`thread_source`:K(n)===`task start`?`turn_trigger`:K(n);for(let n of K(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=F(()=>t.mode===`breakdown`?K(c)?.total:K(l)?.used_basis_points==null?null:K(l).used_basis_points/100),p=F(()=>Math.max(1,K(f)||0,...K(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=wc(),g=B(h),v=z(g),y=H(z(v)),b=z(y);b.value=b.__value=`surface`;var x=H(b);x.value=x.__value=`model`;var S=H(x);S.value=S.__value=`feature`;var C=H(S);C.value=C.__value=`task start`,P(y),mi(y),P(v);var w=H(v,2),T=H(w,2),E=V(H(T,2),!0);P(g);var D=H(g,2),ee=z(D),te=V(ee,!0),O=H(ee,2),ne=V(O),k=H(O,2),re=e=>{var t=mc(),n=B(t),r=V(n),a=H(n,2),o=e=>{var t=pc(),n=V(t);U(()=>X(n,`Data as of ${K(i).dataAsOf??``}`)),Y(e,t)};Z(a,e=>{K(i).dataAsOf&&e(o)});var s=V(H(a,2));xe(2),U((e,t)=>{X(r,`Latest fetch ${e??``} // queried ${K(i).from??``} → ${K(i).through??``}. - Reports are fetched from OpenAI and are not saved between runs.`),X(s,`${(K(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${K(u)??``}`)},[()=>ma(K(i).fetchedAt),()=>m(K(f))]),Y(e,t)},ie=e=>{var t=vc(),n=B(t),r=z(n);let i;var o=V(r,!0),s=H(r),c=e=>{Y(e,hc())};Z(s,e=>{K(a).approximate&&e(c)});var u=H(s);P(n);var d=H(n,2),p=z(d),h=H(p),g=e=>{var t=Mr();U(()=>X(t,`// Boundary tolerance ${K(a).boundary_tolerance_seconds??``}s`)),Y(e,t)};Z(h,e=>{K(a).boundary_tolerance_seconds!=null&&e(g)}),P(d);var _=H(d,2),v=e=>{var t=_c(),n=B(t),r=z(n),i=H(r);let a;var o=V(i);P(n);var s=H(n,2),c=V(s),u=H(s,2),d=e=>{Y(e,gc())};Z(u,e=>{K(l).accounting_complete||e(d)}),xe(2),U(e=>{X(r,`${K(l).window_minutes??``} MIN // ${K(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:K(f)==null,"quota-near":K(f)!=null&&K(f)>=80&&K(f)<100,"quota-full":K(f)!=null&&K(f)>=100}),X(o,`USED ${e??``}${K(f)==null?``:`%`}`),X(c,`${K(l).starts_at??``} → ${K(l).ends_at??``}`)},[()=>m(K(f))]),Y(e,t)};Z(_,e=>{K(l)&&e(v)}),U(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!K(a).coverage_complete}),X(o,K(a).coverage_complete?`Reported range complete`:`Partial coverage`),X(u,` // Latest fetch ${e??``}`),X(p,`Coverage starts ${(K(a).coverage_start||`unknown`)??``} // Data as of ${(K(a).data_as_of||`unknown`)??``}`)},[()=>ma(K(a).fetchedAt)]),Y(e,t)},ae=e=>{Y(e,yc())};Z(k,e=>{t.mode===`breakdown`&&K(i)?e(re):t.mode===`periods`&&K(a)?e(ie,1):e(ae,-1)});var oe=H(k,2),se=e=>{var n=xc(),r=z(n),i=V(H(z(r),2),!0);P(r),Xr(H(r,2),17,()=>K(d),Kr,(e,n,r)=>{var i=F(()=>_(K(n),2));let a=()=>K(i)[0],o=()=>K(i)[1];var s=bc();let c;var l=z(s),u=V(l,!0),d=H(l,2),f=z(d);let h;P(d);var g=V(H(d,2));P(s),U((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),X(u,a()),h=ui(f,``,h,{width:n}),X(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/K(p))}%`,()=>m(o())]),Y(e,s)}),P(n),U(()=>X(i,t.mode===`breakdown`?K(u):`QUOTA USED`)),Y(e,n)},A=e=>{Y(e,Sc())},ce=e=>{Y(e,Cc())};Z(oe,e=>{K(d).length?e(se):t.mode===`breakdown`&&K(c)?.total===0&&K(c)?.groups[K(n)]!=null?e(A,1):(K(i)&&t.mode===`breakdown`||K(a)&&t.mode===`periods`)&&e(ce,2)}),P(D),U(()=>{w.disabled=K(s)>=K(o)-1,T.disabled=K(s)===0,X(E,K(o)?`${K(s)+1} / ${K(o)}`:`NO DATA`),X(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),X(ne,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>K(n),e=>R(n,e)),q(`click`,w,()=>R(r,K(s)+1)),q(`click`,T,()=>R(r,K(s)-1)),Y(e,h),We()}Sr([`click`]);var Ec=864e5;function Dc(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function Oc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Dc(r,-t),a=new Date(i.getTime()+Ec);if(e===n)return{start:a,end:r};r=i}}var kc=J(``),Ac=J(``,1),jc=J(`

      History refresh failed. Any displayed history is the last successful - observation.

      `),Mc=J(`

      Token history unavailable; other reports may still be available.

      `),Nc=J(``),Pc=J(`
      `),Fc=J(`

      LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

      `,1),Ic=J(`
      `,1),Lc=J(` `),Rc=J(`

      LIFETIME TOKENS

      PEAK DAY

      CURRENT STREAK

      DAYS

      LONGEST TURN

      SECONDS

      LONGEST STREAK

      DAYS

      OPENAI // UTC

      Accessible data table
      Date (UTC)Tokens

      `,1),zc=J(`

      History unavailable or awaiting a matching account observation. Missing - history is not treated as zero usage.

      `),Bc=J(`

      USAGE // ACCOUNT HISTORY

      Account-wide history reported by Codex, not the local Sessions counter. Dates - use UTC. Allowance history is approximate where indicated; reset causes are - not provided.

      `,1);function Vc(e,t){Ue(t,!0);let n=L(`daily`),r=L(12),i=L(0),a=F(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=Oc(new Date,K(r),K(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=F(()=>Math.max(1,...K(a).map(e=>e.tokens))),s=F(()=>K(a).length?new Date(K(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=F(()=>{if(K(n)===`monthly`){let e=new Map;for(let t of K(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return K(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Bc(),u=H(B(l),4);Xr(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],Kr,(e,t)=>{var r=F(()=>_(t,2));let a=()=>K(r)[0],o=()=>K(r)[1];var s=kc();let c;var l=V(s,!0);U(()=>{Q(s,`aria-pressed`,K(n)===a()),c=ci(s,1,``,null,c,{active:K(n)===a()}),X(l,o())}),q(`click`,s,()=>{R(n,a(),!0),R(i,0)}),Y(e,s)}),P(u);var d=H(u,2),f=z(d),p=e=>{var t=Ac(),n=B(t),a=H(z(n)),o=z(a);o.value=o.__value=6;var s=H(o);s.value=s.__value=12,P(a),mi(a),P(n);var c=H(n),l=H(c);U(()=>l.disabled=K(i)===0),q(`change`,a,()=>R(i,0)),hi(a,()=>K(r),e=>R(r,e)),q(`click`,c,()=>Kt(i)),q(`click`,l,()=>Kt(i,-1)),Y(e,t)};Z(f,e=>{K(n)!==`breakdown`&&K(n)!==`periods`&&e(p)}),P(d);var m=H(d,2),h=e=>{Y(e,jc())};Z(m,e=>{$.data?.usageError&&e(h)});var g=H(m,2),v=e=>{Y(e,Mc())};Z(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&K(n)!==`breakdown`&&K(n)!==`periods`&&e(v)});var y=H(g,2),b=e=>{var t=Nr();Gr(B(t),()=>K(n),e=>{{let t=F(()=>$.data?.usage?.reports);Tc(e,{get reports(){return K(t)},get mode(){return K(n)}})}}),Y(e,t)},x=e=>{var t=Rc(),r=B(t),i=z(r),l=V(H(z(i),2),!0);P(i);var u=H(i,2),d=V(H(z(u),2),!0);P(u);var f=H(u,2),p=H(z(f),2),m=z(p);xe(),P(p),P(f);var h=H(f,2),g=H(z(h),2),_=z(g);xe(),P(g),P(h);var v=H(h,2),y=H(z(v),2),b=z(y);xe(),P(y),P(v),P(r);var x=H(r,4),S=z(x),C=V(S),w=H(S,2),T=e=>{var t=Fc(),n=B(t),r=z(n),i=z(r);Xr(i,17,()=>Array(K(s)),Kr,(e,t)=>{Y(e,Nc())}),Xr(H(i,2),17,()=>K(a),Kr,(e,t)=>{var n=Pc();let r,i;U(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:K(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:K(t).tokens?.25+.75*K(t).tokens/K(o):1})},[()=>`${K(t).date}: ${pa(K(t).tokens)} tokens`]),Y(e,n)}),P(r),P(n),xe(2),Y(e,t)},E=e=>{var t=Ic(),r=B(t);{let e=F(()=>K(c).map(e=>e.tokens)),t=F(()=>K(n)+` usage`);io(r,{get values(){return K(e)},get label(){return K(t)}})}var i=H(r,2),a=z(i),o=V(a,!0),s=V(H(a),!0);P(i),U(e=>{X(o,K(c)[0]?.date),X(s,e)},[()=>K(c).at(-1)?.date]),Y(e,t)};Z(w,e=>{K(n)===`daily`?e(T):e(E,-1)});var D=H(w,2),ee=H(z(D),2),te=z(ee),O=H(z(te));Xr(O,21,()=>K(n)===`daily`?K(a):K(c),Kr,(e,t)=>{var n=Lc(),r=z(n),i=V(r,!0),a=V(H(r),!0);P(n),U(e=>{X(i,K(t).date),X(a,e)},[()=>pa(K(t).tokens)]),Y(e,n)}),P(O),P(te),P(ee),P(D),P(x);var ne=V(H(x,2));U((e,t,n,r,i,o,s)=>{X(l,e),X(d,t),X(m,`${n??``} `),X(_,`${r??``} `),X(b,`${i??``} `),X(C,`${K(a)[0]?.date??``} — ${o??``}`),X(ne,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>pa($.data.usage.summary.lifetimeTokens),()=>pa($.data.usage.summary.peakDailyTokens),()=>pa($.data.usage.summary.currentStreakDays),()=>pa($.data.usage.summary.longestRunningTurnSec),()=>pa($.data.usage.summary.longestStreakDays),()=>K(a).at(-1)?.date,()=>ma($.data.usageAt)]),Y(e,t)},S=e=>{Y(e,zc())};Z(y,e=>{K(n)===`breakdown`||K(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),Y(e,l),We()}Sr([`click`,`change`]);var Hc=J(`

      Page not found

      Return to Quota

      `,1);function Uc(e){var t=Hc();xe(2),Y(e,t)}var Wc=`CODEXOMETER`,Gc=[`█▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█`,`█▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄`].flatMap(e=>[[...e].map(e=>e===`█`||e===`▀`),[...e].map(e=>e===`█`||e===`▄`)]),Kc=Gc[0].length,qc=Gc.length,Jc=0,Yc=[...Wc].map(e=>{let t=e===`M`?5:3,n={start:Jc,width:t};return Jc+=t+1,n}),Xc=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,Zc=`010 101 111 101.110 111 101 110.111 100 100 111.110 101 101 110.111 100 110 111.111 100 110 100.111 100 101 111.101 101 111 101.111 010 010 111.001 001 101 111.101 110 110 101.100 100 100 111.101 111 101 101.101 111 111 101.111 101 101 111.111 101 111 100.111 101 111 001.111 101 110 101.111 100 001 111.111 010 010 010.101 101 101 111.101 101 101 010.101 101 111 101.101 010 010 101.101 101 010 010.111 001 100 111.111 101 101 111.110 010 010 111.111 001 110 111.111 011 001 111.101 101 111 001.111 110 001 111.100 111 101 111.111 001 010 010.111 111 101 111.111 101 111 001`.split(`.`).map(e=>e.split(` `));function Qc(e=Wc,t=-1,n=!1){let r=``;for(let i=0;i{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function nl(){let e=$c[Math.floor(Math.random()*$c.length)],t=Math.floor(Math.random()*4294967296),n=tl(t),r=[...Wc].map((e,t)=>t);for(let e=r.length-1;e>0;e--){let t=Math.floor(n()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return{variant:e,seed:t,order:r}}function rl(e,t){if(e.variant===`typing`){let e=t<1080,n=e?0:Math.min(Math.floor((t-1080)/90)+1,11);return{text:Wc.slice(0,n).padEnd(11),cursor:n,dot:e?Math.floor(t/180)%2==0:n<11}}if(e.variant===`shuffle`){let n=tl(e.seed^Math.floor(t/70)),r=[...Wc].map(e=>{let t;do t=Xc[Math.floor(n()*36)];while(t===e);return t}),i=Math.min(Math.floor(t/110),11);for(let t of e.order.slice(0,i))r[t]=Wc[t];return{text:r.join(``),cursor:-1,dot:!1}}return{text:Wc,cursor:-1,dot:!1}}var il=jr(``);function al(e,t){Ue(t,!0);let n=Wi(t,`text`,3,Wc),r=Wi(t,`cursor`,19,()=>-1),i=Wi(t,`dot`,3,!1),a=F(()=>Qc(n(),r(),i()));var o=il(),s=V(o);U(()=>{Q(o,`viewBox`,`0 0 ${Kc} ${qc}`),Q(o,`width`,Kc),Q(o,`height`,qc),Q(s,`d`,K(a))}),Y(e,o),We()}var ol=J(`
      `),sl=J(`
      `);function cl(e,t){Ue(t,!0);let n=L(void 0),r=L(0),i=L(Yt({width:0,height:0,pixelRatio:1})),a=L(Yt({x:0,y:0,width:0})),o=F(()=>K(n)?rl(K(n),K(r)):void 0),s=F(()=>{if(!K(n))return{x:0,y:0,width:0};let e=el[K(n).variant],t=Math.min(Math.max((K(r)-e-180)/800,0),1),o=t*t*(3-2*t),s=K(i).width+(K(a).width-K(i).width)*o,c=Math.max((K(i).height-K(i).width*qc/Kc)/2,0),l=(K(n).variant===`slide`&&K(r)Math.round(e*K(i).pixelRatio)/K(i).pixelRatio;return{x:d(l),y:d(u),width:d(s)}});Gi(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`);if(e.matches){t.onfinish();return}R(n,nl(),!0);let o=el[K(n).variant]+180+800,s=0,c=!1,l=performance.now(),u=()=>{let e=t.target?.getBoundingClientRect();R(i,{width:window.innerWidth,height:window.innerHeight,pixelRatio:window.devicePixelRatio||1},!0),e&&R(a,{x:e.x,y:e.y,width:e.width},!0)},d=()=>{c||(c=!0,cancelAnimationFrame(s),t.onfinish())},f=e=>{e instanceof PointerEvent&&e.button!==0||e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)||e instanceof KeyboardEvent&&[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||(e.preventDefault(),e.stopImmediatePropagation(),d())},p=()=>{e.matches&&d()},m=e=>{R(r,Math.max(e-l,0),!0),K(r)>=o?d():s=requestAnimationFrame(m)},h=new ResizeObserver(u);if(t.target){h.observe(t.target),t.target.parentElement&&h.observe(t.target.parentElement);let e=t.target.closest(`header`);e&&h.observe(e)}return u(),window.addEventListener(`resize`,u),document.addEventListener(`keydown`,f,!0),document.addEventListener(`pointerdown`,f,!0),e.addEventListener(`change`,p),s=requestAnimationFrame(m),()=>{c=!0,cancelAnimationFrame(s),h.disconnect(),window.removeEventListener(`resize`,u),document.removeEventListener(`keydown`,f,!0),document.removeEventListener(`pointerdown`,f,!0),e.removeEventListener(`change`,p)}});var c=sl(),l=z(c),u=e=>{var t=ol();let n;al(z(t),{get text(){return K(o).text},get cursor(){return K(o).cursor},get dot(){return K(o).dot}}),P(t),U(()=>{Q(t,`data-text`,K(o).text),Q(t,`data-cursor`,K(o).dot?K(o).cursor:void 0),n=ui(t,``,n,{left:`${K(s).x}px`,top:`${K(s).y}px`,width:`${K(s).width}px`})}),Y(e,t)};Z(l,e=>{K(o)&&e(u)});var d=H(l,2);P(c),U(()=>Q(c,`data-entrance`,K(n)?.variant)),q(`click`,d,function(...e){t.onfinish?.apply(this,e)}),Y(e,c),We()}Sr([`click`]);var ll=J(` `),ul=J(`

      `),dl=J(`

      Connecting to your local Codexometer…

      `),fl=J(``),pl=J(`

      Your quota. Your sessions. Your command centre.

      `);function ml(e,t){Ue(t,!0);let n={"/":to,"/quota/:view?":to,"/sessions/:id?":fc,"/usage":Vc,"*":Uc},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=L(`hacker`),a=L(!0),o=L(void 0);vn(()=>{sa.requests&&lr().then(()=>{K(o)?.focus(),K(o)?.scrollIntoView({block:`nearest`})})});let s=L(void 0),c=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];vn(()=>{ca()}),vn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Yi.location)&&(aa.tab=e)}),Gi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&c.includes(e)&&R(i,e,!0)}catch{}return ya()});function l(){try{localStorage.setItem(`codexometer.web.theme`,K(i))}catch{}}var u=pl(),d=z(u),f=z(d),p=z(f);al(z(p),{}),P(p),Ii(p,e=>R(s,e),()=>K(s)),xe(2),P(f);var m=H(f,2),h=z(m);let g;var v=H(h,1,!0),y=V(H(v));P(m),P(d);var b=H(d,2);Xr(b,21,()=>Object.entries(r),Kr,(e,t)=>{var n=F(()=>_(K(t),2));let r=()=>K(n)[0],i=()=>K(n)[1],a=F(()=>i().test(Yi.location));var o=ll();let s;var c=V(o,!0);U(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+aa.view:`#/`+r()),Q(o,`aria-current`,K(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:K(a)}),X(c,e)},[()=>r().toUpperCase()]),Y(e,o)}),P(b);var x=H(b,2),S=z(x),C=e=>{var t=ul(),n=V(t,!0);U(()=>X(n,$.error)),Y(e,t)};Z(S,e=>{$.error&&e(C)});var w=H(S,2),T=e=>{$i(e,{get routes(){return n}})},E=e=>{Y(e,dl())};Z(w,e=>{$.data?e(T):$.error||e(E,1)}),P(x);var D=H(x,2),ee=z(D),te=V(ee),O=H(ee,2),ne=V(O,!0),k=H(O,2),re=H(z(k));Xr(re,21,()=>c,Kr,(e,t)=>{var n=fl(),r=V(n,!0),i={};U(e=>{X(r,e),i!==(i=K(t))&&(n.value=(n.__value=i)??``)},[()=>K(t).replace(`-`,` `).toUpperCase()]),Y(e,n)}),P(re),Ii(re,e=>R(o,e),()=>K(o)),mi(re),P(k),P(D);var ie=H(D,2),ae=e=>{cl(e,{get target(){return K(s)},onfinish:()=>R(a,!1)})};Z(ie,e=>{K(a)&&e(ae)}),P(u),U(()=>{Q(u,`data-theme`,K(i)),Q(u,`data-starting`,K(a)),d.inert=K(a),g=ci(h,1,`lamp`,null,g,{lit:$.connected}),X(v,$.connected?`CONNECTED`:`OFFLINE`),X(y,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),b.inert=K(a),x.inert=K(a),D.inert=K(a),X(te,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),X(ne,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),q(`change`,re,l),hi(re,()=>K(i),e=>R(i,e)),Y(e,u),We()}Sr([`change`]),zr(ml,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-CqJz1WRL.css b/internal/web/dist/assets/index-CqJz1WRL.css new file mode 100644 index 00000000..b257dcb7 --- /dev/null +++ b/internal/web/dist/assets/index-CqJz1WRL.css @@ -0,0 +1 @@ +.observation-details.svelte-1vgdi83{font-size:12px}summary.svelte-1vgdi83{cursor:pointer;color:var(--accent)}.observation-table.svelte-1vgdi83{max-height:240px;overflow:auto}.zone-canvas.svelte-1vgdi83{flex:1;min-height:170px;margin-top:6px;position:relative}svg.svelte-1vgdi83{width:100%;height:100%;display:block;position:absolute;inset:0}text.svelte-1vgdi83{fill:var(--ink);font:14px Cascadia Code,Consolas,monospace}.axis-title.svelte-1vgdi83{letter-spacing:.04em;font-size:12px}.grid.svelte-1vgdi83{stroke:#fff;stroke-opacity:.14;stroke-width:1px}.axes.svelte-1vgdi83{stroke:var(--ink);stroke-width:1.5px;fill:none}.pace-line.svelte-1vgdi83{stroke:#fff;stroke-width:2px;stroke-dasharray:6 4}.position-halo.svelte-1vgdi83{fill:#101820;stroke:#fff;stroke-width:1.5px}.position-dot.svelte-1vgdi83{fill:#fff}.observation-trail.svelte-1vgdi83{fill:none;stroke:#101820;stroke-width:2.5px;stroke-linejoin:round}.observation-trail-casing.svelte-1vgdi83{fill:none;stroke:#ffffff73;stroke-width:4.5px;stroke-linejoin:round}.trail-start.svelte-1vgdi83{fill:#101820;stroke:#ffffffb3;stroke-width:2px}.trend-line.svelte-1vgdi83{fill:none;stroke:var(--trend-color);stroke-width:2px;stroke-dasharray:3 6}.trend-arrow.svelte-1vgdi83{fill:var(--trend-color);stroke:#ffffff73;stroke-width:.5px}.trend-casing.svelte-1vgdi83{fill:none;stroke:#ffffff73;stroke-width:4px;stroke-dasharray:3 6}.zone-caption.svelte-1vgdi83{min-width:0;color:var(--accent);flex:auto;margin:0}.trend-summary.svelte-1vgdi83{color:var(--ink)}.zone-footer.svelte-1vgdi83{justify-content:space-between;align-items:flex-start;gap:12px;margin-top:4px;display:flex}.zone-controls.svelte-1vgdi83{color:var(--muted);text-align:right;flex-direction:column;align-items:flex-end;gap:5px;font-size:11px;display:flex}.trace-control.svelte-1vgdi83,.trend-control.svelte-1vgdi83{cursor:pointer;white-space:nowrap}.trace-control.svelte-1vgdi83 input:where(.svelte-1vgdi83){accent-color:var(--accent)}.trend-control.svelte-1vgdi83 select:where(.svelte-1vgdi83){border:1px solid var(--edge);background:var(--panel);max-width:min(230px,45vw);color:var(--ink);font:inherit}.trend-control.svelte-1vgdi83 option:where(.svelte-1vgdi83):disabled{color:var(--muted)}.zone-controls.svelte-1vgdi83 small:where(.svelte-1vgdi83){font-size:10px}@container (width<=560px){.zone-footer.svelte-1vgdi83{flex-direction:column}.zone-controls.svelte-1vgdi83{align-self:stretch;align-items:flex-end}}.usage-diagnostic.svelte-16u6dmb{white-space:pre-wrap;overflow-wrap:anywhere}.slash-commands.svelte-7bfwr9{margin:.4rem 0;position:relative}.command-popup.svelte-7bfwr9{z-index:5;box-sizing:border-box;border:1px solid var(--accent);background:var(--panel);width:min(40rem,100%);padding:.35rem;position:absolute;bottom:100%;left:0;box-shadow:0 .3rem 1rem #0006}.command-popup.svelte-7bfwr9 p:where(.svelte-7bfwr9){margin:.3rem 0;font-size:.8em}.command-options.vertical.svelte-7bfwr9{flex-flow:column;gap:.15rem;display:flex}.vertical.svelte-7bfwr9 button:where(.svelte-7bfwr9){text-align:left;white-space:nowrap;width:100%;min-width:0;color:var(--muted);background:var(--panel);border-color:#0000;flex:none;align-items:baseline;gap:.4rem;display:flex}.vertical.svelte-7bfwr9 .command-name:where(.svelte-7bfwr9),.vertical.svelte-7bfwr9 .command-tail:where(.svelte-7bfwr9){flex:none}.vertical.svelte-7bfwr9 .command-name:where(.svelte-7bfwr9){text-overflow:ellipsis;max-width:100%;overflow:hidden}.vertical.svelte-7bfwr9 button.suggested:where(.svelte-7bfwr9){outline:none}.command-options.svelte-7bfwr9 button.suggested:where(.svelte-7bfwr9) .command-name:where(.svelte-7bfwr9){color:var(--ink);font-weight:700}.command-options.svelte-7bfwr9 button:where(.svelte-7bfwr9):not(.suggested):hover .command-name:where(.svelte-7bfwr9){text-decoration:underline}.command-options.svelte-7bfwr9 button:where(.svelte-7bfwr9){color:var(--muted)}.vertical.svelte-7bfwr9 .command-help:where(.svelte-7bfwr9){min-width:0;max-width:none;color:var(--muted);flex:1}.command-options.svelte-7bfwr9{flex-wrap:wrap;gap:.35rem;max-height:35vh;display:flex;overflow:auto}.command-options.svelte-7bfwr9 .suggested:where(.svelte-7bfwr9){outline:none}.command-help.svelte-7bfwr9{text-overflow:ellipsis;white-space:nowrap;opacity:.75;max-width:32ch;font-size:.8em;display:block;overflow:hidden}.command-actions.svelte-7bfwr9{flex-wrap:wrap;gap:.35rem;margin-top:.4rem;display:flex}.availability.svelte-7bfwr9{font-weight:600}.navigation.svelte-7bfwr9{font-size:.8em}pre.svelte-7bfwr9{white-space:pre-wrap;overflow-wrap:anywhere;max-height:35vh;overflow:auto}.file-diff.svelte-x4gtb6{border:1px solid var(--muted);max-height:60vh;padding:.5rem;font-family:monospace;overflow:auto}.diff-line.svelte-x4gtb6{white-space:pre;min-height:1.3em;display:flex}.line-number.svelte-x4gtb6{text-align:right;opacity:.75;-webkit-user-select:none;user-select:none;flex:0 0 5ch;padding-right:1ch;display:inline-block}.added.svelte-x4gtb6{color:#67d391;background:#67d39112}.removed.svelte-x4gtb6{color:#ff6b83;background:#ff6b8312}.heading.svelte-x4gtb6{padding:.5rem 0;font-weight:700}.saved-prompt.svelte-1oupzfc{white-space:pre-wrap;overflow-wrap:anywhere}fieldset.svelte-1oupzfc{border:1px solid;margin:.5rem 0;padding:.35rem .6rem}.decision.svelte-1oupzfc,.answer.svelte-1oupzfc{margin:.3rem 0;display:block}.decision.svelte-1oupzfc code:where(.svelte-1oupzfc),.decision.svelte-1oupzfc span:where(.svelte-1oupzfc){overflow-wrap:anywhere;margin:.3rem 0 .3rem 1.5rem;display:block}textarea.svelte-1oupzfc,.answer.svelte-1oupzfc input:where(.svelte-1oupzfc),.answer.svelte-1oupzfc select:where(.svelte-1oupzfc){box-sizing:border-box;background:var(--bg);width:100%;color:inherit;font:inherit;border:1px solid;margin-top:.4rem;padding:.5rem;display:block}textarea.svelte-1oupzfc{resize:vertical;background:color-mix(in srgb, currentColor 8%, var(--bg))}button.svelte-1oupzfc{margin:.3rem .5rem .3rem 0}h3.svelte-1oupzfc,p.svelte-1oupzfc{margin-block:.4rem}.sent.svelte-1oupzfc{color:var(--accent)}.goal-status.svelte-1yfu3xi{color:var(--accent);text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:.8rem;font-weight:700;overflow:hidden}.pursuing.svelte-1yfu3xi{color:#67d391}.blocked.svelte-1yfu3xi{color:var(--approval)}.stale.svelte-1yfu3xi{color:var(--muted)}.status-line.svelte-gprptn{align-items:center;gap:.5rem;min-width:0;margin-top:.5rem;display:flex}.status-line.svelte-gprptn p:where(.svelte-gprptn){white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;margin:0;font-size:.8rem;overflow:hidden}.configure.svelte-gprptn{padding:.15rem .35rem;font-size:.75rem}.status-picker.svelte-gprptn{border:1px solid var(--edge);margin:.5rem 0;padding:.6rem}.fields.svelte-gprptn{max-height:35vh;overflow:auto}.field.svelte-gprptn{align-items:center;gap:.35rem;display:flex}.field.svelte-gprptn label:where(.svelte-gprptn){flex:1;align-items:center;gap:.4rem;display:flex}.field.svelte-gprptn label:where(.svelte-gprptn) span:where(.svelte-gprptn){font-size:.75rem}.field.svelte-gprptn button:where(.svelte-gprptn){padding:.1rem .35rem}.session-copy.svelte-543j00{justify-content:flex-end;align-items:center;gap:8px;margin-top:auto;padding-top:6px;display:flex}.compact.svelte-543j00{flex-shrink:0;margin-top:0;padding-top:0}span.svelte-543j00{color:var(--muted);overflow-wrap:anywhere;font-size:12px}button.svelte-543j00{color:var(--accent);flex-shrink:0;padding:3px 7px}button.svelte-543j00:hover,button.flashed.svelte-543j00{color:var(--bg);background:var(--accent)}.failed.svelte-mm4wfe{color:var(--approval)}.lamp.failed.svelte-mm4wfe{background:var(--approval);box-shadow:0 0 8px color-mix(in srgb, var(--approval) 40%, transparent)}h3.svelte-1fbui7h,.window-dates.svelte-1fbui7h,.report-value.svelte-1fbui7h{color:var(--accent);font-weight:700}.quality-warning.svelte-1fbui7h,.quota-near.svelte-1fbui7h{color:var(--approval)}.quota-full.svelte-1fbui7h{color:#ff6680}.alternate.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:radial-gradient(circle, var(--panel) .7px, transparent .9px) 0 0 / 3px 3px, var(--accent)}.unknown.svelte-1fbui7h,.unknown.svelte-1fbui7h .report-value:where(.svelte-1fbui7h){color:var(--muted)}.unknown.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:var(--muted);opacity:1}.report-bars.svelte-1fbui7h{grid-template-columns:minmax(5rem,1fr) minmax(2rem,3fr) auto;gap:.6rem;display:grid}.report-row.svelte-1fbui7h,.report-head.svelte-1fbui7h{grid-column:1/-1;grid-template-columns:subgrid;align-items:center;gap:.6rem;display:grid}.report-head.svelte-1fbui7h{color:var(--muted);font-size:.85rem}.report-head.svelte-1fbui7h>span:where(.svelte-1fbui7h):last-child,.report-value.svelte-1fbui7h{text-align:right}.report-row.svelte-1fbui7h>span:where(.svelte-1fbui7h):first-child{overflow-wrap:anywhere}.report-track.svelte-1fbui7h{background:var(--panel);height:1rem}.report-fill.svelte-1fbui7h{background:var(--accent);height:100%}svg.svelte-1jpy949{fill:currentColor;width:100%;height:auto;display:block}.startup.svelte-19xbbtg{z-index:100;background:var(--bg);color:var(--accent);position:fixed;inset:0;overflow:hidden}.wordmark.svelte-19xbbtg{position:absolute}button.svelte-19xbbtg{color:var(--muted);font:inherit;white-space:nowrap;background:0 0;border:0;font-size:12px;position:absolute;bottom:24px;left:50%;transform:translate(-50%)}:root{font-synthesis:none;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:#080e0c;font-family:Cascadia Code,SFMono-Regular,Consolas,monospace}*{box-sizing:border-box}body{margin:0}.shell{--accent:#80edac;--approval:#ffca58;--muted:#98aaa0;--edge:#31473a;--panel:#101c16;--bg:#080e0c;--ink:#e2eee5;background:var(--bg);height:100dvh;color:var(--ink);grid-template-rows:auto auto minmax(0,1fr) auto;padding:clamp(10px,1.2vw,20px);display:grid}.shell[data-theme=rust]{--approval:#ff8a3d;--accent:#ffbc75;--muted:#bfac95;--edge:#59412c;--panel:#261b14;--bg:#140e0a}.shell[data-theme=blue-steel]{--approval:#e8c46a;--accent:#85c8ff;--muted:#9cacc4;--edge:#334d69;--panel:#142235;--bg:#0b1421}.shell[data-theme=ultraviolet]{--approval:#f9a8d4;--accent:#c5adff;--muted:#b3a6c9;--edge:#4b3c68;--panel:#241a35;--bg:#140d22}.shell[data-theme=nightshade]{--approval:#8f7cff;--accent:#e59bff;--muted:#c6a7cf;--edge:#673976;--panel:#301739;--bg:#1c0b24}header,.spread,footer,.controls{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;display:flex}header{margin-bottom:10px}.shell[data-starting=true]>header,.shell[data-starting=true]>nav,.shell[data-starting=true]>main,.shell[data-starting=true]>footer{visibility:hidden}.brand{width:clamp(240px,32vw,405px);max-width:calc(100vw - 40px);color:var(--accent);text-decoration:none;display:block}header p{color:var(--muted);margin:3px 0 0;font-size:13px}.connection{color:var(--accent);text-align:right}small,.eyebrow{letter-spacing:.04em;font-size:12px}.connection small{color:var(--muted);margin-top:4px;display:block}.lamp{background:var(--muted);border-radius:50%;width:9px;height:9px;margin-right:9px;display:inline-block}.lamp.lit{background:var(--accent);box-shadow:0 0 8px color-mix(in srgb, var(--accent) 40%, transparent)}.working{animation:1.5s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.3}}nav{flex-wrap:wrap;gap:6px;margin-bottom:10px;display:flex}nav a,button,.button,select{font:inherit;color:var(--accent);border:1px solid var(--edge);background:var(--panel);cursor:pointer;border-radius:3px;padding:7px 11px;font-size:13px;text-decoration:none}button:hover,.button:hover,nav a:hover{border-color:var(--accent)}nav a.active,nav button.active{background:var(--accent);color:var(--bg);border-color:var(--accent)}:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.secondary{margin-bottom:8px}.secondary a,.secondary button{padding:6px 10px;font-size:12px}main{scrollbar-gutter:stable;flex-direction:column;min-width:0;min-height:0;display:flex;overflow:auto}main>*{flex-shrink:0}.panel{border:1px solid var(--edge);border-top:2px solid var(--accent);background:var(--panel);border-radius:4px;min-width:0;padding:clamp(10px,1vw,16px)}h1{color:var(--accent);font-size:20px}h2{letter-spacing:.04em;color:var(--accent);overflow-wrap:anywhere;margin:0 0 10px;font-size:13px}h3{overflow-wrap:anywhere;font-size:13px}p{margin:6px 0;font-size:13px;line-height:1.45}a{color:var(--accent)}.muted,.eyebrow{color:var(--muted)}.notice{color:#ffe0aa;background:#332611;border-left:3px solid #ffc26e;padding:12px 16px}.empty{color:var(--muted);padding:35px 0}.quota-grid{flex:1 0 auto;grid-auto-rows:minmax(220px,1fr);gap:10px;display:grid}.quota-card{flex-direction:column;min-height:0;display:flex;container-type:inline-size}.quota-card>:not(.meter-graphic){flex-shrink:0}.meter-graphic{flex-direction:column;flex:1;min-height:100px;display:flex}.bar-graphic{min-height:65px}.quota-card .gauge{flex:2;height:auto;min-height:16px;margin:7px 0}.quota-card .timeline{flex:1;min-height:8px}.quota-grid.zone{grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));grid-auto-rows:minmax(330px,1fr)}.quota-grid.radial{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));grid-auto-rows:minmax(260px,1fr)}.gauge{background:var(--edge);height:35px;margin:15px 0;overflow:hidden}.gauge>div{background:repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 9px, transparent 9px, transparent 12px);height:100%;transition:width .5s}.gauge.timeline{height:14px}.pie-wrap{flex:1;min-height:100px;margin:6px 0;position:relative}.pie-wrap svg{width:100%;height:100%;position:absolute;inset:0}.pie-base{fill:var(--edge);stroke:var(--accent);stroke-width:1px}.pie-fill{fill:var(--accent)}.readout{overflow-wrap:anywhere;color:var(--accent);margin:18px 0;font-size:clamp(22px,3vw,34px)}.credit+.credit{border-top:1px solid var(--edge);padding-top:20px}.credit{margin-top:24px}.session-row{grid-template-columns:minmax(210px,1.1fr) minmax(0,1.2fr) minmax(0,1.5fr);align-items:stretch;gap:14px;margin:18px 0;display:grid}.session-totals{grid-template-columns:repeat(auto-fit,minmax(min(145px,100%),1fr));gap:8px;margin:8px 0;display:grid}.session-totals>div{border:1px solid var(--edge);min-width:0;padding:10px}.session-totals dt{color:var(--muted);font-size:11px}.session-totals dd{color:var(--accent);overflow-wrap:anywhere;margin:6px 0 0;font-size:24px}.session-totals.stale dd{color:var(--muted)}.session-row.selected{outline:1px solid var(--accent);outline-offset:4px}.session-row.wide .context{grid-column:2/-1}.detail-controls{flex-wrap:wrap;gap:6px;display:flex}.attention-summary{flex-wrap:wrap;gap:8px;margin-block:8px;display:flex}.attention-summary .approval{color:var(--approval);border-color:var(--approval)}.attention-summary .approval:hover{background:color-mix(in srgb, var(--approval) 12%, var(--panel))}.attention-summary .approval:focus-visible{outline-color:var(--approval)}.attention-note,.attention-badge{color:var(--accent);border-left:3px solid;padding-left:8px}.attention-note.inferred{color:var(--muted)}.attention-badge{font-size:12px}.session-select{text-align:left;overflow-wrap:anywhere;max-width:100%}.status-detail{color:inherit;text-decoration:none}.status-detail:hover{text-decoration:underline}button:disabled{opacity:.4;cursor:default}.session-row .graph-panel{flex-direction:column;grid-column:2/-1;display:flex}.session-row.split .graph-panel{grid-column:auto}.session-row .button,.session-row button{margin-top:8px;display:inline-block}.context pre{max-height:230px;overflow:auto}.session-row .context{flex-direction:column;display:flex}pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7}.full-detail{margin-top:6px}.detail-heading{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px 12px;display:flex}.detail-heading h2{flex:250px;min-width:0;margin:0}.detail-metadata{overflow-wrap:anywhere}.detail-workspace{border-top:1px solid var(--edge);flex-direction:column;gap:10px;margin-top:8px;padding-top:4px;display:flex}.detail-context,.detail-workspace .session-actions{min-width:0}.detail-workspace .session-actions{border-top:1px solid var(--edge);padding-top:6px}.full-detail h3{margin-block:8px}.full-detail pre{margin-block:8px;line-height:1.5}.full-detail hr{margin-block:12px}.full-detail .command,.full-detail .notice{padding:8px 10px}.command{background:var(--bg);border-left:3px solid var(--accent);padding:16px}hr{border:0;border-top:1px solid var(--edge);margin:24px 0}.chart{border-bottom:1px solid var(--muted);align-items:flex-end;gap:2px;height:clamp(120px,22vh,320px);margin-top:18px;display:flex}.chart-bar{background:var(--accent);flex:1;min-width:0;max-height:100%}.controls{justify-content:flex-start;margin:20px 0}.summary-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:16px;margin:20px 0;display:grid}.thresholds-panel{padding:clamp(14px,2vw,22px)}.thresholds-panel h1{margin-top:0}.threshold-list{gap:8px;margin-top:16px;display:grid}.threshold-list article{border:1px solid var(--edge);grid-template-columns:minmax(64px,.5fr) minmax(220px,3fr) minmax(64px,.6fr) minmax(120px,1.2fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.threshold-list article.active{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}.threshold-list article.next{border-color:var(--approval);box-shadow:inset 3px 0 0 var(--approval)}.threshold-list p{color:var(--muted);margin:3px 0 0;font-size:12px}.threshold-trigger{color:var(--accent);font-size:22px;font-weight:800}.threshold-mode,.threshold-state{color:var(--muted);font-size:12px;font-weight:700}.threshold-list article.active .threshold-state{color:var(--accent)}.threshold-list article.next .threshold-state{color:var(--approval)}.heat-scroll{overflow-x:auto}.heatmap{grid-template-rows:repeat(7,13px);grid-auto-columns:minmax(9px,1fr);grid-auto-flow:column;gap:4px;min-width:620px;margin:25px 0;display:grid}.heat-cell{background:var(--accent);border-radius:2px}.heat-cell.zero{background:var(--edge)}.table-scroll{max-height:280px;overflow:auto}table{border-collapse:collapse;width:100%;margin-top:15px}th,td{text-align:left;border-bottom:1px solid var(--edge);padding:8px}summary{cursor:pointer;color:var(--accent);padding-top:14px}footer{border-top:1px solid var(--edge);color:var(--muted);margin-top:8px;padding-top:8px;font-size:11px}footer select{padding:6px}@media (width<=850px){.session-row{grid-template-columns:minmax(0,1fr)}.session-row.wide .context,.session-row .graph-panel{grid-column:auto}.connection{text-align:left}.threshold-list article{grid-template-columns:64px minmax(0,1fr)}.threshold-mode,.threshold-state{grid-column:2}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition:none!important;animation:none!important}} diff --git a/internal/web/dist/assets/index-DAmIts8A.js b/internal/web/dist/assets/index-DAmIts8A.js new file mode 100644 index 00000000..981a5c2a --- /dev/null +++ b/internal/web/dist/assets/index-DAmIts8A.js @@ -0,0 +1,50 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,E=1<<19,D=1<<20,ee=1<<25,te=1<<21,O=1<<22,ne=1<<23,k=Symbol(`$state`),re=Symbol(`component`),ie=Symbol(`legacy props`),ae=Symbol(``),oe=Symbol(`attributes`),se=Symbol(`class`),ce=Symbol(`style`),le=Symbol(`text`),ue=Symbol(`form reset`),de=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},fe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),pe={},A=Symbol(`uninitialized`),me=`http://www.w3.org/1999/xhtml`;function he(){console.warn(`https://svelte.dev/e/derived_inert`)}function ge(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function _e(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ve(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var j=!1;function ye(e){j=e}var M;function be(e){if(e===null)throw ge(),pe;return M=e}function xe(){return be(sn(M))}function N(e){if(j){if(sn(M)!==null)throw ge(),pe;M=e}}function Se(e=1){if(j){for(var t=e,n=M;t--;)n=sn(n);M=n}}function Ce(e=!0){for(var t=0,n=M;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=sn(n);e&&n.remove(),n=i}}function we(e){if(!e||e.nodeType!==8)throw ge(),pe;return e.data}function Te(e){return e===this.v}function Ee(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function De(e){return!Ee(e,this.v)}function Oe(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ke(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ae(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function je(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Me(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Pe(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Fe(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ie(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Le(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Re(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function ze(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Be=!1;function Ve(){Be=!0}var He=null;function Ue(e){He=e}function We(e,t=!1,n){He={p:He,i:!1,c:null,e:null,s:e,x:null,r:W,l:Be&&!t?{s:null,u:null,$:[]}:null}}function Ge(e){var t=He,n=t.e;if(n!==null){t.e=null;for(var r of n)bn(r)}return e!==void 0&&(t.x=e),t.i=!0,He=t.p,Ke(e)}function Ke(e={}){return i(e,re,{value:!0}),e}function qe(){return!Be||He!==null&&He.l===null}var Je=[];function Ye(){var e=Je;Je=[],m(e)}function Xe(e){if(Je.length===0&&!wt){var t=Je;queueMicrotask(()=>{t===Je&&Ye()})}Je.push(e)}function Ze(){for(;Je.length>0;)Ye()}var Qe=~(y|b|v);function $e(e,t){e.f=e.f&Qe|t}function et(e){e.f&512||e.deps===null?$e(e,v):$e(e,b)}function tt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),$e(e,v)}function nt(e){j&&on(e)!==null&&cn(e)}var rt=!1;function it(){rt||(rt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[ue]?.()})},{capture:!0}))}function at(e){var t=U,n=W;Wn(null),Gn(null);try{return e()}finally{Wn(t),Gn(n)}}function ot(e,t,n,r=n){e.addEventListener(t,()=>at(n));let i=e[ue];e[ue]=i?()=>{i(),r(!0)}:()=>r(!0),it()}function st(e,t,n,r){let i=qe()?dt:mt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=W,c=ct(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){pn(e,s)}lt()}}var d=ut();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>pt(e))).then(u).catch(e=>pn(e,s)).finally(d)}l?l.then(()=>{c(),f(),lt()}):f()}function ct(){var e=W,t=U,n=He,r=F;return function(i=!0){Gn(e),Wn(t),Ue(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function lt(e=!0){Gn(null),Wn(null),Ue(null),e&&F?.deactivate()}function ut(){var e=W,t=e.b,n=F,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function dt(e){var t=2|y;return W!==null&&(W.f|=E),{ctx:He,deps:null,effects:null,equals:Te,f:t,fn:e,reactions:null,rv:0,v:A,wv:0,parent:W,ac:null}}var ft=Symbol(`obsolete`);function pt(e,t,n){let r=W;r===null&&ke();var i=void 0,a=Vt(A),o=!U,s=new Set;return wn(()=>{var t=W,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==de&&n.reject(e)}).finally(lt)}catch(e){n.reject(e),lt()}var c=F;if(o){if(t.f&32768)var l=ut();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(ft);else for(let e of s.values())e.reject(ft);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==ft&&(c.activate(),t?(a.f|=ne,Gt(a,t)):(a.f&8388608&&(a.f^=ne),Gt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),vn(()=>{for(let e of s)e.reject(ft)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function P(e){let t=dt(e);return qn(t),t}function mt(e){let t=dt(e);return t.equals=De,t}function ht(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(de),t.ac=null}),t.fn!==null&&(t.teardown=f),cr(t,0),kn(t))}function yt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&lr(t)}var bt=null,F=null,xt=null,St=null,Ct=null,wt=!1,Tt=!1,Et=null,Dt=null,Ot=0,kt=1,At=class e{id=kt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){bt===null?bt=this:(bt.#n=this,this.#t=bt),bt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)$e(r,y),t(r);for(r of n.m)$e(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),$e(e,y),this.schedule(e);for(let e of this.#d)$e(e,b),this.schedule(e);this.apply();for(var t=Et=[],n=[],r=Dt=[];this.#c.length>0;){Ot++>1e3&&(this.#S(),Mt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Lt(e),this.#h()||this.discard(),t}}if(F=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Et=null,Dt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)It(e,t);r.length>0&&F.#_();return}let a=this.#y();if(a)this.#x(n),this.#x(t),a.#b(this);else{this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xt=this,Pt(n),Pt(t),xt=null,this.#s?.resolve();var o=F;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(zt.clear(),o.#_())}}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):rr(r)&&(i&16&&this.#d.add(r),lr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),$e(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),F=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(F===null){let t=F=new e;!Tt&&!wt&&Xe(()=>{t.#e||t.flush()})}return F}apply(){St=null}schedule(e){Ct=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)?e.b.defer_effect(e):this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?bt=e:t.#t=e,this.linked=!1}}};function jt(e){var t=wt;wt=!0;try{var n;for(e&&(F!==null&&!F.is_fork&&F.flush(),n=e());;){if(Ze(),F===null)return n;F.flush()}}finally{wt=t}}function Mt(){try{Pe()}catch(e){pn(e,Ct)}}var Nt=null;function Pt(e){var t=e.length;if(t!==0){for(var n=0;n0)){zt.clear();for(let e of Nt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Nt.has(n)&&(Nt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||lr(n)}}Nt.clear()}}Nt=null}}function Ft(e){F.schedule(e)}function It(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),$e(e,v);for(var n=e.first;n!==null;)It(n,t),n=n.next}}function Lt(e){$e(e,v);for(var t=e.first;t!==null;)Lt(t),t=t.next}var Rt=new Set,zt=new Map,Bt=!1;function Vt(e,t){return{f:0,v:e,reactions:null,equals:Te,rv:0,wv:0}}function I(e,t){let n=Vt(e,t);return qn(n),n}function Ht(e,t=!1,n=!0){let r=Vt(e);return t||(r.equals=De),Be&&n&&He!==null&&He.l!==null&&(He.l.s??=[]).push(r),r}function L(e,t,n=!1){return U!==null&&(!Un||U.f&131072)&&qe()&&U.f&4325394&&(Kn===null||!Kn.has(e))&&Re(),Gt(e,n?Xt(t):t,Dt)}var Ut=null,Wt=0;function Gt(e,t,n=null){if(!e.equals(t)){Vn?zt.set(e,t):zt.has(e)||zt.set(e,e.v);var r=At.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&>(t),St===null&&et(t)}e.wv=nr(),Ut=null,Wt=0,Yt(e,y,n),Ut=null,qe()&&W!==null&&W.f&1024&&!(W.f&96)&&(Xn===null?Zn([e]):Xn.push(e)),!r.is_fork&&Rt.size>0&&!Bt&&Kt()}return t}function Kt(){Bt=!1;for(let e of Rt){e.f&1024&&$e(e,b);let t;try{t=rr(e)}catch{t=!0}t&&lr(e)}Rt.clear()}function qt(e,t=1){var n=G(e),r=t===1?n++:n--;return L(e,n),r}function Jt(e){L(e,e.v+1)}function Yt(e,t,n){var r=e.reactions;if(r!==null){var i=qe(),a=r.length;if(Wt+=a,Wt>1e5&&Ut===null&&(Ut=new Set),Ut!==null){if(Ut.has(e))return;Ut.add(e)}for(var o=0;o{if(er===d)return e();var t=U,n=er;Wn(null),tr(d);var r=e();return Wn(t),tr(n),r};return i&&r.set(`length`,I(t.length,u)),new Proxy(t,{defineProperty(e,t,n){`value`in n&&n.configurable!==!1&&n.enumerable!==!1&&n.writable!==!1||Ie();var i=r.get(t);return i===void 0?f(()=>{var e=I(n.value,u);return r.set(t,e),e}):L(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>I(A,u));r.set(t,e),Jt(o)}}else L(n,A),Jt(o);return!0},get(e,n,i){if(n===k)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>I(Xt(s?e[n]:A),u)),r.set(n,o)),o!==void 0){var c=G(o);return c===A?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=G(i);if(a===A)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===k)return!0;var n=r.get(t),i=n!==void 0&&n.v!==A||Reflect.has(e,t);return(n!==void 0||W!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>I(i?Xt(e[t]):A,u)),r.set(t,n)),G(n)===A)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dI(A,u)),r.set(d+``,p)):L(p,A)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>I(void 0,u)),L(c,Xt(n)),r.set(t,c));else{l=c.v!==A;var m=f(()=>Xt(n));L(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}Jt(o)}return!0},ownKeys(e){G(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==A});for(var[n,i]of r)i.v!==A&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Le()}})}function Zt(e){try{if(typeof e==`object`&&e&&k in e)return e[k]}catch{}return e}function Qt(e,t){return Object.is(Zt(e),Zt(t))}var $t,en,tn,nn;function rn(){if($t===void 0){$t=window,en=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;tn=a(t,`firstChild`).get,nn=a(t,`nextSibling`).get,u(e)&&(e[se]=void 0,e[oe]=null,e[ce]=void 0,e.__e=void 0),u(n)&&(n[le]=void 0)}}function an(e=``){return document.createTextNode(e)}function on(e){return tn.call(e)}function sn(e){return nn.call(e)}function R(e,t){if(!j)return on(e);var n=on(M);if(n===null)n=M.appendChild(an());else if(t&&n.nodeType!==3){var r=an();return n?.before(r),be(r),r}return t&&dn(n),be(n),n}function z(e,t=!1){if(!j){var n=on(e);return n instanceof Comment&&n.data===``?sn(n):n}if(t){if(M?.nodeType!==3){var r=an();return M?.before(r),be(r),r}dn(M)}return M}function B(e,t=!1){if(!j)return on(e);var n=R(e,t);return N(e),n}function V(e,t=1,n=!1){let r=j?M:e;for(var i;t--;)i=r,r=sn(r);if(!j)return r;if(n){if(r?.nodeType!==3){var a=an();return r===null?i?.after(a):r.before(a),be(a),a}dn(r)}return be(r),r}function cn(e){e.textContent=``}function ln(){return!1}function un(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function dn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function fn(e){var t=W;if(t===null)return U.f|=ne,e;if(!(t.f&32768)&&!(t.f&4))throw e;pn(e,t)}function pn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function mn(e){W===null&&(U===null&&Ne(e),Me()),Vn&&je(e)}function hn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function gn(e,t){var n=W;n!==null&&n.f&8192&&(e|=x);var r={ctx:He,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};F?.register_created_effect(r);var i=r;if(e&4)Et===null?At.ensure().schedule(r):Et.push(r);else if(t!==null){try{lr(r)}catch(e){throw jn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&hn(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function _n(){return U!==null&&!Un}function vn(e){let t=gn(8,null);return $e(t,v),t.teardown=e,t}function yn(e){mn(`$effect`);var t=W.f;if(!U&&t&32&&He!==null&&!He.i){var n=He;(n.e??=[]).push(e)}else return bn(e)}function bn(e){return gn(4|D,e)}function xn(e){return mn(`$effect.pre`),gn(8|D,e)}function Sn(e){At.ensure();let t=gn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Pn(t,()=>{jn(t),n(void 0)}):(jn(t),n(void 0))})}function Cn(e){return gn(4,e)}function wn(e){return gn(O|E,e)}function Tn(e,t=0){return gn(8|t,e)}function H(e,t=[],n=[],r=[]){st(r,t,n,t=>{gn(8,()=>{e(...t.map(G))})})}function En(e,t=0){return gn(16|t,e)}function Dn(e){return gn(32|E,e)}function On(e){var t=e.teardown;if(t!==null){let n=Vn,r=U;Hn(!0),Wn(null);try{t.call(null)}catch(t){pn(t,e.parent)}finally{Hn(n),Wn(r)}}}function kn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&at(()=>{e.abort(de)});var r=n.next;n.f&64?n.parent=null:jn(n,t),n=r}}function An(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||jn(t),t=n}}function jn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Mn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,kn(e,t&&!n),cr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();On(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Nn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Mn(e,t){for(;e!==null;){var n=e===t?null:sn(e);e.remove(),e=n}}function Nn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pn(e,t,n=!0){var r=[];e.f|=256,Fn(e,r,!0);var i=()=>{n&&jn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Fn(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Fn(i,t,o?n:!1)}i=a}}}function In(e){e.f&=-257,Ln(e,!0)}function Ln(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||($e(e,y),At.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Ln(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Rn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:sn(n);t.append(n),n=i}}var zn=null,Bn=!1,Vn=!1;function Hn(e){Vn=e}var U=null,Un=!1;function Wn(e){U=e}var W=null;function Gn(e){W=e}var Kn=null;function qn(e){U!==null&&(U.f&2097152||U.f&2)&&(Kn??=new Set).add(e)}var Jn=null,Yn=0,Xn=null;function Zn(e){Xn=e}var Qn=1,$n=0,er=$n;function tr(e){er=e}function nr(){return++Qn}function rr(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&St===null&&$e(e,v)}return!1}function ir(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Kn!==null&&Kn.has(e)))for(var i=0;i{e.ac.abort(de)}),e.ac=null);try{e.f|=te;var u=e.fn,d=u();e.f|=C;var f=or(e);if(qe()&&Xn!==null&&!Un&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Yn+Jn.length,r=0;r{s.ac.abort(de),s.ac=null,$e(s,y)}),vt(s),cr(s,0)}}function cr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Xe(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Sr(e,t,n,r,i){var a={capture:r,passive:i},o=xr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&vn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function K(e,t,n){(t[vr]??={})[e]=n}function Cr(e){for(var t=0;t{Tr=!1,wr=null}));var s=0,c=wr===e&&e[vr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[vr]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=U,f=W;Wn(null),Gn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[vr]?.[r];h==null||o.disabled&&e.target!==o||h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[vr]=t,delete e.currentTarget,Wn(d),Gn(f)}}}var Dr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Or(e){return Dr?.createHTML(e)??e}function kr(e){var t=un(`template`);return t.innerHTML=Or(e.replaceAll(``,``)),t.content}function Ar(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(j)return Ar(M,null),M;i===void 0&&(i=kr(a?e:``+e),n||(i=on(i)));var t=r||en?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=on(t),s=t.lastChild;Ar(o,s)}else Ar(t,t);return t}}function jr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(j)return Ar(M,null),M;if(!o){var e=on(kr(a));if(i)for(o=document.createDocumentFragment();on(e);)o.appendChild(on(e));else o=on(e)}var t=o.cloneNode(!0);if(i){var n=on(t),r=t.lastChild;Ar(n,r)}else Ar(t,t);return t}}function Mr(e,t){return jr(e,t,`svg`)}function Nr(e=``){if(!j){var t=an(e+``);return Ar(t,t),t}var n=M;return n.nodeType===3?dn(n):(n.before(n=an()),be(n)),Ar(n,n),n}function Pr(){if(j)return Ar(M,null),M;var e=document.createDocumentFragment(),t=document.createComment(``),n=an();return e.append(t,n),Ar(t,n),e}function J(e,t){if(j){var n=W;n.f&32768&&n.nodes.end!==null||(n.nodes.end=M),xe()}else e!==null&&e.before(t)}function Fr(){if(j&&M&&M.nodeType===8&&M.textContent?.startsWith(`$`)){let e=M.textContent.substring(1);return xe(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Ir(e){let t=0,n=Vt(0),r;return()=>{_n()&&(G(n),Tn(()=>(t===0&&(r=pr(()=>e(()=>Jt(n)))),t+=1,()=>{Xe(()=>{--t,t===0&&(r?.(),r=void 0,Jt(n))})})))}}var Lr=T|E;function Rr(e,t,n,r){new zr(e,t,n,r)}var zr=class{parent;is_pending=!1;transform_error;#e;#t=j?M:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ir(()=>(this.#m=Vt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=En(()=>{if(j){let e=this.#t;xe();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Lr),j&&(this.#e=M)}#g(){try{this.#a=Dn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Xe(r),t&&(this.#s=Dn(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{t?ve():(t=!0,n&&ze(),this.#s!==null&&Pn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()}))};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){pn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Dn(()=>e(this.#e)),Xe(()=>{var e=this.#c=document.createDocumentFragment(),t=an(),n=!1;e.append(t),this.#a=this.#S(()=>{try{return Dn(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){pn(e,this.#i.parent)}return null}}),this.#a===null?(this.#c=null,n&&this.#x(F)):this.#u===0&&(this.#e.before(e),this.#c=null,Pn(this.#o,()=>{this.#o=null}),this.#x(F))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Dn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Rn(this.#a,e);let t=this.#n.pending;this.#o=Dn(()=>t(this.#e))}else this.#x(F)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){tt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=W,n=U,r=He;Gn(this.#i),Wn(this.#i),Ue(this.#i.ctx);try{return At.ensure(),e()}finally{Gn(t),Wn(n),Ue(r)}}#C(e,t){this.has_pending_snippet()?(this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Pn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))):this.parent&&this.parent.#C(e,t)}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Xe(()=>{this.#d=!1,this.#m&&Gt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;F?.is_fork?(this.#a&&F.skip_effect(this.#a),this.#o&&F.skip_effect(this.#o),this.#s&&F.skip_effect(this.#s),F.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(jn(this.#a),null),this.#o&&=(jn(this.#o),null),this.#s&&=(jn(this.#s),null),j&&(be(this.#t),Se(),be(Ce()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return Dn(()=>{var r=W;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return pn(e,this.#i.parent),null}}))};Xe(()=>{var t;try{t=this.transform_error(e)}catch(e){pn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>pn(e,this.#i&&this.#i.parent)):n(t)})}};function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[le]??=e.nodeValue)&&(e[le]=n,e.nodeValue=`${n}`)}function Br(e,t){return Hr(e,t)}var Vr=new Map;function Hr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){rn();var l=void 0,u=Sn(()=>{var s=n??t.appendChild(an());Rr(s,{pending:()=>{}},t=>{We({});var n=He;if(o&&(n.c=o),a&&(i.$$events=a),j&&Ar(t,null),l=e(t,i)||Ke(),j&&(W.nodes.end=M,M===null||M.nodeType!==8||M.data!==`]`))throw ge(),pe;Ge()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Vr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Er),r.delete(e),r.size===0&&Vr.delete(n)):r.set(e,i)}br.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Ur.set(l,u),l}var Ur=new WeakMap,Wr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)In(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(In(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(jn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Rn(r,t),t.append(an()),this.#n.set(e,{effect:r,fragment:t})}else jn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Pn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(jn(n.effect),this.#n.delete(e))};ensure(e,t){var n=F,r=ln();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=an();i.append(a),this.#n.set(e,{effect:Dn(()=>t(a)),fragment:i})}else this.#t.set(e,Dn(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else j&&(this.anchor=M),this.#a(n)}};function X(e,t,n=!1){var r;j&&(r=M,xe());var i=new Wr(e),a=n?T:0;function o(e,t){if(j){var n=we(r);if(e!==parseInt(n.substring(1))){var a=Ce();be(a),i.anchor=a,ye(!1),i.ensure(e,t),ye(!0);return}}i.ensure(e,t)}En(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Gr=Symbol(`NaN`);function Kr(e,t,n){j&&xe();var r=new Wr(e),i=!qe();En(()=>{var e=t();e!==e&&(e=Gr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function qr(e,t){return t}function Jr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Yr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;cn(d),d.append(u),e.items.clear()}Yr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Yr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,$r(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=ee,ti(d,null,c)):In(d):Pn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:En(()=>{p=G(f);var e=p.length;let t=!1;j&&we(c)===`[!`!=(e===0)&&(c=Ce(),be(c),ye(!1),t=!0);for(var r=new Set,u=F,v=ln(),y=0;ys(c)):(d=Dn(()=>s(Xr??=an())),d.f|=ee)),e>r.size&&Ae(``,``,``),j&&e>0&&be(Ce()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&ye(!0),G(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,j&&(c=M)}function Qr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function $r(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Qr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var E=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function ei(e,t,n,r,i,a,o,s){var c=o&1?o&16?Vt(n):Ht(n,!1,!1):null,l=o&2?Vt(i):null;return{v:c,i:l,e:Dn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ti(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=sn(r);if(a.before(r),r===i)return;r=o}}function ni(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ri(e,t,...n){var r=new Wr(e);En(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},T)}function ii(e,t,n){var r;j&&(r=M,xe());var i=new Wr(e);En(()=>{var e=t()??null;if(j&&we(r)===`[`!=(e!==null)){var a=Ce();be(a),i.anchor=a,ye(!1),i.ensure(e,e&&(t=>n(t,e))),ye(!0)}else i.ensure(e,e&&(t=>n(t,e)))},T)}var ai=[...` +\r\f\xA0\v`];function oi(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ai.includes(r[o-1]))&&(s===r.length||ai.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function si(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function ci(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function li(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(ci)),i&&c.push(...Object.keys(i).map(ci));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(yi)||(`__defaultValue`in e&&mi(e,!1),`__value`in e&&hi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),vn(()=>{t.disconnect()})}function _i(e,t,n=t){var r=new WeakSet,i=!0;ot(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),vi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&vi(o)}n(a),e.__value=a,F!==null&&r.add(F)}),Cn(()=>{var a=t();if(e===document.activeElement){var o=F;if(r.has(o))return}if(hi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=vi(s),n(a))}e.__value=a,i=!1})}function vi(e){return`__value`in e?e.__value:e.value}function yi(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var bi=Symbol(`is custom element`),xi=Symbol(`is html`),Si=fe?`link`:`LINK`;function Ci(e){if(j){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Z(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Z(e,`checked`,null),e.checked=r}}};e[ue]=n,Xe(n),it()}}function wi(e,t){var n=Ti(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Z(e,t,n,r){var i=Ti(e);j&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Si)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ae]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Di(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Ti(e){return e[oe]??={[bi]:e.nodeName.includes(`-`),[xi]:e.namespaceURI===me}}var Ei=new Map;function Di(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ei.get(t);if(n)return n;Ei.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Oi(e,t,n=t){var r=new WeakSet;ot(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Ni(e)?Pi(a):a,n(a),F!==null&&r.add(F),await ur(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(j&&e.defaultValue!==e.value||pr(t)==null&&e.value)&&(n(Ni(e)?Pi(e.value):e.value),F!==null&&r.add(F)),Tn(()=>{var n=t();if(e===document.activeElement){var i=F;if(r.has(i))return}Ni(e)&&n===Pi(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var ki=new Set;function Ai(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),ot(n,`change`,()=>{var e=n.__value;a&&(e=Mi(o,e,n.checked)),i(e)},()=>i(a?[]:null)),Tn(()=>{var e=r();j&&n.defaultChecked!==n.checked?s=!0:a?(e||=[],n.checked=e.includes(n.__value)):n.checked=Qt(n.__value,e)}),vn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),ki.has(o)||(ki.add(o),Xe(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),ki.delete(o)})),Xe(()=>{if(s){var e=a?Mi(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function ji(e,t,n=t){ot(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(j&&e.defaultChecked!==e.checked||pr(t)==null)&&n(e.checked),Tn(()=>{e.checked=!!t()})}function Mi(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Ii(e,t,n){var r=Fi.observe(e,()=>n(e[t]));Cn(()=>(pr(()=>n(e[t])),r))}function Li(e,t){return e===t||e?.[k]===t}function Ri(e=Ke(),t,n,r){var i=He.r,a=W;return Cn(()=>{var o,s;return Tn(()=>{o=s,s=r?.()||[],pr(()=>{Li(n(...s),e)||(t(e,...s),o&&Li(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Li(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function zi(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?Tn(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&vn(()=>{n.removeEventListener(t,a)})}function Bi(e=!1){let t=He,n=t.l.u;if(!n)return;let r=()=>mr(t.s);if(e){let e=0,n={},i=dt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>G(i)}n.b.length&&xn(()=>{Vi(t,r),m(n.b)}),yn(()=>{let e=pr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&yn(()=>{Vi(t,r),m(n.a)})}function Vi(e,t){if(e.l.s)for(let t of e.l.s)G(t);t()}var Hi=!1;function Ui(e){var t=Hi;try{return Hi=!1,[e(),Hi]}finally{Hi=t}}var Wi={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===k||t===ie)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Gi(...e){return new Proxy({props:e},Wi)}function Q(e,t,n,r){var i=!Be||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=dt(r),G(u)):(l&&(l=!1,c=s?pr(r):r),c);let f;if(o){var p=k in e||ie in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Ui(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Fe(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?dt:mt)(()=>(v=!1,g()));o&&G(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&o?Xt(e):e;return L(y,n),v=!0,c!==void 0&&(c=n),e}return Vn&&v||b.f&16384?y.v:G(y)})}function Ki(e){He===null&&Oe(`onMount`),Be&&He.l!==null?Ji(He).m.push(e):yn(()=>{let t=pr(e);if(typeof t==`function`)return t})}function qi(e){He===null&&Oe(`onDestroy`),Ki(()=>()=>pr(e))}function Ji(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Yi(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Xi=new class{#e=I(Zi());get _loc(){return G(this.#e)}set _loc(e){L(this.#e,e)}#t=P(()=>this._loc.location);get _location(){return G(this.#t)}set _location(e){L(this.#t,e)}#n=P(()=>this._loc.querystring);get _querystring(){return G(this.#n)}set _querystring(e){L(this.#n,e)}#r=I(void 0);get _params(){return G(this.#r)}set _params(e){L(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Zi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Zi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}async function Qi(e){if(!e||e.length<1||e.charAt(0)!=`/`&&e.indexOf(`#/`)!==0)throw Error(`Invalid parameter location`);await ur();let t=(e.charAt(0)==`#`?``:`#`)+e;try{let e={...history.state};delete e.__svelte_spa_router_scrollX,delete e.__svelte_spa_router_scrollY,window.history.replaceState(e,``,t)}catch{console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event(`hashchange`))}function $i(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function ea(e,t){We(t,!0);let n=Q(t,`routes`,19,()=>({})),r=Q(t,`prefix`,3,``),i=Q(t,`restoreScrollState`,3,!1),a=Q(t,`onConditionsFailed`,3,()=>{}),o=Q(t,`onRouteLoaded`,3,()=>{}),s=Q(t,`onRouteLoading`,3,()=>{}),c=Q(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Yi(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=I(null),f=I(null),p=I({}),m=null,h=null;yn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),yn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await ur(),e(t)}yn(()=>{let e=Xi.loc,t=!1;return pr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Pr(),y=z(v),b=e=>{let t=P(()=>G(d));var n=Pr(),r=z(n),i=e=>{var n=Pr();ii(z(n),()=>G(t),(e,t)=>{t(e,Gi({get params(){return G(f)},get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)},a=e=>{var n=Pr();ii(z(n),()=>G(t),(e,t)=>{t(e,Gi({get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)};X(r,e=>{G(f)?e(i):e(a,-1)}),J(e,n)};X(y,e=>{G(d)&&e(b)}),J(e,v),Ge()}var ta=[`bars`,`pace`,`pie`,`fuel`,`resets`,`thresholds`];function na(e){return e===`zone`||e===`consumption-pace`?`pace`:typeof e==`string`&&ta.includes(e)?e:`bars`}var ra=`codexometer.web.preferences.v1`,ia={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function aa(){try{let e=JSON.parse(localStorage.getItem(ra)||`null`);return!e||typeof e!=`object`?ia:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:na(e.view),selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ia}}var oa=Xt(aa()),sa=Xt({open:!1}),ca=Xt({requests:0});function la(){let e=JSON.stringify(oa);try{localStorage.setItem(ra,e)}catch{}}function ua(){return oa.tab===`quota`?`/quota/`+oa.view:`/`+oa.tab}function da(e){return oa.layouts.find(t=>t.id===e)?.level??oa.defaultDetail}function fa(e){oa.defaultDetail=e,oa.layouts=[]}function pa(e,t){oa.layouts=[...oa.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Xt({data:null,connected:!1,error:``}),ma=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),ha=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),ga=`codexometer.web.session`,_a=class extends Error{},va;async function ya(e,t,n){if(!va||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await va(e,t,n)}function ba(){let e=new AbortController,t,n=``;va=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new _a(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(ga)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+ua()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(ga,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}n?await o():$.error=`Open the private pairing link printed by codexometer --web in your terminal.`}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(ga)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` + +`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{va=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ve();var xa=q(`

      Quota refresh failed. Policy state is based on the last successful + observation.

      `),Sa=q(`

      `),Ca=q(`

      The longest Codex quota window selects one active model profile. ASK + creates a per-session review; AUTO applies the profile on the next + eligible check.

      `,1),wa=q(`

      No threshold-based model steps were configured at launch.

      `);function Ta(e,t){We(t,!1),Bi();var n=Pr(),r=z(n),i=e=>{var t=Ca(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,xa())};X(i,e=>{$.data.quotaError&&e(a)});var o=V(i,2),s=R(o),c=B(s),l=V(s,4);Zr(l,5,()=>$.data.thresholds,qr,(e,t)=>{var n=Sa();let r;var i=R(n),a=B(i),o=V(i,2),s=R(o),c=B(s,!0),l=B(V(s,2));N(o);var u=V(o,2),d=B(u,!0),f=B(V(u,2));N(n),H((e,i)=>{r=ui(n,1,``,null,r,{active:G(t).state===`ACTIVE`,next:G(t).state===`NEXT`}),Y(a,`${G(t).threshold??``}%`),Y(c,G(t).model),Y(l,`${e??``} REASONING // ${i??``} + SPEED`),Y(d,G(t).mode),Y(f,`${G(t).state??``}${G(t).state===`NEXT`?` // ${G(t).remaining||0} PP TO GO`:``}`)},[()=>G(t).effort.toUpperCase(),()=>G(t).speed.toUpperCase()]),J(e,n)}),N(l),N(o),H(e=>{Y(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),Y(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>ha($.data.quotaAt)]),J(e,t)},a=e=>{J(e,wa())};X(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),J(e,n),Ge()}var Ea=Mr(` `,1),Da=Mr(` `,1),Oa=Mr(` `,1),ka=Mr(` `,1),Aa=q(`
      `,1),ja=q(` `),Ma=q(`
      Quota observations
      Observed atPeriod elapsedConsumedTrail segment
      `),Na=q(`
      OBSERVATION DATA
      `),Pa=q(`
      CONSUMPTIONQUOTA PERIOD ELAPSED
      `,1);function Fa(e,t){let n=Fr();We(t,!0);let r=Q(t,`trail`,19,()=>[]),i=I(!1),a=I(!0),o=I(`window`),s=[0,25,50,75,100],c={off:0,halfHour:30,hour:60,day:1440,window:0},l=I(400),u=I(240),d=P(()=>G(l)-24),f=P(()=>G(u)-48),p=P(()=>Math.max(1,G(d)-48)),m=P(()=>Math.max(1,G(f)-20)),h=P(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*G(p));function g(e){return G(f)-(e-0)/100*G(m)}let _=P(()=>g(t.used)),v=P(()=>t.used-t.elapsed),y=P(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*G(p)} ${g(e.used)}`).join(` `)),b=P(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),x=P(()=>G(b).length<2?0:Math.max(0,Date.parse(G(b).at(-1).at)-Date.parse(G(b)[0].at)));function S(e){if(G(x)Date.parse(e.at)>=t).length>=2}let C=P(()=>({off:!0,halfHour:S(18e5),hour:S(36e5),day:S(864e5),window:Number.isFinite(t.elapsed)&&t.elapsed>0&&Number.isFinite(t.used)}));yn(()=>{G(o)!==`window`&&!G(C)[G(o)]&&L(o,`window`)});function w(e){if(e===`off`||!G(C)[e])return[];let t=c[e]*6e4,n=Date.parse(G(b).at(-1).at)-t,r=G(b).findIndex(e=>Date.parse(e.at)>=n);return r<0?[]:G(b).slice(r)}function T(e){if(e.length<2)return null;let t=e.reduce((e,t)=>e+t.elapsed,0)/e.length,n=e.reduce((e,t)=>e+t.used,0)/e.length,r=0,i=0;for(let a of e)r+=(a.elapsed-t)*(a.used-n),i+=(a.elapsed-t)**2;return i>0?Math.max(0,r/i):null}let E=P(()=>{let e=G(o)===`window`&&G(C).window?t.used/t.elapsed:T(w(G(o)));if(e===null||!t.duration)return null;let n=t.used+e*(100-t.elapsed),r=G(o)===`window`?0:t.used-e*t.elapsed,i=e,a=Math.max(0,t.elapsed-c[G(o)]/t.duration*100);G(o)===`window`&&(a=0);let s=100;if(i!==0){let e=(0-r)/i,t=(100-r)/i;a=Math.max(a,Math.min(e,t)),s=Math.min(100,Math.max(e,t))}if(a>s)return null;let l=r+i*a,u=r+i*s,d=Math.hypot((s-a)/100*G(p),(u-l)/100*G(m)),f=Math.max(3,Math.min(9,Math.floor(d/65)+2));return{path:`M${Array.from({length:f},(e,t)=>{let n=a+(s-a)*t/(f-1),r=l+(u-l)*t/(f-1);return`${48+n/100*G(p)} ${g(r)}`}).join(` L`)}`,projected:n,safe:n<=100}}),D=P(()=>{if(G(b).length===0)return`NO OBSERVATIONS`;if(G(b).length===1)return`ONE OBSERVATION`;let e=Math.floor(G(x)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var ee=Pa(),te=z(ee),O=R(te);let ne;var k=R(O),re=R(k),ie=V(re);N(k);var ae=V(k),oe=V(ae);Zr(oe,17,()=>s,qr,(e,t)=>{var n=Ea(),r=z(n),i=V(r),a=B(i);H(()=>{Z(r,`x1`,48+G(t)/100*G(p)),Z(r,`x2`,48+G(t)/100*G(p)),Z(r,`y2`,G(f)),Z(i,`x`,48+G(t)/100*G(p)),Z(i,`y`,G(f)+20),Y(a,`${G(t)??``}%`)}),J(e,n)});var se=V(oe);Zr(se,17,()=>s,qr,(e,t)=>{var n=Da(),r=z(n),i=V(r),a=B(i);H((e,n,o)=>{Z(r,`y1`,e),Z(r,`x2`,G(d)),Z(r,`y2`,n),Z(i,`y`,o),Y(a,`${G(t)??``}%`)},[()=>g(G(t)),()=>g(G(t)),()=>g(G(t))+4]),J(e,n)});var ce=V(se),le=V(ce),ue=V(le),de=e=>{var t=Oa(),n=z(t),i=V(n),a=V(i),o=B(R(a));N(a),H((e,t)=>{Z(n,`d`,G(y)),Z(i,`d`,G(y)),Z(a,`cx`,48+r()[0].elapsed/100*G(p)),Z(a,`cy`,e),Y(o,`First observation: ${t??``}`)},[()=>g(r()[0].used),()=>ha(r()[0].at)]),J(e,t)};X(ue,e=>{G(a)&&r().length&&e(de)});var fe=V(ue),pe=e=>{var t=ka(),r=z(t),i=V(r),a=B(R(i));N(i),H(e=>{Z(r,`d`,G(E).path),Z(i,`d`,G(E).path),Z(i,`marker-mid`,`url(#${n}-trend-arrow)`),Y(a,`${G(o)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>G(E).projected.toFixed(1)]),J(e,t)};X(fe,e=>{G(E)&&e(pe)});var A=V(fe,2),me=V(A),he=V(me),ge=B(R(he));N(he),N(O),N(te);var _e=V(te,2),ve=R(_e),j=R(ve),ye=V(j,3),M=B(ye,!0),be=V(ye,2),xe=e=>{var t=Aa(),n=B(V(z(t)));H(e=>Y(n,`TREND // ${e??``}`),[()=>G(E).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${G(E).projected.toFixed(1)}% PROJECTED AT RESET`]),J(e,t)};X(be,e=>{G(E)&&e(xe)}),N(ve);var Ce=V(ve,2),we=R(Ce),Te=R(we);Ci(Te),Se(),N(we);var Ee=V(we,2),De=V(R(Ee),2),Oe=R(De);Oe.value=Oe.__value=`off`;var ke=V(Oe),Ae=B(ke);ke.value=ke.__value=`halfHour`;var je=V(ke),Me=B(je);je.value=je.__value=`hour`;var Ne=V(je),Pe=B(Ne);Ne.value=Ne.__value=`day`;var Fe=V(Ne),Ie=B(Fe);Fe.value=Fe.__value=`window`,N(De),gi(De),N(Ee);var Le=B(V(Ee,2));N(Ce),N(_e);var Re=V(_e,2),ze=e=>{var t=Na(),n=V(R(t),2),a=e=>{var t=Ma(),n=R(t),i=V(R(n),2);Zr(i,21,r,qr,(e,t,n)=>{var r=ja(),i=R(r),a=R(i),o=B(a,!0);N(i);var s=V(i),c=B(s),l=V(s),u=B(l),d=B(V(l),!0);N(r),H((e,r)=>{Z(a,`datetime`,G(t).at),Y(o,e),Y(c,`${r??``}%`),Y(u,`${G(t).used??``}%`),Y(d,n===0?`First observation`:G(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>ha(G(t).at),()=>G(t).elapsed.toFixed(1)]),J(e,r)}),N(i),N(n),N(t),J(e,t)};X(n,e=>{G(i)&&e(a)}),N(t),zi(`open`,`toggle`,t,e=>L(i,e),()=>G(i)),J(e,t)};X(Re,e=>{r().length&&e(ze)}),H((e,r,i,a,o,s)=>{Z(O,`viewBox`,`0 0 ${G(l)} ${G(u)}`),Z(O,`aria-label`,e),ne=fi(O,``,ne,{"--trend-color":G(E)?.safe?`#115b35`:`#7f1825`}),Z(re,`id`,n),Z(ie,`id`,n+`-trend-arrow`),Z(ae,`width`,G(p)),Z(ae,`height`,G(m)),Z(ae,`fill`,`url(#${n})`),Z(ce,`d`,`M48 20 V${G(f)} H${G(d)}`),Z(le,`y1`,r),Z(le,`x2`,G(d)),Z(le,`y2`,i),Z(A,`x`,48+G(p)/2),Z(A,`y`,G(u)-5),Z(me,`cx`,G(h)),Z(me,`cy`,G(_)),Z(he,`cx`,G(h)),Z(he,`cy`,G(_)),Y(ge,`${t.used??``}% consumed // ${a??``}% of period elapsed`),Y(j,`${t.used??``}% USED // ${o??``}% TIME ELAPSED`),Y(M,s),ke.disabled=!G(C).halfHour,Y(Ae,`LAST 30 MINUTES${G(C).halfHour?``:` — UNAVAILABLE`}`),je.disabled=!G(C).hour,Y(Me,`LAST HOUR${G(C).hour?``:` — UNAVAILABLE`}`),Ne.disabled=!G(C).day,Y(Pe,`LAST 24 HOURS${G(C).day?``:` — UNAVAILABLE`}`),Fe.disabled=!G(C).window,Y(Ie,`FROM WINDOW START${G(C).window?``:` — NO TIME ELAPSED`}`),Y(Le,`HISTORY // ${G(D)??``}`)},[()=>`Pace: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${G(v)>0?`Above`:G(v)<0?`Below`:`On`} the steady-consumption line.${G(a)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>g(0),()=>g(100),()=>t.elapsed.toFixed(1),()=>t.elapsed.toFixed(1),()=>Math.abs(G(v))<.05?`ON PACE`:G(v)>0?`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:`BELOW THE LINE — WITHIN PACE`]),Ii(te,`clientWidth`,e=>L(l,e)),Ii(te,`clientHeight`,e=>L(u,e)),ji(Te,()=>G(a),e=>L(a,e)),_i(De,()=>G(o),e=>L(o,e)),J(e,ee),Ge()}var Ia=q(` `),La=q(`

      Quota refresh failed. Values below are the last successful observation.

      `),Ra=q(`

      `),za=q(`

      Expiry details unavailable. No listed expiry does not mean no expiry.

      `),Ba=q(`

      `),Va=q(`

      Read-only preview. Use the terminal to redeem a reset.

      The backend may return only some credits. This list does not establish + redemption order.

      `),Ha=q(` `,1),Ua=Mr(``),Wa=Mr(``),Ga=q(`
      `),Ka=q(`

      Cycle duration or reset date unavailable — position cannot be + plotted.

      `),qa=q(`
      EMPTYFULL
      `),Ja=q(`

      `,1),Ya=q(`
      `,1),Xa=q(`

      `),Za=q(`

      `),Qa=q(`

      No quota windows reported yet.

      `),$a=q(`
      `,1),eo=q(`

      All reported windows are shown. API-equivalent learning and quota status + scoring remain in the terminal for this first preview.

      `,1),to=q(` `,1);function no(e,t){We(t,!0);let n=Q(t,`params`,19,()=>({})),r=P(()=>ta.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=I(Xt(Date.now())),a=P(()=>G(r).includes(na(n().view))?na(n().view):`bars`);Ki(()=>{let e=setInterval(()=>L(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-G(i))/(e.duration*6e4))))}yn(()=>{oa.view=G(a),(n().view===`zone`||n().view===`consumption-pace`)&&Qi(`/quota/pace`)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=to(),l=z(c);Zr(l,21,()=>G(r),qr,(e,t)=>{var n=Ia();let r;var i=B(n,!0);H(e=>{Z(n,`href`,`#/quota/`+G(t)),Z(n,`aria-current`,G(a)===G(t)?`page`:void 0),r=ui(n,1,``,null,r,{active:G(a)===G(t)}),Y(i,e)},[()=>G(t)===`fuel`?`FUEL TANK`:G(t).toUpperCase()]),J(e,n)}),N(l);var u=V(l,2),d=e=>{var t=eo(),n=z(t),r=e=>{J(e,La())};X(n,e=>{$.data.quotaError&&e(r)});var i=V(n,2),c=e=>{var t=Ra(),n=B(t);H(()=>Y(n,`Last usage accounting issue: + ${$.data.usageDiagnostic??``}`)),J(e,t)};X(i,e=>{$.data.usageDiagnostic&&e(c)});var l=V(i,2),u=B(l),d=V(l,2),f=e=>{Ta(e,{})},p=e=>{var t=Va(),n=R(t),r=B(n),i=V(n,4),a=e=>{J(e,za())};X(i,e=>{$.data.credits.length||e(a)}),Zr(V(i,2),17,()=>$.data.credits,qr,(e,t)=>{var n=Ba(),r=R(n),i=B(r),a=B(V(r,2),!0);N(n),H(e=>{Y(i,`${(G(t).title||`Quota reset`)??``} // ${G(t).status??``}`),Y(a,e)},[()=>G(t).expiryKnown?G(t).expires?`EXPIRES `+ha(G(t).expires):`Does not expire`:`Expiry information unavailable`]),J(e,n)}),Se(2),N(t),H(()=>Y(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),J(e,t)},m=e=>{var t=$a(),n=z(t);let r;Zr(n,21,()=>$.data.meters,qr,(e,t)=>{let n=P(()=>o(G(t)));var r=Za(),i=R(r),c=B(i,!0),l=V(i,2),u=R(l),d=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`FREE ${100-G(t).used}%`),Y(a,`USED ${G(t).used??``}%`)}),J(e,n)},f=e=>{var n=Ha(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`USED ${G(t).used??``}%`),Y(a,`FREE ${100-G(t).used}%`)}),J(e,n)};X(u,e=>{G(a)===`fuel`?e(d):e(f,-1)}),N(l);var p=V(l,2);let m;var h=R(p),g=e=>{var n=Ga(),r=R(n),i=V(R(r)),a=e=>{J(e,Ua())},o=e=>{var n=Wa();H(e=>Z(n,`d`,e),[()=>s(G(t).used)]),J(e,n)};X(i,e=>{G(t).used>=100?e(a):G(t).used>0&&e(o,1)}),N(r),N(n),H(()=>Z(r,`aria-label`,`${G(t).used}% quota used`)),J(e,n)},_=e=>{var r=Pr(),i=z(r),a=e=>{{let r=P(()=>G(t).trail||[]);Fa(e,{get used(){return G(t).used},get elapsed(){return G(n)},get trail(){return G(r)},get duration(){return G(t).duration}})}},o=e=>{J(e,Ka())};X(i,e=>{G(n)===null?e(o,-1):e(a)}),J(e,r)},v=e=>{var r=Ya(),i=z(r),o=R(i);let s;N(i);var c=V(i,2),l=e=>{J(e,qa())};X(c,e=>{G(a)===`fuel`&&e(l)});var u=V(c,2),d=e=>{var t=Ja(),r=z(t),i=B(r),o=V(r,2),s=R(o);let c;N(o),H(e=>{Y(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=fi(s,``,c,{width:`${G(a)===`fuel`?100-G(n):G(n)}%`})},[()=>Math.floor(G(n))]),J(e,t)};X(u,e=>{G(n)!==null&&e(d)}),H(()=>{Z(i,`aria-label`,G(a)===`fuel`?`Fuel remaining`:`Quota used`),Z(i,`aria-valuenow`,G(a)===`fuel`?100-G(t).used:G(t).used),s=fi(o,``,s,{width:`${G(a)===`fuel`?100-G(t).used:G(t).used}%`})}),J(e,r)};X(h,e=>{G(a)===`pie`?e(g):G(a)===`pace`?e(_,1):e(v,-1)}),N(p);var y=V(p,2),b=B(y),x=V(y,2),S=e=>{var n=Xa(),r=B(n,!0);H(()=>Y(r,G(t).details)),J(e,n)};X(x,e=>{G(t).details&&e(S)}),N(r),H(e=>{Y(c,G(t).name),m=ui(p,1,`meter-graphic`,null,m,{"bar-graphic":G(a)===`bars`||G(a)===`fuel`}),Y(b,`RESETS // ${e??``}`)},[()=>ha(G(t).reset)]),J(e,r)}),N(n);var i=V(n,2),c=e=>{J(e,Qa())};X(i,e=>{$.data.meters.length||e(c)}),H(()=>r=ui(n,1,`quota-grid`,null,r,{radial:G(a)===`pie`,zone:G(a)===`pace`})),J(e,t)};X(d,e=>{G(a)===`thresholds`?e(f):G(a)===`resets`?e(p,1):e(m,-1)}),Se(2),H(e=>Y(u,`QUOTA // OBSERVED ${e??``}`),[()=>ha($.data.quotaAt)]),J(e,t)};X(u,e=>{$.data&&e(d)}),J(e,c),Ge()}var ro=q(`
      `),io=q(`

      `,1);function ao(e,t){We(t,!0);let n=Q(t,`values`,19,()=>[]),r=Q(t,`label`,3,`Token activity`),i=Q(t,`capacity`,3,0),a=P(()=>Math.max(0,...n())),o=P(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=io(),c=z(s),l=B(c),u=V(c,2);Zr(u,21,()=>G(o),qr,(e,t)=>{var n=ro();let r;H((e,t)=>{Z(n,`title`,e),r=fi(n,``,r,{height:t})},[()=>G(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*G(t)/Math.max(1,G(a))}%`]),J(e,n)}),N(u),H((e,t)=>{Y(l,`SCALE // 0 — ${e??``} TOKENS`),Z(u,`aria-label`,t)},[()=>G(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${G(a).toLocaleString(`en-GB`)} tokens.`]),J(e,s),Ge()}function oo(e){if(!e||![`LAST REPLY`,`LAST ACTIVITY`].includes(e.contextKind))return``;let t=e.text||e.contextKind===`LAST ACTIVITY`&&e.workingCommand||``;return t.trim()?t:``}var so=q(` `),co=q(``),lo=q(`

      `),uo=q(`

      `,1),fo=q(`

      `),po=q(`

      Loading / sending…

      `),mo=q(`
      `),ho=q(`

      `),go=q(`

       
      `),_o=q(`
      `),vo=q(`
      `),yo=q(`

      Review expired. Press Enter to review again.

      `),bo=q(`

      `,1),xo=q(`

      `,1),So=q(`

      No available matching commands.

      `),Co=q(` `,1),wo=q(`

      `),To=q(`

      Review expired. Review the option again.

      `),Eo=q(``),Do=q(``),Oo=q(``),ko=q(``),Ao=q(``),jo=q(``),Mo=q(`
      `),No=q(`
      `);function Po(e,t){let n=Fr();We(t,!0);let r=e=>{var t=Pr();Zr(z(t),19,()=>G(A),e=>e.id,(e,t,r)=>{var i=co();let o;var s=R(i),c=B(s,!0),l=V(s),u=B(l),d=V(l),f=e=>{var n=so(),r=B(n,!0);H(()=>Y(r,G(t).help)),J(e,n)};X(d,e=>{(G(v)?.path===``||G(le))&&e(f)}),N(i),H((e,s)=>{Z(i,`id`,`${n}-${G(r)}`),Z(i,`role`,G(le)?`option`:void 0),Z(i,`aria-selected`,G(le)?G(T)===G(r):void 0),Z(i,`tabindex`,G(le)?-1:void 0),i.disabled=G(g)||G(_e)&&!a(),Z(i,`title`,G(t).help),Z(i,`aria-label`,e),o=ui(i,1,`svelte-7bfwr9`,null,o,{suggested:G(T)===G(r)}),Y(c,G(t).label),Y(u,`${G(le)&&G(t).selected?` // CURRENT`:``}${s??``}`)},[()=>G(t).label+(G(le)&&G(t).selected?` // CURRENT`:``)+ae(G(t)),()=>ae(G(t))]),Sr(`focus`,i,()=>{G(le)||j(G(r))}),K(`click`,i,()=>{j(G(r)),xe(G(t))}),J(e,i)}),J(e,t)},i=Q(t,`query`,3,``),a=Q(t,`localOnly`,3,!1),o=Q(t,`oncopy`,3,()=>{}),s=Q(t,`onchange`,3,()=>{}),c=Q(t,`oncomplete`,3,e=>{}),l=[`statusline`,`usage`,`copy`,`theme`,`exit`,`quit`];function u(){return[{id:`local-statusline`,label:`/statusline`,help:`Choose fields for Codexometer’s detail footer.`,next:`statusline`},{id:`local-usage`,label:`/usage`,help:`Open Codexometer’s usage history. Quota and reset views remain available.`,next:`usage`},{id:`local-copy`,label:`/copy`,help:`Copy the selected session’s observed reply or activity with its Copy control.`,next:`copy`},{id:`local-theme`,label:`/theme`,help:`Open the existing Codexometer theme selector. Saved browser display preferences only.`,next:`theme`},{id:`local-exit`,label:`/exit`,help:`Leave session detail and return to Sessions. The local server remains running.`,next:`exit`},{id:`local-quit`,label:`/quit`,help:`Alias for /exit: return to Sessions. The local server remains running.`,next:`quit`}]}function d(){return{title:`/ COMMANDS`,help:`Local Codexometer commands remain available without session control.`,path:``,revision:``,choices:u()}}function f(){L(b,``),L(O,``),L(x,0),L(ne,[],!0)}function p(){w++,L(g,!1),L(h,!1),L(E,i()),f(),L(_,``),G(fe)?s()():c()(i())}async function m(e){if(!l.includes(e))return!1;if(e===`copy`&&!oo($.data?.sessions.find(e=>e.id===t.session)))return L(_,`No reply or activity text is available to copy for this session.`),!0;if(e===`copy`){let e=o()();p(),await e}else p(),e===`usage`?location.hash=`/usage`:e===`theme`?ca.requests++:e===`statusline`?sa.open=!0:location.hash=`/sessions`;return!0}let h=I(!1),g=I(!1),_=I(``),v=I(null),y=I(null),b=I(``),x=I(0),S=I(Xt(Date.now())),C=I(``),w=0,T=I(0),E=I(null),D=I(void 0),ee=I(void 0),te=I(void 0),O=I(``),ne=I(Xt([]));function k(e){return[`rename/`,`cd/`,`goal/set/`,`goal/edit/`,`goal/budget/`].some(t=>e.startsWith(t))}let re=P(()=>k(G(v)?.path||``)),ie=P(()=>!!G(y)&&!G(re)||!!G(O)||G(ne).length>0);function ae(e){return e.unavailable?e.unavailable.startsWith(`Waiting for idle.`)?` // WAITING FOR IDLE`:` // UNAVAILABLE`:e.next?` →`:e.action?``:` // HELP`}async function oe(e){G(v)&&!(G(ve)&&G(pe))&&L(ne,[...G(ne),{path:G(v).path,index:G(T),input:G(C)}],!0),await be(e)}async function se(){if(!G(ie))return;if(w++,L(g,!1),L(b,``),L(x,0),L(_,``),G(O)){L(O,``),G(D)?.focus();return}if(G(y)&&!G(re)){L(y,null),await ur(),G(D)?.focus();return}let e=G(ne).at(-1);e&&(L(ne,G(ne).slice(0,-1),!0),await be(e.path,e))}function ce(){G(v)&&G(C).trim()&&!G(g)&&!G(_e)&&oe(G(v).path+`/`+encodeURIComponent(G(C).trim()))}let le=P(()=>G(h)&&!!G(v)?.picker&&!G(y)),ue=P(()=>G(h)&&!G(v)?.input&&!G(y)),de=setInterval(()=>{L(S,Date.now(),!0)},1e3);qi(()=>{clearInterval(de),w++});let fe=P(()=>i().trim().startsWith(`/`)&&!i().trim().startsWith(`//`)),pe=P(()=>G(v)?.path===``&&G(fe)?i().trim().slice(1).toLowerCase():``),A=P(()=>(G(v)?.choices||[]).filter(e=>!G(pe)||e.label.toLowerCase().startsWith(`/`+G(pe)))),me=P(()=>G(y)||G(A)[G(T)]),he=P(()=>!!G(b)&&G(S)G(A).find(e=>e.id===G(O))),_e=P(()=>!$.connected||!!$.data?.sessionsError),ve=P(()=>G(h)&&G(fe)&&(!G(v)||G(v).path===``)&&!G(y));yn(()=>{i(),L(T,0)}),yn(()=>{let e=G(T);G(A),G(ue)&&ur().then(()=>{let t=G(D)?.children[e];if(!t||!G(D))return;let n=G(D).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(G(D).scrollTop+=r.bottom-n.bottom)})});function j(e){G(T)!==e&&G(v)?.picker&&(L(O,``),L(b,``),L(x,0),L(_,``),w++),L(T,e,!0)}function ye(){w++,L(g,!1),L(h,!1),L(E,i()),f(),c()(i())}function M(e){let t=!!G(ee)?.contains(e.target);if(!G(h)||!G(ue)&&!G(y)&&!G(v)?.input||!G(fe)&&!t||G(_e)&&!a()||e.isComposing||e.ctrlKey||e.metaKey||e.altKey)return;if(G(v)?.input){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ye());return}let n=e.key===`ArrowLeft`,r=e.key.toLowerCase()===`f`,o=e.key.toLowerCase()===`c`;if((o||r||n)&&!t||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!o&&!r&&!n||e.key===`Tab`&&(G(y)||G(v)?.path!==``||e.shiftKey)||e.key===`Enter`&&e.target instanceof Element&&e.target.closest(`button`)&&!G(D)?.contains(e.target)&&!e.target.closest(`[data-command-confirm]`)||G(y)&&!t||G(y)&&[`ArrowUp`,`ArrowDown`].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){ye();return}if(G(g)||e.repeat&&(o||e.key===`Enter`))return;if(n){G(ie)&&se();return}if(r){be(G(v)?.path||``,void 0,!0);return}if(o){(G(y)?.action||G(le)&&G(O))&&Ce();return}if(G(y)){e.key===`Enter`&&G(y).action&&!G(he)&&!G(_)&&Se(G(y));return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){j(Math.min(Math.max(G(T)+(e.key===`ArrowUp`?-1:1),0),Math.max(G(A).length-1,0))),!G(le)&&G(D)?.contains(e.target)&&ur().then(()=>(G(D)?.children[G(T)])?.focus());return}if(e.key===`Enter`&&(G(v)?.path===``||G(v)?.path===`goal`)&&/^\/goal\s+\S/.test(i().trim())){oe(i().trim().slice(1));return}let s=G(A)[G(T)];s&&(e.key===`Tab`?c()(s.label):G(le)?Se(s):xe(s))}yn(()=>{G(_e)&&!a()&&(w++,L(g,!1),f(),G(h)&&(L(h,!1),L(E,i())),L(v,null),L(y,null))}),yn(()=>{G(fe)&&!G(h)&&i()!==G(E)&&(!G(_e)||a())&&(f(),L(h,!0),be(``))});async function be(e,n,r=!1){let i=++w;if(G(v)&&L(v,{...G(v),path:e},!0),n&&L(C,n.input,!0),L(g,!0),L(y,null),L(O,``),L(b,``),L(x,0),L(_,``),a())L(v,d(),!0),L(T,n?.index??0,!0),L(g,!1);else try{let a=await ya(`commands`,{session:t.session,command:{mode:`list`,path:e,...r?{refresh:!0}:{}}});i===w&&((e===``||e===`help`)&&(a.choices=[...a.choices.filter(e=>!l.includes(e.label.replace(/^\//,``))),...u()]),L(v,a,!0),L(T,n?Math.min(n.index,Math.max(a.choices.length-1,0)):a.picker?Math.max(a.choices.findIndex(e=>e.selected),0):0,!0),a.picker&&ur().then(()=>G(D)?.focus()),L(C,n?.input??a.value??``,!0),n&&ur().then(()=>{a.input?G(ee)?.querySelector(`input`)?.focus():G(D)?.focus()}),k(a.path)&&a.choices.length===1&&(L(g,!1),xe(a.choices[0])))}catch{i===w&&(L(_,`Command catalogue unavailable. Use Codex.`),e===``||e===`help`?(L(v,d(),!0),L(_,``)):L(v,{title:`/`+e,help:``,path:e,revision:``,choices:[]},!0))}finally{i===w&&L(g,!1)}}async function xe(e){e.unavailable||G(g)||e.next&&await m(e.next)||G(_)||(G(v)?.picker?(j(G(A).findIndex(t=>t.id===e.id)),e.action&&(e.reversible||$.data?.noConfirm)?await Se(e):G(D)?.focus()):e.next?await oe(e.next):await Se(e))}async function Se(e){if(G(g)||G(_e)||!G(v)||e.unavailable||G(_))return;let n=e.action&&(e.reversible||$.data?.noConfirm);if(G(v).picker){if(G(he)&&G(O)===e.id)return;L(O,e.id,!0)}else n||(L(y,e,!0),ur().then(()=>G(te)?.focus()));if(L(b,``),L(x,0),L(_,``),!e.action)return;let r=++w;L(g,!0);try{let n=await ya(`commands`,{session:t.session,command:{mode:`prepare`,path:G(v).path,revision:G(v).revision,choice:e.id}});if(r===w){let e=Date.parse(n.expires);if(!n.confirmation||!Number.isFinite(e)||Date.now()>=e)throw Error(`Review confirmation unavailable`);L(b,n.confirmation,!0),L(x,e,!0)}}catch{r===w&&L(_,`Option changed or unavailable. Refresh before retrying.`)}finally{r===w&&L(g,!1)}n&&r===w&&G(b)&&await Ce()}async function Ce(){if(!G(b)||G(_e)||G(g)||Date.now()>=G(x)||!G(v)||G(v).picker&&G(O)!==G(A)[G(T)]?.id)return;let e=G(b);L(b,``),L(g,!0);let n=++w;try{let r=await ya(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:G(v).path}});n===w&&(L(_,r.message,!0),L(h,!1),L(v,null),L(y,null),f(),L(E,null),s()())}catch{n===w&&L(_,`Change unconfirmed. Check Codex before retrying.`)}finally{n===w&&L(g,!1)}}var we={handleKey:M},Te=No(),Ee=R(Te),De=V(Ee,2),Oe=e=>{var t=lo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(De,e=>{G(_)&&!G(h)&&e(Oe)});var ke=V(De,2),Ae=e=>{var i=Mo();let o;var s=R(i),c=e=>{var t=uo(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(v)?.title||`/ COMMANDS`),Y(i,G(v)?.help||`Loading live options…`)}),J(e,t)};X(s,e=>{G(ve)||e(c)});var l=V(s,2),u=e=>{var t=fo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(l,e=>{G(_)&&e(u)});var d=V(l,2),f=e=>{J(e,po())};X(d,e=>{G(g)&&e(f)});var p=V(d,2),m=e=>{var t=mo(),r=R(t),i=R(r),o=V(i);Ci(o),N(r),N(t),H(e=>{Z(t,`id`,`${n}-input`),Y(i,`${e??``} `),Z(o,`aria-label`,G(v).inputLabel||`Session name`),Z(o,`maxlength`,G(v).inputLimit||512),o.disabled=G(g)||G(_e)&&!a()},[()=>(G(v).inputLabel||`Session name`).toUpperCase()]),Sr(`submit`,t,e=>{e.preventDefault(),ce()}),Oi(o,()=>G(C),e=>L(C,e)),J(e,t)},h=e=>{var n=go(),r=R(n),i=B(r,!0),a=V(r,2),o=B(a,!0),s=V(a,2),c=e=>{var n=ho(),r=R(n),i=V(r),a=e=>{J(e,Nr(`Only this session's saved + name changes.`))},o=P(()=>G(v)?.path.startsWith(`rename/`)),s=e=>{J(e,Nr(`Only this session’s + directory changes; project configuration is not reloaded.`))},c=P(()=>G(v)?.path.startsWith(`cd/`)),l=e=>{J(e,Nr(`Only this session's goal + changes. Active pursuit may immediately start further turns and + consume quota.`))},u=P(()=>G(v)?.path.startsWith(`goal/`)),d=e=>{J(e,Nr(`No change sent yet. Model, reasoning and speed settings can + change token usage and cost. Changes affect subsequent turns of + this session, not global defaults. Automatic quota thresholds + may later supersede model settings.`))};X(i,e=>{G(o)?e(a):G(c)?e(s,1):G(u)?e(l,2):e(d,-1)}),N(n),H(()=>Y(r,`TARGET // ${t.session??``}. `)),J(e,n)};X(s,e=>{G(y).action&&e(c)}),N(n),Ri(n,e=>L(te,e),()=>G(te)),H(()=>{Y(i,G(y).label),Y(o,G(y).help||`No additional help supplied by Codex.`)}),J(e,n)},w=e=>{var t=Co(),i=z(t),a=e=>{var t=_o(),i=R(t);r(i),N(t),Ri(t,e=>L(D,e),()=>G(D)),H(()=>Z(t,`aria-activedescendant`,`${n}-${G(T)}`)),J(e,t)},o=e=>{var t=vo();let n;var i=R(t);r(i),N(t),Ri(t,e=>L(D,e),()=>G(D)),H(()=>n=ui(t,1,`command-options svelte-7bfwr9`,null,n,{vertical:G(ve)})),J(e,t)};X(i,e=>{G(le)?e(a):e(o,-1)});var s=V(i,2),c=e=>{var t=xo(),n=z(t),r=B(n,!0),i=V(n,2),a=e=>{var t=bo(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,yo())};X(i,e=>{G(b)&&G(S)>=G(x)&&e(a)}),H(()=>Y(r,`REVIEW // ${G(ge).label??``}. No change sent yet.`)),J(e,t)};X(i,e=>{G(ge)&&e(a)}),H(()=>Y(r,G(A)[G(T)]?.help)),J(e,t)};X(s,e=>{G(le)&&e(c)});var l=V(s,2),u=e=>{J(e,So())};X(l,e=>{!G(g)&&!G(A).length&&e(u)}),J(e,t)};X(p,e=>{G(v)?.input?e(m):G(y)?e(h,1):e(w,-1)});var E=V(p,2),O=e=>{var t=wo(),n=B(t,!0);H(()=>Y(n,G(me).unavailable)),J(e,t)};X(E,e=>{G(me)?.unavailable&&e(O)});var ne=V(E,2),k=e=>{J(e,To())};X(ne,e=>{G(b)&&G(S)>=G(x)&&!G(le)&&e(k)});var re=V(ne,2),ae=R(re),oe=e=>{var t=Pr(),r=z(t),i=e=>{var t=Eo(),r=B(t,!0);H(e=>{Z(t,`form`,`${n}-input`),t.disabled=e,Y(r,G(v).reversibleInput||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)},[()=>G(g)||G(_e)||!G(C).trim()]),J(e,t)},o=e=>{var t=Pr(),n=z(t),r=e=>{var t=Do();H(()=>t.disabled=G(g)||G(_e)&&!a()),K(`click`,t,Ce),J(e,t)},i=e=>{var t=Oo(),n=B(t,!0);H(()=>{t.disabled=G(g)||G(_e)&&!a(),Y(n,G(me).reversible||$.data?.noConfirm?`ENTER APPLY`:`ENTER REVIEW`)}),K(`click`,t,()=>{G(me)&&Se(G(me))}),J(e,t)};X(n,e=>{G(he)&&!G(me).reversible&&!$.data?.noConfirm?e(r):e(i,-1)}),J(e,t)},s=e=>{var t=Oo(),n=B(t);H(()=>{t.disabled=G(g)||G(_e)&&!a(),Y(n,`ENTER ${G(me).next?`OPEN`:`HELP`}`)}),K(`click`,t,()=>{G(me)&&xe(G(me))}),J(e,t)};X(r,e=>{G(v)?.input?e(i):G(me)?.action&&!G(me).unavailable?e(o,1):!G(y)&&G(me)&&!G(me).unavailable&&e(s,2)}),J(e,t)};X(ae,e=>{G(_)||e(oe)});var ue=V(ae,2),de=e=>{var t=ko();H(()=>t.disabled=G(g)),K(`click`,t,se),J(e,t)};X(ue,e=>{G(ie)&&e(de)});var fe=V(ue,2),pe=e=>{var t=Ao();H(()=>t.disabled=G(g)),K(`click`,t,()=>be(G(v)?.path||``,void 0,!0)),J(e,t)};X(fe,e=>{G(ve)||e(pe)});var j=V(fe,2);N(re);var we=V(re,2),Te=e=>{var t=jo(),n=B(t);H(()=>Y(n,`↑/↓ select${G(ve)?` · Tab complete`:``}`)),J(e,t)};X(we,e=>{!G(v)?.input&&!G(y)&&e(Te)}),N(i),Ri(i,e=>L(ee,e),()=>G(ee)),H(()=>{Z(i,`aria-label`,G(ve)?`Slash command suggestions`:`Session command options`),o=ui(i,1,`svelte-7bfwr9`,null,o,{"command-popup":G(ve)})}),K(`keydown`,i,M),K(`click`,j,ye),J(e,i)};return X(ke,e=>{G(h)&&e(Ae)}),N(Te),H(()=>Ee.disabled=G(_e)&&!a()||G(g)),K(`click`,Ee,()=>{L(h,!G(h)),L(E,G(h)?null:i(),!0),L(b,``),G(h)?(L(ne,[],!0),be(``)):ye()}),J(e,Te),Ge(we)}Cr([`click`,`keydown`]);var Fo=q(` `,1),Io=q(`
      `),Lo=q(`
      /
      `);function Ro(e,t){We(t,!0);let n=P(()=>t.lines.filter(e=>e.kind===`addition`).length),r=P(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=Lo(),a=R(i),o=R(a),s=B(o),c=B(V(o,2));N(a),Zr(V(a,2),17,()=>t.lines,qr,(e,t)=>{var n=Io();let r;var i=R(n),a=e=>{var n=Fo(),r=z(n),i=B(r,!0),a=B(V(r),!0);H(()=>{Y(i,G(t).old||``),Y(a,G(t).new||``)}),J(e,n)};X(i,e=>{G(t).kind!==`heading`&&G(t).kind!==`metadata`&&e(a)});var o=B(V(i),!0);N(n),H(()=>{r=ui(n,1,`diff-line svelte-x4gtb6`,null,r,{added:G(t).kind===`addition`,removed:G(t).kind===`removal`,heading:G(t).kind===`heading`}),Y(o,G(t).text)}),J(e,n)}),N(i),H(()=>{Z(a,`aria-label`,`${G(n)} lines added, ${G(r)} lines removed`),Y(s,`+${G(n)??``}`),Y(c,`−${G(r)??``}`)}),J(e,i),Ge()}var zo=q(`

      `),Bo=q(`

      Send this saved prompt now? This starts Codex work and consumes quota.

      `,1),Vo=q(``),Ho=q(`

       

      In memory only. Follows session model, reasoning and speed. Closing + Codexometer cancels pending work.

      `),Uo=q(`

      CURRENT PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      PROPOSED PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      Applied settings remain after Codexometer closes.

      `,1),Wo=q(`

      `),Go=q(`

       
      `,1),Ko=q(`

      Command unavailable from this observation. Open Codex to inspect the + request.

      `),qo=q(`

      Session controls temporarily unavailable. Check Codex for current state.

      `),Jo=q(`

      Checking session controls…

      `),Yo=q(`

      `),Xo=q(`
      About browser controls

      Controls require a supported live request from a connected shared + app-server session. Local observations alone cannot provide them.

      `),Zo=q(` `,1),Qo=q(` `),$o=q(`Grants permission beyond this one action. Check the scope + carefully.`),es=q(``),ts=q(``),ns=q(``),rs=q(``),is=q(`

      Not before this time; when quota and idle allow.

      `),as=q(`

      `,1),os=q(`

      The existing trigger remains active until saved or deleted. If + it changes or sends while you edit, saving is blocked.

      `),ss=q(` `,1),cs=q(``),ls=q(``),us=q(``),ds=q(` `,1),fs=q(`
    • `),ps=q(`
      View fixed choices

      Type one of these choices exactly. Your answer stays masked.

        `),ms=q(` `,1),hs=q(`

        `),gs=q(`

        `,1),_s=q(` `,1),vs=q(``),ys=q(`

        `,1),bs=q(`

        `);function xs(e,t){We(t,!0);let n=[],r=Q(t,`observedCommand`,3,``),i=Q(t,`observedFileChanges`,19,()=>[]),a=Q(t,`review`,3,``),o=Q(t,`suspended`,3,!1),s=Q(t,`openScheduler`,3,!1),c=Q(t,`onProtectedChange`,3,e=>{}),l=Q(t,`oncopy`,3,()=>{}),u=I(null),d=I(Xt([])),f=I(null),p=I(``),m=I(0),h=I(Xt(Date.now())),g=I(!1),_=I(``),v=I(!1),y=I(!1),b=I(``),x=I(!1),S=I(``),C=I(!1),w=I(``),T=I(`now`),E=I(60),D=I(``),ee=I(!1),te=I(``),O=I(Xt([])),ne=P(()=>G(O).find(e=>e.status!==`sent`)),k=I(void 0),re=I(void 0);function ie(e){if(G(x)){ur().then(()=>G(k)?.focus());return}if(e.status!==`pending`||G(g)||!G(u)?.id||G(u).kind!==`prompt`||G(u).questions?.length)return;L(x,!0),L(S,e.id,!0),ur().then(()=>G(k)?.focus()),L(d,[e.text],!0),L(T,e.trigger===`quota`?`quota`:`at`,!0),L(p,``),L(w,``);let t=new Date(e.at);e.trigger!==`quota`&&L(D,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}yn(()=>{s()&&G(ne)&&!G(C)&&G(u)?.id&&G(u).kind===`prompt`&&!G(u).questions?.length&&(L(C,!0),ie(G(ne)))});async function ae(){if(!a())try{L(O,await ya(`schedules`,{session:t.session},j.signal),!0),G(x)&&!G(O).some(e=>e.id===G(S)&&e.status===`pending`)&&L(p,``),G(w)&&!G(O).some(e=>e.id===G(w)&&e.status===`pending`)&&(L(p,``),L(w,``))}catch{}}async function oe(e){try{L(O,await ya(`schedules`,{session:t.session,cancelId:e},j.signal),!0),L(x,!1),L(p,``),L(w,``),L(d,[],!0)}catch(e){L(_,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}yn(()=>(c()(G(g)||G(d).some(e=>e.length>0)),()=>c()(!1)));let se=P(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),ce=P(()=>!$.connected||!!$.data?.sessionsError),le=P(()=>a()!==`profile`&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ue=P(()=>!G(ce)&&!G(y)&&!!G(u)?.id&&G(u).kind===`approval`&&G(b)!==G(u).id),de=P(()=>G(ue)?G(u).command:r()),fe=P(()=>!!G(p)&&G(h)G(u)?.questions?.length?G(u).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),A=P(()=>G(u)?.kind===`approval`||G(u)?.kind===`profile`?G(f)!==null:G(d).length===G(pe).length&&G(d).every((e,t)=>e.trim().length>0&&(G(pe)[t].freeText||G(pe)[t].options?.includes(e)))),me=P(()=>G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`),he=P(()=>G(T)===`delay`?G(h)+G(E)*6e4:Date.parse(G(D))),ge=P(()=>{if(!G(me))return``;if(G(x)&&!G(O).some(e=>e.id===G(S)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!G(d)[0]?.trim())return`Enter a message to schedule.`;if(G(T)===`quota`)return``;if(!Number.isFinite(G(he))||G(he)<=G(h))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(G(h));return e.setFullYear(e.getFullYear()+1),G(he)>=e.getTime()?`Choose a time within one year.`:``});function _e(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ve(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>G(h))return`Due in `+Math.ceil((Date.parse(e.at)-G(h))/6e4)+` min`;let t=G(ce)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}yn(()=>{(G(ce)||o()||G(le)||G(h)>=G(m))&&L(p,``)});let j=new AbortController;Ki(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&G(ne)&&(e.preventDefault(),ie(G(ne)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{L(h,Date.now(),!0)},1e3);async function i(){await ae();try{let e=await ya(`offer`,{session:t.session,...a()?{review:a()}:{}},j.signal);if(j.signal.aborted)return;L(y,!1),G(u)?.id!==e.id&&(L(p,``),L(f,null),L(d,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),L(u,e,!0),G(v)&&e.id&&e.id!==G(b)&&(L(_,``),L(v,!1))}catch{j.signal.aborted||(L(u,null),L(y,!0),L(p,``))}finally{j.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),j.abort(),clearTimeout(n),clearInterval(r)}});async function ye(e){if(!e&&G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(d)[0]?.trim().startsWith(`/`)&&!G(d)[0]?.trim().startsWith(`//`)){L(_,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!G(u)?.id||G(g)||G(ce)||o()||G(le)||(e?!e.canSend:!G(A)||G(ge)))return;let n=G(u).id;L(g,!0),L(_,``),L(v,!1),L(p,``),L(w,e?.id||``,!0);try{let r=!e&&G(u).kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`?{trigger:G(T)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...G(T)===`quota`?{}:{at:(G(T)===`delay`?new Date(Date.now()+G(E)*6e4):new Date(G(D))).toISOString()}}:void 0;L(ee,!!r),L(te,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:_e(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await ya(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&G(x)?{editId:G(S)}:{},...G(u).kind===`approval`||G(u).kind===`profile`?{choice:G(f)}:{answers:e?[e.text]:[...G(d)]}},j.signal);G(u)?.id!==n||j.signal.aborted||G(ce)||o()||G(le)||(L(p,i.confirmation,!0),L(m,Date.parse(i.expires),!0))}catch(e){j.signal.aborted||L(_,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{L(g,!1)}$.data?.noConfirm&&G(p)&&!j.signal.aborted&&await M()}async function M(){if(!G(u)?.id||G(g)||o()||G(le)||!G(fe))return;let e=G(u).id,n=G(u).kind,r=G(p);L(p,``),L(g,!0),L(b,e,!0);try{await ya(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},j.signal),L(v,!0),L(x,!1),G(ee)&&(L(b,``),await ae()),L(_,G(ee)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){L(_,e instanceof _a?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{L(g,!1),L(w,``),await ae(),L(d,[],!0),L(f,null)}}var be=Zo(),xe=z(be),Ce=e=>{var t=Pr();Zr(z(t),17,()=>G(O).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Ho(),r=R(n),i=B(r,!0),a=V(r,2),s=B(a),c=V(a,2),l=B(c,!0),d=V(c,2),f=B(d,!0),m=V(d,2),h=B(m,!0),v=V(m,2),y=e=>{var t=zo(),n=B(t,!0);H(()=>Y(n,G(_))),J(e,t)};X(v,e=>{G(_)&&e(y)});var b=V(v,4),x=V(b,2),S=V(x,2),C=e=>{var n=Bo(),r=V(z(n),2),i=V(r,2);H(()=>r.disabled=G(g)||G(ce)||!G(t).canSend),K(`click`,r,M),K(`click`,i,()=>{L(p,``),L(w,``)}),J(e,n)},T=e=>{var n=Vo();H(()=>n.disabled=G(g)||G(ce)||!G(t).canSend||o()),K(`click`,n,()=>ye(G(t))),J(e,n)};X(S,e=>{G(fe)&&G(w)===G(t).id?e(C):e(T,-1)}),N(n),H((e,n)=>{Y(i,G(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),Y(s,`TARGET // ${G(t).session??``}`),Y(l,e),Y(f,n),Y(h,G(t).text),b.disabled=G(g)||!G(u)?.id||G(u).kind!==`prompt`||!!G(u).questions?.length||G(t).status!==`pending`,x.disabled=G(g)||G(t).status===`sending`},[()=>G(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${_e(G(t).at)}`,()=>ve(G(t))]),K(`click`,b,()=>ie(G(t))),K(`click`,x,()=>oe(G(t).id)),J(e,n)}),J(e,t)},we=P(()=>!a()&&G(u)?.kind!==`approval`&&!G(u)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(se)||``));X(xe,e=>{G(we)&&e(Ce)});var Te=V(xe,2),Ee=e=>{var r=bs(),o=R(r),s=B(o,!0),c=V(o,2),S=e=>{var t=Uo(),n=z(t),r=B(n),i=V(n,6),a=B(i,!0),o=B(V(i,6),!0);Se(2),H(()=>{Y(r,`Your ${G(u).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),Y(a,G(u).profile.current),Y(o,G(u).profile.proposed)}),J(e,t)};X(c,e=>{G(u)?.profile&&!G(ce)&&!G(y)&&e(S)});var C=V(c,2),w=e=>{var t=Wo();let n;var r=B(t,!0);H(()=>{n=ui(t,1,`svelte-1oupzfc`,null,n,{notice:!G(v),sent:G(v)}),Y(r,G(_))}),J(e,t)};X(C,e=>{G(_)&&e(w)});var O=V(C,2),ne=e=>{Ro(e,{get lines(){return G(u).fileChanges}})},ie=e=>{Ro(e,{get lines(){return i()}})},ae=e=>{var t=Go(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(ue)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),Y(i,G(de))}),J(e,t)},oe=e=>{J(e,Ko())};X(O,e=>{G(u)?.fileChanges?.length&&!G(ce)&&!G(y)?e(ne):i().length?e(ie,1):G(de)?e(ae,2):a()!==`profile`&&G(se)===`APPROVAL NEEDED`&&!G(v)&&e(oe,3)});var le=V(O,2),me=e=>{J(e,qo())},ve=e=>{J(e,Jo())},j=e=>{var t=Zo(),n=z(t),r=e=>{var t=Yo(),n=B(t,!0);H(e=>Y(n,e),[()=>G(se)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(se)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),J(e,t)};X(n,e=>{(G(se)===`WORKING`||!G(v)&&!G(g))&&e(r)});var i=V(n,2),a=e=>{J(e,Xo())},o=P(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(se)||``)&&!G(v));X(i,e=>{G(o)&&e(a)}),J(e,t)},be=e=>{var r=ys(),i=z(r),o=B(i),s=V(i,2),c=R(s),_=B(c,!0),v=V(c,2),y=e=>{var r=Pr();Zr(z(r),17,()=>G(u).choices||[],qr,(e,r,i)=>{var o=es(),s=R(o);Ci(s),s.value=s.__value=i;var c=V(s),l=V(c),u=e=>{var t=Qo(),n=B(t,!0);H(()=>Y(n,G(r).detail)),J(e,t)};X(l,e=>{G(r).detail&&e(u)});var d=V(l,2),p=e=>{J(e,$o())};X(d,e=>{G(r).persistent&&e(p)}),N(o),H(()=>{Z(s,`name`,`decision-`+t.session+`-`+a()),Y(c,` ${G(r).label??``} `)}),Ai(n,[],s,()=>G(f),e=>L(f,e)),J(e,o)}),J(e,r)},b=e=>{var n=Zo(),r=z(n),i=e=>{var t=ss(),n=z(t),r=V(R(n)),i=R(r),a=e=>{var t=ts();t.value=t.__value=`now`,J(e,t)};X(i,e=>{G(x)||e(a)});var o=V(i);o.value=o.__value=`quota`;var s=V(o);s.value=s.__value=`delay`;var c=V(s);c.value=c.__value=`at`,N(r),gi(r),N(n);var l=V(n,2),u=e=>{var t=ns(),n=V(R(t));Ci(n),N(t),Oi(n,()=>G(E),e=>L(E,e)),J(e,t)};X(l,e=>{G(T)===`delay`&&e(u)});var d=V(l,2),f=e=>{var t=rs(),n=V(R(t));Ci(n),N(t),Oi(n,()=>G(D),e=>L(D,e)),J(e,t)};X(d,e=>{G(T)===`at`&&e(f)});var p=V(d,2),m=e=>{var t=as(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,is())};X(i,e=>{G(T)!==`quota`&&e(a)});var o=V(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. + One pending request per session; saving replaces it. Memory + only; Codexometer must stay running. Uses session model, + reasoning and speed.`,H(e=>Y(r,`Will send: ${e??``}`),[()=>G(T)===`quota`?`when quota is available and this session is idle`:Number.isFinite(G(he))?_e(G(he)):`choose a date and time`]),J(e,t)};X(p,e=>{G(T)!==`now`&&e(m)});var h=V(p,2),g=e=>{J(e,os())};X(h,e=>{G(x)&&e(g)}),_i(r,()=>G(T),e=>L(T,e)),J(e,t)};X(r,e=>{G(u).questions?.length||e(i)}),Zr(V(r,2),17,()=>G(pe),qr,(e,n,r)=>{var i=ms(),o=z(i),s=e=>{{let n=P(()=>G(d)[0]||``);Ri(Po(e,{get session(){return t.session},get oncopy(){return l()},get query(){return G(n)},oncomplete:e=>{L(d,[e],!0),ur().then(()=>G(k)?.focus())},onchange:()=>{L(d,[``],!0),ur().then(()=>G(k)?.focus())}}),e=>L(re,e,!0),()=>G(re))}};X(o,e=>{r===0&&a()!==`profile`&&G(u).kind===`prompt`&&!G(u).questions?.length&&e(s)});var c=V(o,2),f=R(c),p=V(f),m=e=>{var t=cs();Ci(t),Oi(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},h=e=>{var t=us(),i=R(t);i.value=i.__value=``,Zr(V(i),17,()=>G(n).options||[],qr,(e,t)=>{var n=ls(),r=B(n,!0),i={};H(()=>{Y(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=i)??``)}),J(e,n)}),N(t),gi(t),_i(t,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)},g=e=>{var t=ds(),i=z(t);nt(i),Ri(i,e=>L(k,e),()=>G(k));var a=V(i,2),o=e=>{var t=Yo(),r=B(t);H(e=>Y(r,`Suggested answers: ${e??``}`),[()=>G(n).options.join(` · `)]),J(e,t)};X(a,e=>{G(n).options?.length&&e(o)}),K(`keydown`,i,e=>{G(u)?.kind===`prompt`&&!G(u).questions?.length&&G(re)?.handleKey(e)}),Oi(i,()=>G(d)[r],e=>G(d)[r]=e),J(e,t)};X(p,e=>{G(n).secret?e(m):G(n).freeText?e(g,-1):e(h,1)}),N(c);var _=V(c,2),v=e=>{var t=ps(),r=V(R(t),4);Zr(r,21,()=>G(n).options||[],qr,(e,t)=>{var n=fs(),r=B(n,!0);H(()=>Y(r,G(t))),J(e,n)}),N(r),N(t),J(e,t)};X(_,e=>{G(n).secret&&!G(n).freeText&&e(v)}),H(()=>Y(f,`${G(n).text??``} `)),J(e,i)}),J(e,n)};X(v,e=>{G(u).kind===`approval`||G(u).kind===`profile`?e(y):e(b,-1)}),N(s);var S=V(s,2),C=e=>{var t=gs(),n=z(t),r=e=>{var t=hs(),n=B(t);H(()=>Y(n,`TRIGGER // ${G(te)??``}`)),J(e,t)};X(n,e=>{G(ee)&&e(r)});var i=V(n,2),a=B(i),o=V(i,2),s=B(o),c=V(o,2);H(e=>{Y(a,`Check the target and ${G(u).kind===`profile`?`profile above`:G(u).kind===`approval`?G(u).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${G(ee)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. + Confirmation expires in ${e??``}s.`),o.disabled=G(g)||G(ce),Y(s,`CONFIRM ${(G(u).kind===`approval`||G(u).kind===`profile`?G(u).choices?.[G(f)]?.label:G(ee)?G(x)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((G(m)-G(h))/1e3))]),K(`click`,o,M),K(`click`,c,()=>{L(p,``)}),J(e,t)},w=e=>{var t=_s(),n=z(t),r=e=>{var t=zo(),n=B(t,!0);H(()=>Y(n,G(ge))),J(e,t)};X(n,e=>{G(ge)&&e(r)});var i=V(n,2),a=B(i,!0);H(()=>{i.disabled=G(g)||G(ce)||!G(A)||!!G(ge),Y(a,G(g)?`SENDING…`:$.data?.noConfirm?G(x)?`SAVE CHANGES`:G(u).kind===`approval`||G(u).kind===`profile`?`SEND DECISION`:G(u).kind===`prompt`&&!G(u).questions?.length&&G(T)!==`now`?`SET TRIGGER`:`SEND`:G(x)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),K(`click`,i,()=>ye()),J(e,t)};X(S,e=>{G(fe)&&!$.data?.noConfirm?e(C):e(w,-1)});var O=V(S,2),ne=e=>{var t=vs();K(`click`,t,()=>{L(x,!1),L(p,``),L(d,[],!0)}),J(e,t)};X(O,e=>{G(x)&&e(ne)}),H(()=>{Y(o,`TARGET // ${G(u).thread??``} // ${(G(u).directory||`Directory unavailable`)??``}`),s.disabled=G(g)||G(fe)||G(ce),Y(_,G(u).kind===`approval`||G(u).kind===`profile`?`Choose a decision`:G(x)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),J(e,r)};X(le,e=>{G(ce)||G(y)?e(me):G(u)?G(u).id?G(b)!==G(u).id&&e(be,3):e(j,2):e(ve,1)}),N(r),H(()=>Y(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),J(e,r)};X(Te,e=>{!G(le)&&(!G(ne)||G(x)||a()||G(u)?.kind!==`prompt`||G(u).questions?.length)&&e(Ee)}),J(e,be),Ge()}Cr([`click`,`keydown`]);var Ss=q(` `);function Cs(e,t){We(t,!0);let n=Q(t,`stale`,3,!1),r=P(()=>n()||!!t.goal?.stale);var i=Pr(),a=z(i),o=e=>{var n=Ss();let i;var a=B(n,!0);H((e,o)=>{i=ui(n,1,`goal-status svelte-1yfu3xi`,null,i,{stale:G(r),pursuing:!G(r)&&t.goal.status===`active`,blocked:e}),Z(n,`title`,o),Y(a,G(r)?`GOAL STALE`:t.goal.label)},[()=>!G(r)&&[`blocked`,`usageLimited`,`budgetLimited`].includes(t.goal.status),()=>t.goal.objective+` +`+t.goal.tokensUsed.toLocaleString()+(t.goal.tokenBudget===null?` tokens`:` / `+t.goal.tokenBudget.toLocaleString()+` tokens`)]),J(e,n)};X(a,e=>{t.goal&&e(o)}),J(e,i),Ge()}var ws=q(` `,1),Ts=q(`
        `),Es=q(`

        STATUS LINE // CODEXOMETER

        Choose multiple fields and their order. These display preferences do not + change Codex CLI configuration. Missing values are omitted.

        `),Ds=q(`

        `,1);function Os(e,t){We(t,!0);let n=Q(t,`stale`,3,!1),r=I(Xt([])),i=I(!1),a=P(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??G(a).filter(e=>e.default).map(e=>e.id))].filter(e=>G(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=P(()=>[...G(r).map(e=>G(a).find(t=>t.id===e)).filter(Boolean),...G(a).filter(e=>!G(r).includes(e.id))]);yn(()=>{sa.open&&!G(i)?(L(r,o(oa.statusLine),!0),L(i,!0)):sa.open||L(i,!1)});function l(e,t){L(r,t?[...G(r),e]:G(r).filter(t=>t!==e),!0)}function u(e,t){let n=G(r).indexOf(e),i=n+t;if(n<0||i<0||i>=G(r).length)return;let a=[...G(r)];[a[n],a[i]]=[a[i],a[n]],L(r,a,!0)}var d=Ds(),p=z(d),m=e=>{var t=Es(),n=V(R(t),4);Zr(n,21,()=>G(c),e=>e.id,(e,t)=>{var n=Ts(),i=R(n),a=R(i);Ci(a);var o=V(a,1,!0),s=B(V(o),!0);N(i);var c=V(i,2),d=e=>{var n=ws(),i=z(n),a=V(i,2);H((e,n)=>{Z(i,`aria-label`,`Move `+G(t).label+` earlier`),i.disabled=e,Z(a,`aria-label`,`Move `+G(t).label+` later`),a.disabled=n},[()=>G(r).indexOf(G(t).id)===0,()=>G(r).indexOf(G(t).id)===G(r).length-1]),K(`click`,i,()=>u(G(t).id,-1)),K(`click`,a,()=>u(G(t).id,1)),J(e,n)},f=P(()=>G(r).includes(G(t).id));X(c,e=>{G(f)&&e(d)}),N(n),H(e=>{Z(i,`title`,G(t).help),wi(a,e),Y(o,G(t).label),Y(s,G(t).help)},[()=>G(r).includes(G(t).id)]),K(`change`,a,e=>l(G(t).id,e.currentTarget.checked)),J(e,n)}),N(n);var i=V(n,2),a=B(i),o=V(i,2),d=V(o,2);N(t),H(e=>Y(a,`Preview // ${e??``}`),[()=>s(G(r))||`—`]),K(`click`,o,()=>{oa.statusLine=[...G(r)],la(),sa.open=!1}),K(`click`,d,()=>{sa.open=!1}),J(e,t)};X(p,e=>{sa.open&&e(m)});var h=V(p,2),g=R(h),_=B(g,!0),v=V(g,2);{let e=P(()=>n()||!$.connected||!!$.data?.sessionsError);Cs(v,{get goal(){return t.session.goal},get stale(){return G(e)}})}var y=V(v,2);ri(V(y,2),()=>t.children??f),N(h),H((e,t)=>{Z(g,`title`,e),Y(_,t)},[()=>s(oa.statusLine),()=>s(oa.statusLine)]),K(`click`,y,()=>{sa.open=!sa.open}),J(e,d),Ge()}Cr([`change`,`click`]);var ks=q(`
        `);function As(e,t){We(t,!0);let n=Q(t,`active`,3,!1),r=Q(t,`compact`,3,!1),i=P(()=>oo(t.session)),a=P(()=>!!G(i)),o=I(!1),s=I(``),c=I(!1);yn(()=>{if(!G(c))return;let e=setTimeout(()=>{L(c,!1)},150);return()=>clearTimeout(e)}),yn(()=>{G(i),t.session.status,L(s,``)});async function l(){if(!G(a)||G(o))return;let e=G(i);L(o,!0),L(c,!0),L(s,``);try{await navigator.clipboard.writeText(e),G(i)===e&&L(s,`Copied.`)}catch{G(i)===e&&L(s,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{L(o,!1)}}function u(e){!n()||!G(a)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),l())}var d={copy:l},f=Pr();Sr(`keydown`,$t,u);var p=z(f),m=e=>{var t=ks();let n;var i=R(t),a=B(i,!0),u=V(i,2);let d;N(t),H(()=>{n=ui(t,1,`session-copy svelte-543j00`,null,n,{compact:r()}),Y(a,G(s)),u.disabled=G(o),d=ui(u,1,`svelte-543j00`,null,d,{flashed:G(c)})}),K(`click`,u,l),J(e,t)};return X(p,e=>{G(a)&&e(m)}),J(e,f),Ge(d)}Cr([`click`]);var js=q(`

         
        `,1),Ms=q(`

        LATEST GUIDANCE

         
        `,1),Ns=q(`

        CONTEXT

         

        `,1),Ps=q(`

        `),Fs=q(`

        `),Is=q(`
         
        `),Ls=q(`

         
        `,1),Rs=q(`
         
        `),zs=q(`

        Command unavailable from this observation. Open Codex to inspect the + request.

        `),Bs=q(`

        `,1),Vs=q(`

        `),Hs=q(` `,1),Us=q(`
        `),Ws=q(`

        Session connection or refresh unavailable. Context and telemetry may be + stale.

        `),Gs=q(`

        Some quota profile checks are unavailable. Only sessions with freshly + verified quota and settings can be updated; previous outcome notices remain + visible.

        `),Ks=q(` `),qs=q(` `),Js=q(` `),Ys=q(``),Xs=q(`

        Read only — reply or approve in Codex.

        `),Zs=q(`

        `),Qs=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),$s=q(`
        `),ec=q(` `,1),tc=q(`
        `),nc=q(`

        This session is no longer in the current observation. Return to sessions.

        `),rc=q(`

        `),ic=q(``),ac=q(`

        `),oc=q(` `),sc=q(`

        `),cc=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),lc=q(`

        `),uc=q(`

        TOKEN ACTIVITY // 30 SECOND SAMPLES

        `),dc=q(`

        TOKENS

        FULL DETAIL →
        `),fc=q(`

        No locally observed sessions yet. Keep Codex running alongside + Codexometer.

        `),pc=q(`

        ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

        `,1),mc=q(`

        SESSION TOTALS

        `,1);function hc(e,t){We(t,!0);let n=(e,t=f,n,r)=>{let i=mt(()=>g(n?.(),!0)),a=mt(()=>g(r?.(),!1));var o=Hs(),s=z(o),c=e=>{var n=js(),r=z(n),i=B(r,!0),a=B(V(r,2),!0);H(()=>{Y(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),Y(a,t().currentTask)}),J(e,n)};X(s,e=>{t().currentTask&&e(c)});var l=V(s,2),u=e=>{var n=Ms(),r=B(V(z(n),2),!0);H(()=>Y(r,t().latestGuidance)),J(e,n)};X(l,e=>{t().latestGuidance&&e(u)});var d=V(l,2),p=e=>{var n=Ns(),r=B(V(z(n),2),!0);Se(2),H(()=>Y(r,t().approvalContext)),J(e,n)};X(d,e=>{G(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=V(d,2),h=e=>{var n=Ps();let r;var i=B(n,!0);H(e=>{r=ui(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),Y(i,e)},[()=>D(t())]),J(e,n)},_=P(()=>D(t())&&(!G(a)||G(v)||t().status===`CHECK SESSION`||y(t())));X(m,e=>{G(_)&&e(h)});var b=V(m,2),x=e=>{var n=Fs(),r=B(n,!0);H(e=>Y(r,e),[()=>ee(t())]),J(e,n)};X(b,e=>{G(i)&&e(x)});var S=V(b,2),C=e=>{var n=Is(),r=B(n,!0);H(()=>Y(r,t().text||`No session context available.`)),J(e,n)};X(S,e=>{(t().text||!t().workingCommand)&&e(C)});var w=V(S,2),T=e=>{var n=Ls(),r=V(z(n),2),i=R(r),a=V(i),o=e=>{var n=Nr();H(()=>Y(n,`// ${t().commandTiming??``}`)),J(e,n)};X(a,e=>{t().commandTiming&&e(o)});var s=V(a,2),c=e=>{var n=Nr();H(()=>Y(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),J(e,n)};X(s,e=>{!G(v)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(c)});var l=V(s,2),u=e=>{J(e,Nr(`+`))};X(l,e=>{t().runningLimited&&e(u)}),N(r);var d=B(V(r,2),!0);H(e=>{Y(i,`COMMAND // ${e??``} `),Y(d,t().workingCommand)},[()=>G(v)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),J(e,n)};X(w,e=>{t().workingCommand&&e(T)});var E=V(w,2),te=e=>{Ro(e,{get lines(){return t().fileChanges}})},O=e=>{var n=Bs(),r=V(z(n),2),i=B(r,!0),a=V(r,2),o=e=>{var n=Rs(),r=B(n,!0);H(()=>Y(r,t().command)),J(e,n)},s=e=>{J(e,zs())};X(a,e=>{t().command?e(o):e(s,-1)}),H(()=>Y(i,G(v)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),J(e,n)};X(E,e=>{(!G(a)||!$.data?.control)&&t().fileChanges?.length?e(te):G(a)&&$.data?.control||!t().command&&t().status!==`APPROVAL NEEDED`||e(O,1)});var ne=V(E,2),k=e=>{var n=Vs(),r=B(n);H(()=>Y(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),J(e,n)};X(ne,e=>{G(a)||e(k)}),J(e,o)},r=I(void 0),i=Q(t,`params`,19,()=>({})),a=P(()=>$.data?.sessions||[]),o=P(()=>$.data?.control&&$.data.profiles||[]),s=P(()=>($.data?.triggers||[]).filter(e=>G(a).some(t=>t.id===e.session)));function c(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():w(t)}function l(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&G(s).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let u=I(!1);function d(e,t){i().id&&i().id!==t&&G(u)?e.preventDefault():w(t)}yn(()=>{let e=i().id;e&&pr(()=>{oa.selected=e,pa(e,2)})});let p=P(()=>G(a).find(e=>e.id===i().id)),m=P(()=>new URLSearchParams(Xi.querystring).get(`review`)===`profile`&&G(o).some(e=>e.session===i().id&&e.pending)),h=P(()=>G(a).some(e=>e.id===oa.selected)?oa.selected:G(a)[0]?.id),v=P(()=>!$.connected||!!$.data?.sessionsError);function y(e){return e.status!==`STALE`&&e.failed===!0}let b=P(()=>[[`OBSERVED TOKENS`,ma(G(a).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ma(G(a).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`ERRORS`,`ERRORS`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,G(v)?`—`:ma(G(a).filter(e=>t===`ERRORS`?y(e):e.status===t).length)])]),x=P(()=>G(a).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`].includes(e.status)||y(e)).sort((e,t)=>S(e)-S(t)));function S(e){return e.status===`APPROVAL NEEDED`?0:e.status===`INPUT NEEDED`?1:2}let C=P(()=>G(a).filter(e=>e.status===`TURN COMPLETE`&&!G(s).some(t=>t.session===e.id)&&!G(o).some(t=>t.session===e.id&&t.pending)));function w(e){oa.selected=e,ur().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function T(e,t){if(w(e),i().id){t<0&&(pa(e,2),location.hash=`/sessions`);return}let n=da(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):pa(e,n)}function E(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&i().id)e.preventDefault(),T(i().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(i().id||G(h)))e.preventDefault(),T(i().id||G(h),e.key===`ArrowLeft`?-1:1);else if(!i().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&G(a).length){e.preventDefault();let t=G(a).findIndex(e=>e.id===G(h));w(G(a)[Math.max(0,Math.min(G(a).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function D(e){return G(v)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:y(e)?e.status===`MODEL BUSY`?`CONFIRMED TURN FAILURE — the selected model was at capacity. Choose another model with /model or retry when ready. This is not a quota-exhaustion signal.`:e.status===`MODEL UNAVAILABLE`?`CONFIRMED TURN FAILURE — the provider could not find the selected model. Choose an available model with /model. No automatic retry or model change.`:e.status===`CAPACITY RESTRICTED`?`CONFIRMED TURN FAILURE — capacity is unavailable on a policy-restricted route. Inspect the error before changing settings or retrying. This is not a quota-exhaustion signal; no automatic retry or policy change.`:`CONFIRMED TURN FAILURE — inspect the error below before sending another prompt. No automatic retry or model change.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function ee(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var te=mc();Sr(`keydown`,$t,E);var O=z(te),ne=B(V(R(O),2));N(O);var k=V(O,2);let re;Zr(k,21,()=>G(b),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1];var a=Us();let o;var s=R(a),c=B(s,!0),l=B(V(s,2),!0);N(a),H(()=>{o=ui(a,1,`svelte-mm4wfe`,null,o,{failed:r()===`ERRORS`&&i()!==`0`&&i()!==`—`}),Y(c,r()),Y(l,i())}),J(e,a)}),N(k);var ie=V(k,2),ae=B(ie),oe=V(ie,2),se=e=>{J(e,Ws())};X(oe,e=>{G(v)&&e(se)});var ce=V(oe,2),le=e=>{J(e,Gs())};X(ce,e=>{$.data?.profileError&&e(le)});var ue=V(ce,2),de=e=>{var t=Ys(),n=R(t);Zr(n,17,()=>G(x),qr,(e,t)=>{var n=Ks();let r;var i=B(n);H((e,a,o)=>{r=ui(n,1,`button`,null,r,{approval:e}),Z(n,`href`,a),Y(i,`${G(t).status??``} + ${o??``} // ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>G(t).status===`APPROVAL NEEDED`||G(t).status===`INPUT NEEDED`||y(G(t)),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>w(G(t).id)),J(e,n)});var r=V(n,2);Zr(r,17,()=>G(o).filter(e=>e.pending&&G(a).some(t=>t.id===e.session)),qr,(e,t)=>{var n=qs(),r=B(n);H((e,a,o)=>{Z(n,`title`,i().id&&i().id!==G(t).session&&G(u)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Z(n,`href`,e),Y(r,`QUOTA THRESHOLD ${a??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session)+`?review=profile`,()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory||G(t).session]),K(`click`,n,e=>d(e,G(t).session)),J(e,n)});var l=V(r,2);Zr(l,17,()=>G(C),qr,(e,t)=>{var n=Js(),r=B(n);H((e,i)=>{Z(n,`href`,e),Y(r,`TURN COMPLETE ${i??``} // + ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>w(G(t).id)),J(e,n)}),Zr(V(l,2),17,()=>G(s),qr,(e,t)=>{var n=Js(),r=B(n);H((e,t,i)=>{Z(n,`href`,e),Y(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session),()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(a).find(e=>e.id===G(t).session)?.name||G(a).find(e=>e.id===G(t).session)?.directory]),K(`click`,n,e=>c(e,G(t).session)),J(e,n)}),N(t),J(e,t)},fe=P(()=>(G(x).length||G(C).length||G(o).some(e=>e.pending)||G(s).length)&&!G(v));X(ue,e=>{G(fe)&&e(de)});var pe=V(ue,2),A=e=>{var t=Pr(),a=z(t),s=e=>{var t=tc(),a=R(t),s=R(a);let c;var d=R(s);let f;var h=V(d);N(s);var g=V(s,2);N(a);var _=V(a,2),b=e=>{var t=Vs(),n=B(t,!0);H(()=>Y(n,G(p).directory)),J(e,t)};X(_,e=>{G(p).name&&G(p).directory&&e(b)});var x=V(_,2),S=B(x),C=V(x,2);let T;var E=R(C),D=R(E);n(D,()=>G(p),()=>!0,()=>!0),N(E);var ee=V(E,2),te=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{{let t=P(()=>new URLSearchParams(Xi.querystring).get(`schedule`)===`edit`),n=P(()=>G(p).fileChanges||[]);xs(e,{get session(){return G(p).id},oncopy:()=>G(r)?.copy(),get openScheduler(){return G(t)},get observedCommand(){return G(p).command},get observedFileChanges(){return G(n)},get suspended(){return G(m)},onProtectedChange:e=>{L(u,e,!0)}})}}),J(e,t)},O=e=>{var t=Xs();Kr(V(R(t),2),()=>G(p).id,e=>{Po(e,{get session(){return G(p).id},localOnly:!0,oncopy:()=>G(r)?.copy()})}),N(t),J(e,t)};X(ee,e=>{$.data?.control?e(te):e(O,-1)}),N(C);var ne=V(C,2);Zr(ne,17,()=>G(o).filter(e=>e.session===G(p).id),e=>e.session,(e,t)=>{var n=$s(),r=R(n),i=e=>{var n=Zs(),r=B(n,!0);H(()=>Y(r,G(t).notice)),J(e,n)};X(r,e=>{G(t).notice&&e(i)});var a=V(r,2),o=e=>{xs(e,{get session(){return G(p).id},review:`profile`})},s=e=>{var t=Qs();H(e=>Z(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(p).id)+`?review=profile`]),J(e,t)};X(a,e=>{G(t).pending&&G(m)?e(o):G(t).pending&&e(s,1)}),N(n),H(()=>Z(n,`id`,`quota-profile-`+G(p).id)),J(e,n)});var k=V(ne,2),re=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Os(e,{get session(){return G(p)},get stale(){return G(v)},children:e=>{var t=Pr(),n=z(t),i=e=>{Ri(As(e,{get session(){return G(p)},active:!0,compact:!0}),e=>L(r,e,!0),()=>G(r))};X(n,e=>{G(m)||e(i)}),J(e,t)},$$slots:{default:!0}})}),J(e,t)},ie=e=>{var t=ec(),n=z(t),i=e=>{var t=Pr();Kr(z(t),()=>G(p).id,e=>{Ri(As(e,{get session(){return G(p)},active:!0}),e=>L(r,e,!0),()=>G(r))}),J(e,t)};X(n,e=>{G(m)||e(i)}),Kr(V(n,2),()=>G(p).id,e=>{Os(e,{get session(){return G(p)},get stale(){return G(v)}})}),J(e,t)};X(k,e=>{G(p).goal?e(re):e(ie,-1)}),N(t),H((e,t,n,r)=>{c=ui(s,1,`svelte-mm4wfe`,null,c,{failed:e}),f=ui(d,1,`lamp lit svelte-mm4wfe`,null,f,{failed:t,working:G(p).status===`WORKING`&&!G(v)}),Y(h,`${n??``} // ${(G(p).name||G(p).directory)??``}`),Y(S,`${r??``} TOKENS // ${G(p).id??``} // CONTEXT SOURCE // ${(G(p).source||`LOCAL`)??``}`),T=fi(C,``,T,{display:G(m)?`none`:void 0})},[()=>y(G(p))&&!G(v)&&!G(m),()=>y(G(p))&&!G(v),()=>G(v)?`STALE`:G(m)?`QUOTA THRESHOLD`:l(G(p)),()=>ma(G(p).tokens)]),K(`click`,g,()=>{w(i().id),pa(i().id,2)}),J(e,t)},c=e=>{J(e,nc())};X(a,e=>{G(p)?e(s):e(c,-1)}),J(e,t)},me=e=>{var t=pc(),r=z(t),i=V(R(r),2),s=R(i),c=V(s,2);N(i),N(r);var u=V(r,2);Zr(u,17,()=>G(a),e=>e.id,(e,t)=>{let r=P(()=>da(G(t).id));var i=dc();let a;var s=R(i),c=R(s),u=e=>{var n=rc(),r=R(n),i=B(r);N(n),H(e=>{Z(r,`aria-pressed`,G(h)===G(t).id),Y(i,`${e??``} // ${G(t).name??``}`)},[()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,r,()=>w(G(t).id)),J(e,n)};X(c,e=>{G(t).name&&e(u)});var f=V(c,2),p=R(f);let m;var g=R(p);let _;var b=V(g,1,!0);N(p),N(f);var x=V(f,2),S=e=>{var n=ic(),r=B(n,!0);H(()=>{Z(n,`aria-pressed`,G(h)===G(t).id),Y(r,G(t).directory||G(t).id)}),K(`click`,n,()=>w(G(t).id)),J(e,n)};X(x,e=>{G(t).name||e(S)});var C=V(x,2),E=R(C);Se(),N(C);var D=V(C,2),te=e=>{var n=Vs(),r=B(n,!0);H(()=>Y(r,G(t).directory)),J(e,n)};X(D,e=>{G(t).name&&G(t).directory&&e(te)});var O=V(D,2),ne=B(O),k=V(O,2),re=B(k),ie=V(k,2);Cs(ie,{get goal(){return G(t).goal},get stale(){return G(v)}});var ae=V(ie,2),oe=R(ae),se=V(oe,2),ce=B(se,!0),le=V(se,2);N(ae);var ue=V(ae,2),de=V(ue,2),fe=e=>{var n=ac(),r=B(n,!0);H(e=>Y(r,e),[()=>G(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:y(G(t))?`OPEN DETAIL FOR THE TURN ERROR`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:G(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`]),J(e,n)},pe=P(()=>!G(v)&&([`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(G(t).status)||y(G(t))));X(de,e=>{G(pe)&&e(fe)}),N(s);var A=V(s,2),me=e=>{var r=lc(),i=R(r),a=R(i),s=B(a,!0),c=V(a,2),l=e=>{var n=oc(),r=B(n,!0);H(e=>{Z(n,`href`,e),Y(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id)]),J(e,n)};X(c,e=>{!G(v)&&G(t).status===`APPROVAL NEEDED`&&e(l)}),N(i);var u=V(i,2);n(u,()=>G(t),()=>!1);var f=V(u,2);Zr(f,17,()=>G(o).filter(e=>e.session===G(t).id),qr,(e,n)=>{var r=ec(),i=z(r),a=e=>{var t=sc(),r=B(t,!0);H(()=>Y(r,G(n).notice)),J(e,t)};X(i,e=>{G(n).notice&&e(a)});var o=V(i,2),s=e=>{var n=cc();H(e=>Z(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(t).id)+`?review=profile`]),K(`click`,n,e=>d(e,G(t).id)),J(e,n)};X(o,e=>{G(n).pending&&e(s)}),J(e,r)});var p=V(f,2);{let e=P(()=>G(h)===G(t).id);As(p,{get session(){return G(t)},get active(){return G(e)}})}N(r),H(e=>Y(s,e),[()=>ee(G(t))]),J(e,r)};X(A,e=>{G(r)>0&&e(me)});var he=V(A,2),ge=e=>{var n=uc(),r=V(R(n),2);{let e=P(()=>(G(t).samples||[]).map(e=>e.tokens));ao(r,{get values(){return G(e)},capacity:120})}var i=B(V(r,2));N(n),H(()=>Y(i,`LAST ${(G(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),J(e,n)};X(he,e=>{G(r)<2&&e(ge)}),N(i),H((e,n,o,s,c,l,u)=>{a=ui(i,1,`session-row`,null,a,{selected:G(h)===G(t).id,wide:G(r)===2,split:G(r)===1}),Z(i,`aria-label`,`Session `+(G(t).name||G(t).directory||G(t).id)),m=ui(p,1,`status-detail svelte-mm4wfe`,null,m,{failed:e}),Z(p,`href`,n),_=ui(g,1,`lamp lit svelte-mm4wfe`,null,_,{failed:o,working:G(t).status===`WORKING`&&!G(v)}),Y(b,s),Y(E,`${c??``} `),Y(ne,`${G(t).agents??``} LINKED AGENTS`),Y(re,`ACTIVE // ${l??``}`),oe.disabled=G(r)===0,Z(se,`aria-expanded`,G(r)>0),Y(ce,G(r)?`HIDE DETAIL`:`SHOW DETAIL`),Z(ue,`href`,u)},[()=>y(G(t))&&!G(v),()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>y(G(t))&&!G(v),()=>G(v)?`STALE`:l(G(t)),()=>ma(G(t).tokens),()=>ha(G(t).activity),()=>`#/sessions/`+encodeURIComponent(G(t).id)]),K(`click`,p,()=>w(G(t).id)),K(`click`,oe,()=>T(G(t).id,-1)),K(`click`,se,()=>{w(G(t).id),pa(G(t).id,+!G(r))}),K(`click`,le,()=>T(G(t).id,1)),K(`click`,ue,()=>w(G(t).id)),J(e,i)});var f=V(u,2),p=e=>{J(e,fc())};X(f,e=>{G(a).length||e(p)}),K(`click`,s,()=>fa(1)),K(`click`,c,()=>fa(0)),J(e,t)};X(pe,e=>{i().id?e(A):e(me,-1)}),H(e=>{Y(ne,`OBSERVED ${e??``}`),re=ui(k,1,`session-totals`,null,re,{stale:G(v)}),Y(ae,`${G(v)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens + observed since this server started for currently listed sessions; linked + agents are already included. Totals can decrease when a session leaves the + list. History samples every 30 seconds. Not account-wide totals.`)},[()=>ha($.data?.sessionsAt)]),J(e,te),Ge()}Cr([`click`]);var gc=q(`

        `),_c=q(`

        Relative usage/credits are not tokens or quota percentages. Groupings + describe the same usage, not additional consumption.

        `,1),vc=q(`// APPROXIMATE`),yc=q(`

        Partial accounting: totals may still change.

        `),bc=q(`

        Percentage of this period's historical allowance, not today's limit. May + exceed 100%. This is not a manual/automatic reset log.

        `,1),xc=q(`

        `,1),Sc=q(`

        This optional account report is unavailable. Token history remains + available; missing data does not mean zero usage.

        `),Cc=q(`
        `),wc=q(`
        `),Tc=q(`

        No usage reported for this day.

        `),Ec=q(`

        Selected breakdown unavailable; missing does not mean zero.

        `),Dc=q(`

        `,1);function Oc(e,t){We(t,!0);let n=I(`surface`),r=I(0),i=P(()=>t.reports?.daily),a=P(()=>t.reports?.plan),o=P(()=>t.mode===`breakdown`?G(i)?.days.length||0:G(a)?.periods.length||0),s=P(()=>Math.min(G(r),Math.max(0,G(o)-1))),c=P(()=>G(i)?.days[(G(i)?.days.length||0)-1-G(s)]),l=P(()=>G(a)?.periods[G(s)]),u=P(()=>t.mode===`breakdown`?G(i)?.units||``:`%`),d=P(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=G(c)?.groups[G(n)]||{};else{let t=G(n)===`feature`?`thread_source`:G(n)===`task start`?`turn_trigger`:G(n);for(let n of G(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=P(()=>t.mode===`breakdown`?G(c)?.total:G(l)?.used_basis_points==null?null:G(l).used_basis_points/100),p=P(()=>Math.max(1,G(f)||0,...G(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=Dc(),g=z(h),v=R(g),y=V(R(v)),b=R(y);b.value=b.__value=`surface`;var x=V(b);x.value=x.__value=`model`;var S=V(x);S.value=S.__value=`feature`;var C=V(S);C.value=C.__value=`task start`,N(y),gi(y),N(v);var w=V(v,2),T=V(w,2),E=B(V(T,2),!0);N(g);var D=V(g,2),ee=R(D),te=B(ee,!0),O=V(ee,2),ne=B(O),k=V(O,2),re=e=>{var t=_c(),n=z(t),r=B(n),a=V(n,2),o=e=>{var t=gc(),n=B(t);H(()=>Y(n,`Data as of ${G(i).dataAsOf??``}`)),J(e,t)};X(a,e=>{G(i).dataAsOf&&e(o)});var s=B(V(a,2));Se(2),H((e,t)=>{Y(r,`Latest fetch ${e??``} // queried ${G(i).from??``} → ${G(i).through??``}. + Reports are fetched from OpenAI and are not saved between runs.`),Y(s,`${(G(c)?.date||`No daily buckets reported`)??``} // ${t??``} + ${G(u)??``}`)},[()=>ha(G(i).fetchedAt),()=>m(G(f))]),J(e,t)},ie=e=>{var t=xc(),n=z(t),r=R(n);let i;var o=B(r,!0),s=V(r),c=e=>{J(e,vc())};X(s,e=>{G(a).approximate&&e(c)});var u=V(s);N(n);var d=V(n,2),p=R(d),h=V(p),g=e=>{var t=Nr();H(()=>Y(t,`// Boundary tolerance ${G(a).boundary_tolerance_seconds??``}s`)),J(e,t)};X(h,e=>{G(a).boundary_tolerance_seconds!=null&&e(g)}),N(d);var _=V(d,2),v=e=>{var t=bc(),n=z(t),r=R(n),i=V(r);let a;var o=B(i);N(n);var s=V(n,2),c=B(s),u=V(s,2),d=e=>{J(e,yc())};X(u,e=>{G(l).accounting_complete||e(d)}),Se(2),H(e=>{Y(r,`${G(l).window_minutes??``} MIN // ${G(l).plan_type??``} // `),a=ui(i,1,`svelte-1fbui7h`,null,a,{muted:G(f)==null,"quota-near":G(f)!=null&&G(f)>=80&&G(f)<100,"quota-full":G(f)!=null&&G(f)>=100}),Y(o,`USED ${e??``}${G(f)==null?``:`%`}`),Y(c,`${G(l).starts_at??``} → ${G(l).ends_at??``}`)},[()=>m(G(f))]),J(e,t)};X(_,e=>{G(l)&&e(v)}),H(e=>{i=ui(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!G(a).coverage_complete}),Y(o,G(a).coverage_complete?`Reported range complete`:`Partial coverage`),Y(u,` // Latest fetch ${e??``}`),Y(p,`Coverage starts ${(G(a).coverage_start||`unknown`)??``} // Data as of ${(G(a).data_as_of||`unknown`)??``}`)},[()=>ha(G(a).fetchedAt)]),J(e,t)},ae=e=>{J(e,Sc())};X(k,e=>{t.mode===`breakdown`&&G(i)?e(re):t.mode===`periods`&&G(a)?e(ie,1):e(ae,-1)});var oe=V(k,2),se=e=>{var n=wc(),r=R(n),i=B(V(R(r),2),!0);N(r),Zr(V(r,2),17,()=>G(d),qr,(e,n,r)=>{var i=P(()=>_(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=Cc();let c;var l=R(s),u=B(l,!0),d=V(l,2),f=R(d);let h;N(d);var g=B(V(d,2));N(s),H((e,n,i)=>{c=ui(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Z(l,`title`,a()),Y(u,a()),h=fi(f,``,h,{width:n}),Y(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/G(p))}%`,()=>m(o())]),J(e,s)}),N(n),H(()=>Y(i,t.mode===`breakdown`?G(u):`QUOTA USED`)),J(e,n)},ce=e=>{J(e,Tc())},le=e=>{J(e,Ec())};X(oe,e=>{G(d).length?e(se):t.mode===`breakdown`&&G(c)?.total===0&&G(c)?.groups[G(n)]!=null?e(ce,1):(G(i)&&t.mode===`breakdown`||G(a)&&t.mode===`periods`)&&e(le,2)}),N(D),H(()=>{w.disabled=G(s)>=G(o)-1,T.disabled=G(s)===0,Y(E,G(o)?`${G(s)+1} / ${G(o)}`:`NO DATA`),Y(te,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),Y(ne,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),_i(y,()=>G(n),e=>L(n,e)),K(`click`,w,()=>L(r,G(s)+1)),K(`click`,T,()=>L(r,G(s)-1)),J(e,h),Ge()}Cr([`click`]);var kc=864e5;function Ac(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function jc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=Ac(r,-t),a=new Date(i.getTime()+kc);if(e===n)return{start:a,end:r};r=i}}var Mc=q(``),Nc=q(``,1),Pc=q(`

        History refresh failed. Any displayed history is the last successful + observation.

        `),Fc=q(`

        Token history unavailable; other reports may still be available.

        `),Ic=q(``),Lc=q(`
        `),Rc=q(`

        LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

        `,1),zc=q(`
        `,1),Bc=q(` `),Vc=q(`

        LIFETIME TOKENS

        PEAK DAY

        CURRENT STREAK

        DAYS

        LONGEST TURN

        SECONDS

        LONGEST STREAK

        DAYS

        OPENAI // UTC

        Accessible data table
        Date (UTC)Tokens

        `,1),Hc=q(`

        History unavailable or awaiting a matching account observation. Missing + history is not treated as zero usage.

        `),Uc=q(`

        USAGE // ACCOUNT HISTORY

        Account-wide history reported by Codex, not the local Sessions counter. Dates + use UTC. Allowance history is approximate where indicated; reset causes are + not provided.

        `,1);function Wc(e,t){We(t,!0);let n=I(`daily`),r=I(12),i=I(0),a=P(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=jc(new Date,G(r),G(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=P(()=>Math.max(1,...G(a).map(e=>e.tokens))),s=P(()=>G(a).length?new Date(G(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=P(()=>{if(G(n)===`monthly`){let e=new Map;for(let t of G(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return G(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Uc(),u=V(z(l),4);Zr(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],qr,(e,t)=>{var r=P(()=>_(t,2));let a=()=>G(r)[0],o=()=>G(r)[1];var s=Mc();let c;var l=B(s,!0);H(()=>{Z(s,`aria-pressed`,G(n)===a()),c=ui(s,1,``,null,c,{active:G(n)===a()}),Y(l,o())}),K(`click`,s,()=>{L(n,a(),!0),L(i,0)}),J(e,s)}),N(u);var d=V(u,2),f=R(d),p=e=>{var t=Nc(),n=z(t),a=V(R(n)),o=R(a);o.value=o.__value=6;var s=V(o);s.value=s.__value=12,N(a),gi(a),N(n);var c=V(n),l=V(c);H(()=>l.disabled=G(i)===0),K(`change`,a,()=>L(i,0)),_i(a,()=>G(r),e=>L(r,e)),K(`click`,c,()=>qt(i)),K(`click`,l,()=>qt(i,-1)),J(e,t)};X(f,e=>{G(n)!==`breakdown`&&G(n)!==`periods`&&e(p)}),N(d);var m=V(d,2),h=e=>{J(e,Pc())};X(m,e=>{$.data?.usageError&&e(h)});var g=V(m,2),v=e=>{J(e,Fc())};X(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&G(n)!==`breakdown`&&G(n)!==`periods`&&e(v)});var y=V(g,2),b=e=>{var t=Pr();Kr(z(t),()=>G(n),e=>{{let t=P(()=>$.data?.usage?.reports);Oc(e,{get reports(){return G(t)},get mode(){return G(n)}})}}),J(e,t)},x=e=>{var t=Vc(),r=z(t),i=R(r),l=B(V(R(i),2),!0);N(i);var u=V(i,2),d=B(V(R(u),2),!0);N(u);var f=V(u,2),p=V(R(f),2),m=R(p);Se(),N(p),N(f);var h=V(f,2),g=V(R(h),2),_=R(g);Se(),N(g),N(h);var v=V(h,2),y=V(R(v),2),b=R(y);Se(),N(y),N(v),N(r);var x=V(r,4),S=R(x),C=B(S),w=V(S,2),T=e=>{var t=Rc(),n=z(t),r=R(n),i=R(r);Zr(i,17,()=>Array(G(s)),qr,(e,t)=>{J(e,Ic())}),Zr(V(i,2),17,()=>G(a),qr,(e,t)=>{var n=Lc();let r,i;H(e=>{r=ui(n,1,`heat-cell`,null,r,{zero:G(t).tokens===0}),Z(n,`title`,e),i=fi(n,``,i,{opacity:G(t).tokens?.25+.75*G(t).tokens/G(o):1})},[()=>`${G(t).date}: ${ma(G(t).tokens)} tokens`]),J(e,n)}),N(r),N(n),Se(2),J(e,t)},E=e=>{var t=zc(),r=z(t);{let e=P(()=>G(c).map(e=>e.tokens)),t=P(()=>G(n)+` usage`);ao(r,{get values(){return G(e)},get label(){return G(t)}})}var i=V(r,2),a=R(i),o=B(a,!0),s=B(V(a),!0);N(i),H(e=>{Y(o,G(c)[0]?.date),Y(s,e)},[()=>G(c).at(-1)?.date]),J(e,t)};X(w,e=>{G(n)===`daily`?e(T):e(E,-1)});var D=V(w,2),ee=V(R(D),2),te=R(ee),O=V(R(te));Zr(O,21,()=>G(n)===`daily`?G(a):G(c),qr,(e,t)=>{var n=Bc(),r=R(n),i=B(r,!0),a=B(V(r),!0);N(n),H(e=>{Y(i,G(t).date),Y(a,e)},[()=>ma(G(t).tokens)]),J(e,n)}),N(O),N(te),N(ee),N(D),N(x);var ne=B(V(x,2));H((e,t,n,r,i,o,s)=>{Y(l,e),Y(d,t),Y(m,`${n??``} `),Y(_,`${r??``} `),Y(b,`${i??``} `),Y(C,`${G(a)[0]?.date??``} — ${o??``}`),Y(ne,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ma($.data.usage.summary.lifetimeTokens),()=>ma($.data.usage.summary.peakDailyTokens),()=>ma($.data.usage.summary.currentStreakDays),()=>ma($.data.usage.summary.longestRunningTurnSec),()=>ma($.data.usage.summary.longestStreakDays),()=>G(a).at(-1)?.date,()=>ha($.data.usageAt)]),J(e,t)},S=e=>{J(e,Hc())};X(y,e=>{G(n)===`breakdown`||G(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),J(e,l),Ge()}Cr([`click`,`change`]);var Gc=q(`

        Page not found

        Return to Quota

        `,1);function Kc(e){var t=Gc();Se(2),J(e,t)}var qc=`CODEXOMETER`,Jc=[`█▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█`,`█▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄`].flatMap(e=>[[...e].map(e=>e===`█`||e===`▀`),[...e].map(e=>e===`█`||e===`▄`)]),Yc=Jc[0].length,Xc=Jc.length,Zc=0,Qc=[...qc].map(e=>{let t=e===`M`?5:3,n={start:Zc,width:t};return Zc+=t+1,n}),$c=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,el=`010 101 111 101.110 111 101 110.111 100 100 111.110 101 101 110.111 100 110 111.111 100 110 100.111 100 101 111.101 101 111 101.111 010 010 111.001 001 101 111.101 110 110 101.100 100 100 111.101 111 101 101.101 111 111 101.111 101 101 111.111 101 111 100.111 101 111 001.111 101 110 101.111 100 001 111.111 010 010 010.101 101 101 111.101 101 101 010.101 101 111 101.101 010 010 101.101 101 010 010.111 001 100 111.111 101 101 111.110 010 010 111.111 001 110 111.111 011 001 111.101 101 111 001.111 110 001 111.100 111 101 111.111 001 010 010.111 111 101 111.111 101 111 001`.split(`.`).map(e=>e.split(` `));function tl(e=qc,t=-1,n=!1){let r=``;for(let i=0;i{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function al(){let e=nl[Math.floor(Math.random()*nl.length)],t=Math.floor(Math.random()*4294967296),n=il(t),r=[...qc].map((e,t)=>t);for(let e=r.length-1;e>0;e--){let t=Math.floor(n()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return{variant:e,seed:t,order:r}}function ol(e,t){if(e.variant===`typing`){let e=t<1080,n=e?0:Math.min(Math.floor((t-1080)/90)+1,11);return{text:qc.slice(0,n).padEnd(11),cursor:n,dot:e?Math.floor(t/180)%2==0:n<11}}if(e.variant===`shuffle`){let n=il(e.seed^Math.floor(t/70)),r=[...qc].map(e=>{let t;do t=$c[Math.floor(n()*36)];while(t===e);return t}),i=Math.min(Math.floor(t/110),11);for(let t of e.order.slice(0,i))r[t]=qc[t];return{text:r.join(``),cursor:-1,dot:!1}}return{text:qc,cursor:-1,dot:!1}}var sl=Mr(``);function cl(e,t){We(t,!0);let n=Q(t,`text`,3,qc),r=Q(t,`cursor`,19,()=>-1),i=Q(t,`dot`,3,!1),a=P(()=>tl(n(),r(),i()));var o=sl(),s=B(o);H(()=>{Z(o,`viewBox`,`0 0 ${Yc} ${Xc}`),Z(o,`width`,Yc),Z(o,`height`,Xc),Z(s,`d`,G(a))}),J(e,o),Ge()}var ll=q(`
        `),ul=q(`
        `);function dl(e,t){We(t,!0);let n=I(void 0),r=I(0),i=I(Xt({width:0,height:0,pixelRatio:1})),a=I(Xt({x:0,y:0,width:0})),o=P(()=>G(n)?ol(G(n),G(r)):void 0),s=P(()=>{if(!G(n))return{x:0,y:0,width:0};let e=rl[G(n).variant],t=Math.min(Math.max((G(r)-e-180)/800,0),1),o=t*t*(3-2*t),s=G(i).width+(G(a).width-G(i).width)*o,c=Math.max((G(i).height-G(i).width*Xc/Yc)/2,0),l=(G(n).variant===`slide`&&G(r)Math.round(e*G(i).pixelRatio)/G(i).pixelRatio;return{x:d(l),y:d(u),width:d(s)}});Ki(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`);if(e.matches){t.onfinish();return}L(n,al(),!0);let o=rl[G(n).variant]+180+800,s=0,c=!1,l=performance.now(),u=()=>{let e=t.target?.getBoundingClientRect();L(i,{width:window.innerWidth,height:window.innerHeight,pixelRatio:window.devicePixelRatio||1},!0),e&&L(a,{x:e.x,y:e.y,width:e.width},!0)},d=()=>{c||(c=!0,cancelAnimationFrame(s),t.onfinish())},f=e=>{e instanceof PointerEvent&&e.button!==0||e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)||e instanceof KeyboardEvent&&[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||(e.preventDefault(),e.stopImmediatePropagation(),d())},p=()=>{e.matches&&d()},m=e=>{L(r,Math.max(e-l,0),!0),G(r)>=o?d():s=requestAnimationFrame(m)},h=new ResizeObserver(u);if(t.target){h.observe(t.target),t.target.parentElement&&h.observe(t.target.parentElement);let e=t.target.closest(`header`);e&&h.observe(e)}return u(),window.addEventListener(`resize`,u),document.addEventListener(`keydown`,f,!0),document.addEventListener(`pointerdown`,f,!0),e.addEventListener(`change`,p),s=requestAnimationFrame(m),()=>{c=!0,cancelAnimationFrame(s),h.disconnect(),window.removeEventListener(`resize`,u),document.removeEventListener(`keydown`,f,!0),document.removeEventListener(`pointerdown`,f,!0),e.removeEventListener(`change`,p)}});var c=ul(),l=R(c),u=e=>{var t=ll();let n;cl(R(t),{get text(){return G(o).text},get cursor(){return G(o).cursor},get dot(){return G(o).dot}}),N(t),H(()=>{Z(t,`data-text`,G(o).text),Z(t,`data-cursor`,G(o).dot?G(o).cursor:void 0),n=fi(t,``,n,{left:`${G(s).x}px`,top:`${G(s).y}px`,width:`${G(s).width}px`})}),J(e,t)};X(l,e=>{G(o)&&e(u)});var d=V(l,2);N(c),H(()=>Z(c,`data-entrance`,G(n)?.variant)),K(`click`,d,function(...e){t.onfinish?.apply(this,e)}),J(e,c),Ge()}Cr([`click`]);var fl=q(` `),pl=q(`

        `),ml=q(`

        Connecting to your local Codexometer…

        `),hl=q(``),gl=q(`

        Your quota. Your sessions. Your command centre.

        `);function _l(e,t){We(t,!0);let n={"/":no,"/quota/:view?":no,"/sessions/:id?":hc,"/usage":Wc,"*":Kc},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=I(`hacker`),a=I(!0),o=I(void 0);yn(()=>{ca.requests&&ur().then(()=>{G(o)?.focus(),G(o)?.scrollIntoView({block:`nearest`})})});let s=I(void 0),c=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];yn(()=>{la()}),yn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Xi.location)&&(oa.tab=e)}),Ki(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&c.includes(e)&&L(i,e,!0)}catch{}return ba()});function l(){try{localStorage.setItem(`codexometer.web.theme`,G(i))}catch{}}var u=gl(),d=R(u),f=R(d),p=R(f);cl(R(p),{}),N(p),Ri(p,e=>L(s,e),()=>G(s)),Se(2),N(f);var m=V(f,2),h=R(m);let g;var v=V(h,1,!0),y=B(V(v));N(m),N(d);var b=V(d,2);Zr(b,21,()=>Object.entries(r),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1],a=P(()=>i().test(Xi.location));var o=fl();let s;var c=B(o,!0);H(e=>{Z(o,`href`,r()===`quota`?`#/quota/`+oa.view:`#/`+r()),Z(o,`aria-current`,G(a)?`page`:void 0),s=ui(o,1,``,null,s,{active:G(a)}),Y(c,e)},[()=>r().toUpperCase()]),J(e,o)}),N(b);var x=V(b,2),S=R(x),C=e=>{var t=pl(),n=B(t,!0);H(()=>Y(n,$.error)),J(e,t)};X(S,e=>{$.error&&e(C)});var w=V(S,2),T=e=>{ea(e,{get routes(){return n}})},E=e=>{J(e,ml())};X(w,e=>{$.data?e(T):$.error||e(E,1)}),N(x);var D=V(x,2),ee=R(D),te=B(ee),O=V(ee,2),ne=B(O,!0),k=V(O,2),re=V(R(k));Zr(re,21,()=>c,qr,(e,t)=>{var n=hl(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).replace(`-`,` `).toUpperCase()]),J(e,n)}),N(re),Ri(re,e=>L(o,e),()=>G(o)),gi(re),N(k),N(D);var ie=V(D,2),ae=e=>{dl(e,{get target(){return G(s)},onfinish:()=>L(a,!1)})};X(ie,e=>{G(a)&&e(ae)}),N(u),H(()=>{Z(u,`data-theme`,G(i)),Z(u,`data-starting`,G(a)),d.inert=G(a),g=ui(h,1,`lamp`,null,g,{lit:$.connected}),Y(v,$.connected?`CONNECTED`:`OFFLINE`),Y(y,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),b.inert=G(a),x.inert=G(a),D.inert=G(a),Y(te,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),Y(ne,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),K(`change`,re,l),_i(re,()=>G(i),e=>L(i,e)),J(e,u),Ge()}Cr([`change`]),Br(_l,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-DiPYjudz.css b/internal/web/dist/assets/index-DiPYjudz.css deleted file mode 100644 index 1fdde2ca..00000000 --- a/internal/web/dist/assets/index-DiPYjudz.css +++ /dev/null @@ -1 +0,0 @@ -.observation-details.svelte-1vgdi83{font-size:12px}summary.svelte-1vgdi83{cursor:pointer;color:var(--accent)}.observation-table.svelte-1vgdi83{max-height:240px;overflow:auto}.zone-canvas.svelte-1vgdi83{flex:1;min-height:170px;margin-top:6px;position:relative}svg.svelte-1vgdi83{width:100%;height:100%;display:block;position:absolute;inset:0}text.svelte-1vgdi83{fill:var(--ink);font:14px Cascadia Code,Consolas,monospace}.axis-title.svelte-1vgdi83{letter-spacing:.04em;font-size:12px}.grid.svelte-1vgdi83{stroke:#fff;stroke-opacity:.14;stroke-width:1px}.axes.svelte-1vgdi83{stroke:var(--ink);stroke-width:1.5px;fill:none}.pace-line.svelte-1vgdi83{stroke:#fff;stroke-width:2px;stroke-dasharray:6 4}.position-halo.svelte-1vgdi83{fill:#101820;stroke:#fff;stroke-width:1.5px}.position-dot.svelte-1vgdi83{fill:#fff}.observation-trail.svelte-1vgdi83{fill:none;stroke:#101820;stroke-width:2.5px;stroke-linejoin:round}.observation-trail-casing.svelte-1vgdi83{fill:none;stroke:#ffffff73;stroke-width:4.5px;stroke-linejoin:round}.trail-start.svelte-1vgdi83{fill:#101820;stroke:#ffffffb3;stroke-width:2px}.trend-line.svelte-1vgdi83{fill:none;stroke:var(--trend-color);stroke-width:2px;stroke-dasharray:3 6}.trend-arrow.svelte-1vgdi83{fill:var(--trend-color);stroke:#ffffff73;stroke-width:.5px}.trend-casing.svelte-1vgdi83{fill:none;stroke:#ffffff73;stroke-width:4px;stroke-dasharray:3 6}.zone-caption.svelte-1vgdi83{min-width:0;color:var(--accent);flex:auto;margin:0}.trend-summary.svelte-1vgdi83{color:var(--ink)}.zone-footer.svelte-1vgdi83{justify-content:space-between;align-items:flex-start;gap:12px;margin-top:4px;display:flex}.zone-controls.svelte-1vgdi83{color:var(--muted);text-align:right;flex-direction:column;align-items:flex-end;gap:5px;font-size:11px;display:flex}.trace-control.svelte-1vgdi83,.trend-control.svelte-1vgdi83{cursor:pointer;white-space:nowrap}.trace-control.svelte-1vgdi83 input:where(.svelte-1vgdi83){accent-color:var(--accent)}.trend-control.svelte-1vgdi83 select:where(.svelte-1vgdi83){border:1px solid var(--edge);background:var(--panel);max-width:min(230px,45vw);color:var(--ink);font:inherit}.trend-control.svelte-1vgdi83 option:where(.svelte-1vgdi83):disabled{color:var(--muted)}.zone-controls.svelte-1vgdi83 small:where(.svelte-1vgdi83){font-size:10px}@container (width<=560px){.zone-footer.svelte-1vgdi83{flex-direction:column}.zone-controls.svelte-1vgdi83{align-self:stretch;align-items:flex-end}}.usage-diagnostic.svelte-16u6dmb{white-space:pre-wrap;overflow-wrap:anywhere}.slash-commands.svelte-7bfwr9{margin:.4rem 0;position:relative}.command-popup.svelte-7bfwr9{z-index:5;box-sizing:border-box;border:1px solid var(--accent);background:var(--panel);width:min(40rem,100%);padding:.35rem;position:absolute;bottom:100%;left:0;box-shadow:0 .3rem 1rem #0006}.command-popup.svelte-7bfwr9 p:where(.svelte-7bfwr9){margin:.3rem 0;font-size:.8em}.command-options.vertical.svelte-7bfwr9{flex-flow:column;gap:.15rem;display:flex}.vertical.svelte-7bfwr9 button:where(.svelte-7bfwr9){text-align:left;white-space:nowrap;width:100%;min-width:0;color:var(--muted);background:var(--panel);border-color:#0000;flex:none;align-items:baseline;gap:.4rem;display:flex}.vertical.svelte-7bfwr9 .command-name:where(.svelte-7bfwr9),.vertical.svelte-7bfwr9 .command-tail:where(.svelte-7bfwr9){flex:none}.vertical.svelte-7bfwr9 .command-name:where(.svelte-7bfwr9){text-overflow:ellipsis;max-width:100%;overflow:hidden}.vertical.svelte-7bfwr9 button.suggested:where(.svelte-7bfwr9){outline:none}.command-options.svelte-7bfwr9 button.suggested:where(.svelte-7bfwr9) .command-name:where(.svelte-7bfwr9){color:var(--ink);font-weight:700}.command-options.svelte-7bfwr9 button:where(.svelte-7bfwr9):not(.suggested):hover .command-name:where(.svelte-7bfwr9){text-decoration:underline}.command-options.svelte-7bfwr9 button:where(.svelte-7bfwr9){color:var(--muted)}.vertical.svelte-7bfwr9 .command-help:where(.svelte-7bfwr9){min-width:0;max-width:none;color:var(--muted);flex:1}.command-options.svelte-7bfwr9{flex-wrap:wrap;gap:.35rem;max-height:35vh;display:flex;overflow:auto}.command-options.svelte-7bfwr9 .suggested:where(.svelte-7bfwr9){outline:none}.command-help.svelte-7bfwr9{text-overflow:ellipsis;white-space:nowrap;opacity:.75;max-width:32ch;font-size:.8em;display:block;overflow:hidden}.command-actions.svelte-7bfwr9{flex-wrap:wrap;gap:.35rem;margin-top:.4rem;display:flex}.availability.svelte-7bfwr9{font-weight:600}.navigation.svelte-7bfwr9{font-size:.8em}pre.svelte-7bfwr9{white-space:pre-wrap;overflow-wrap:anywhere;max-height:35vh;overflow:auto}.file-diff.svelte-x4gtb6{border:1px solid var(--muted);max-height:60vh;padding:.5rem;font-family:monospace;overflow:auto}.diff-line.svelte-x4gtb6{white-space:pre;min-height:1.3em;display:flex}.line-number.svelte-x4gtb6{text-align:right;opacity:.75;-webkit-user-select:none;user-select:none;flex:0 0 5ch;padding-right:1ch;display:inline-block}.added.svelte-x4gtb6{color:#67d391;background:#67d39112}.removed.svelte-x4gtb6{color:#ff6b83;background:#ff6b8312}.heading.svelte-x4gtb6{padding:.5rem 0;font-weight:700}.saved-prompt.svelte-1oupzfc{white-space:pre-wrap;overflow-wrap:anywhere}fieldset.svelte-1oupzfc{border:1px solid;margin:.5rem 0;padding:.35rem .6rem}.decision.svelte-1oupzfc,.answer.svelte-1oupzfc{margin:.3rem 0;display:block}.decision.svelte-1oupzfc code:where(.svelte-1oupzfc),.decision.svelte-1oupzfc span:where(.svelte-1oupzfc){overflow-wrap:anywhere;margin:.3rem 0 .3rem 1.5rem;display:block}textarea.svelte-1oupzfc,.answer.svelte-1oupzfc input:where(.svelte-1oupzfc),.answer.svelte-1oupzfc select:where(.svelte-1oupzfc){box-sizing:border-box;background:var(--bg);width:100%;color:inherit;font:inherit;border:1px solid;margin-top:.4rem;padding:.5rem;display:block}textarea.svelte-1oupzfc{resize:vertical;background:color-mix(in srgb, currentColor 8%, var(--bg))}button.svelte-1oupzfc{margin:.3rem .5rem .3rem 0}h3.svelte-1oupzfc,p.svelte-1oupzfc{margin-block:.4rem}.sent.svelte-1oupzfc{color:var(--accent)}.status-line.svelte-gprptn{align-items:center;gap:.5rem;min-width:0;margin-top:.5rem;display:flex}.status-line.svelte-gprptn p:where(.svelte-gprptn){white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;margin:0;font-size:.8rem;overflow:hidden}.configure.svelte-gprptn{padding:.15rem .35rem;font-size:.75rem}.status-picker.svelte-gprptn{border:1px solid var(--edge);margin:.5rem 0;padding:.6rem}.fields.svelte-gprptn{max-height:35vh;overflow:auto}.field.svelte-gprptn{align-items:center;gap:.35rem;display:flex}.field.svelte-gprptn label:where(.svelte-gprptn){flex:1;align-items:center;gap:.4rem;display:flex}.field.svelte-gprptn label:where(.svelte-gprptn) span:where(.svelte-gprptn){font-size:.75rem}.field.svelte-gprptn button:where(.svelte-gprptn){padding:.1rem .35rem}.session-copy.svelte-543j00{justify-content:flex-end;align-items:center;gap:8px;margin-top:auto;padding-top:6px;display:flex}span.svelte-543j00{color:var(--muted);overflow-wrap:anywhere;font-size:12px}button.svelte-543j00{color:var(--accent);flex-shrink:0;padding:3px 7px}button.svelte-543j00:hover,button.flashed.svelte-543j00{color:var(--bg);background:var(--accent)}.failed.svelte-mm4wfe{color:var(--approval)}.lamp.failed.svelte-mm4wfe{background:var(--approval);box-shadow:0 0 8px color-mix(in srgb, var(--approval) 40%, transparent)}h3.svelte-1fbui7h,.window-dates.svelte-1fbui7h,.report-value.svelte-1fbui7h{color:var(--accent);font-weight:700}.quality-warning.svelte-1fbui7h,.quota-near.svelte-1fbui7h{color:var(--approval)}.quota-full.svelte-1fbui7h{color:#ff6680}.alternate.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:radial-gradient(circle, var(--panel) .7px, transparent .9px) 0 0 / 3px 3px, var(--accent)}.unknown.svelte-1fbui7h,.unknown.svelte-1fbui7h .report-value:where(.svelte-1fbui7h){color:var(--muted)}.unknown.svelte-1fbui7h .report-fill:where(.svelte-1fbui7h){background:var(--muted);opacity:1}.report-bars.svelte-1fbui7h{grid-template-columns:minmax(5rem,1fr) minmax(2rem,3fr) auto;gap:.6rem;display:grid}.report-row.svelte-1fbui7h,.report-head.svelte-1fbui7h{grid-column:1/-1;grid-template-columns:subgrid;align-items:center;gap:.6rem;display:grid}.report-head.svelte-1fbui7h{color:var(--muted);font-size:.85rem}.report-head.svelte-1fbui7h>span:where(.svelte-1fbui7h):last-child,.report-value.svelte-1fbui7h{text-align:right}.report-row.svelte-1fbui7h>span:where(.svelte-1fbui7h):first-child{overflow-wrap:anywhere}.report-track.svelte-1fbui7h{background:var(--panel);height:1rem}.report-fill.svelte-1fbui7h{background:var(--accent);height:100%}svg.svelte-1jpy949{fill:currentColor;width:100%;height:auto;display:block}.startup.svelte-19xbbtg{z-index:100;background:var(--bg);color:var(--accent);position:fixed;inset:0;overflow:hidden}.wordmark.svelte-19xbbtg{position:absolute}button.svelte-19xbbtg{color:var(--muted);font:inherit;white-space:nowrap;background:0 0;border:0;font-size:12px;position:absolute;bottom:24px;left:50%;transform:translate(-50%)}:root{font-synthesis:none;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:#080e0c;font-family:Cascadia Code,SFMono-Regular,Consolas,monospace}*{box-sizing:border-box}body{margin:0}.shell{--accent:#80edac;--approval:#ffca58;--muted:#98aaa0;--edge:#31473a;--panel:#101c16;--bg:#080e0c;--ink:#e2eee5;background:var(--bg);height:100dvh;color:var(--ink);grid-template-rows:auto auto minmax(0,1fr) auto;padding:clamp(10px,1.2vw,20px);display:grid}.shell[data-theme=rust]{--approval:#ff8a3d;--accent:#ffbc75;--muted:#bfac95;--edge:#59412c;--panel:#261b14;--bg:#140e0a}.shell[data-theme=blue-steel]{--approval:#e8c46a;--accent:#85c8ff;--muted:#9cacc4;--edge:#334d69;--panel:#142235;--bg:#0b1421}.shell[data-theme=ultraviolet]{--approval:#f9a8d4;--accent:#c5adff;--muted:#b3a6c9;--edge:#4b3c68;--panel:#241a35;--bg:#140d22}.shell[data-theme=nightshade]{--approval:#8f7cff;--accent:#e59bff;--muted:#c6a7cf;--edge:#673976;--panel:#301739;--bg:#1c0b24}header,.spread,footer,.controls{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;display:flex}header{margin-bottom:10px}.shell[data-starting=true]>header,.shell[data-starting=true]>nav,.shell[data-starting=true]>main,.shell[data-starting=true]>footer{visibility:hidden}.brand{width:clamp(240px,32vw,405px);max-width:calc(100vw - 40px);color:var(--accent);text-decoration:none;display:block}header p{color:var(--muted);margin:3px 0 0;font-size:13px}.connection{color:var(--accent);text-align:right}small,.eyebrow{letter-spacing:.04em;font-size:12px}.connection small{color:var(--muted);margin-top:4px;display:block}.lamp{background:var(--muted);border-radius:50%;width:9px;height:9px;margin-right:9px;display:inline-block}.lamp.lit{background:var(--accent);box-shadow:0 0 8px color-mix(in srgb, var(--accent) 40%, transparent)}.working{animation:1.5s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.3}}nav{flex-wrap:wrap;gap:6px;margin-bottom:10px;display:flex}nav a,button,.button,select{font:inherit;color:var(--accent);border:1px solid var(--edge);background:var(--panel);cursor:pointer;border-radius:3px;padding:7px 11px;font-size:13px;text-decoration:none}button:hover,.button:hover,nav a:hover{border-color:var(--accent)}nav a.active,nav button.active{background:var(--accent);color:var(--bg);border-color:var(--accent)}:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.secondary{margin-bottom:8px}.secondary a,.secondary button{padding:6px 10px;font-size:12px}main{scrollbar-gutter:stable;flex-direction:column;min-width:0;min-height:0;display:flex;overflow:auto}main>*{flex-shrink:0}.panel{border:1px solid var(--edge);border-top:2px solid var(--accent);background:var(--panel);border-radius:4px;min-width:0;padding:clamp(10px,1vw,16px)}h1{color:var(--accent);font-size:20px}h2{letter-spacing:.04em;color:var(--accent);overflow-wrap:anywhere;margin:0 0 10px;font-size:13px}h3{overflow-wrap:anywhere;font-size:13px}p{margin:6px 0;font-size:13px;line-height:1.45}a{color:var(--accent)}.muted,.eyebrow{color:var(--muted)}.notice{color:#ffe0aa;background:#332611;border-left:3px solid #ffc26e;padding:12px 16px}.empty{color:var(--muted);padding:35px 0}.quota-grid{flex:1 0 auto;grid-auto-rows:minmax(220px,1fr);gap:10px;display:grid}.quota-card{flex-direction:column;min-height:0;display:flex;container-type:inline-size}.quota-card>:not(.meter-graphic){flex-shrink:0}.meter-graphic{flex-direction:column;flex:1;min-height:100px;display:flex}.bar-graphic{min-height:65px}.quota-card .gauge{flex:2;height:auto;min-height:16px;margin:7px 0}.quota-card .timeline{flex:1;min-height:8px}.quota-grid.zone{grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));grid-auto-rows:minmax(330px,1fr)}.quota-grid.radial{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));grid-auto-rows:minmax(260px,1fr)}.gauge{background:var(--edge);height:35px;margin:15px 0;overflow:hidden}.gauge>div{background:repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 9px, transparent 9px, transparent 12px);height:100%;transition:width .5s}.gauge.timeline{height:14px}.pie-wrap{flex:1;min-height:100px;margin:6px 0;position:relative}.pie-wrap svg{width:100%;height:100%;position:absolute;inset:0}.pie-base{fill:var(--edge);stroke:var(--accent);stroke-width:1px}.pie-fill{fill:var(--accent)}.readout{overflow-wrap:anywhere;color:var(--accent);margin:18px 0;font-size:clamp(22px,3vw,34px)}.credit+.credit{border-top:1px solid var(--edge);padding-top:20px}.credit{margin-top:24px}.session-row{grid-template-columns:minmax(210px,1.1fr) minmax(0,1.2fr) minmax(0,1.5fr);align-items:stretch;gap:14px;margin:18px 0;display:grid}.session-totals{grid-template-columns:repeat(auto-fit,minmax(min(145px,100%),1fr));gap:8px;margin:8px 0;display:grid}.session-totals>div{border:1px solid var(--edge);min-width:0;padding:10px}.session-totals dt{color:var(--muted);font-size:11px}.session-totals dd{color:var(--accent);overflow-wrap:anywhere;margin:6px 0 0;font-size:24px}.session-totals.stale dd{color:var(--muted)}.session-row.selected{outline:1px solid var(--accent);outline-offset:4px}.session-row.wide .context{grid-column:2/-1}.detail-controls{flex-wrap:wrap;gap:6px;display:flex}.attention-summary{flex-wrap:wrap;gap:8px;margin-block:8px;display:flex}.attention-summary .approval{color:var(--approval);border-color:var(--approval)}.attention-summary .approval:hover{background:color-mix(in srgb, var(--approval) 12%, var(--panel))}.attention-summary .approval:focus-visible{outline-color:var(--approval)}.attention-note,.attention-badge{color:var(--accent);border-left:3px solid;padding-left:8px}.attention-note.inferred{color:var(--muted)}.attention-badge{font-size:12px}.session-select{text-align:left;overflow-wrap:anywhere;max-width:100%}.status-detail{color:inherit;text-decoration:none}.status-detail:hover{text-decoration:underline}button:disabled{opacity:.4;cursor:default}.session-row .graph-panel{flex-direction:column;grid-column:2/-1;display:flex}.session-row.split .graph-panel{grid-column:auto}.session-row .button,.session-row button{margin-top:8px;display:inline-block}.context pre{max-height:230px;overflow:auto}.session-row .context{flex-direction:column;display:flex}pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.7}.full-detail{margin-top:6px}.detail-heading{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px 12px;display:flex}.detail-heading h2{flex:250px;min-width:0;margin:0}.detail-metadata{overflow-wrap:anywhere}.detail-workspace{border-top:1px solid var(--edge);flex-direction:column;gap:10px;margin-top:8px;padding-top:4px;display:flex}.detail-context,.detail-workspace .session-actions{min-width:0}.detail-workspace .session-actions{border-top:1px solid var(--edge);padding-top:6px}.full-detail h3{margin-block:8px}.full-detail pre{margin-block:8px;line-height:1.5}.full-detail hr{margin-block:12px}.full-detail .command,.full-detail .notice{padding:8px 10px}.command{background:var(--bg);border-left:3px solid var(--accent);padding:16px}hr{border:0;border-top:1px solid var(--edge);margin:24px 0}.chart{border-bottom:1px solid var(--muted);align-items:flex-end;gap:2px;height:clamp(120px,22vh,320px);margin-top:18px;display:flex}.chart-bar{background:var(--accent);flex:1;min-width:0;max-height:100%}.controls{justify-content:flex-start;margin:20px 0}.summary-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:16px;margin:20px 0;display:grid}.thresholds-panel{padding:clamp(14px,2vw,22px)}.thresholds-panel h1{margin-top:0}.threshold-list{gap:8px;margin-top:16px;display:grid}.threshold-list article{border:1px solid var(--edge);grid-template-columns:minmax(64px,.5fr) minmax(220px,3fr) minmax(64px,.6fr) minmax(120px,1.2fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.threshold-list article.active{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}.threshold-list article.next{border-color:var(--approval);box-shadow:inset 3px 0 0 var(--approval)}.threshold-list p{color:var(--muted);margin:3px 0 0;font-size:12px}.threshold-trigger{color:var(--accent);font-size:22px;font-weight:800}.threshold-mode,.threshold-state{color:var(--muted);font-size:12px;font-weight:700}.threshold-list article.active .threshold-state{color:var(--accent)}.threshold-list article.next .threshold-state{color:var(--approval)}.heat-scroll{overflow-x:auto}.heatmap{grid-template-rows:repeat(7,13px);grid-auto-columns:minmax(9px,1fr);grid-auto-flow:column;gap:4px;min-width:620px;margin:25px 0;display:grid}.heat-cell{background:var(--accent);border-radius:2px}.heat-cell.zero{background:var(--edge)}.table-scroll{max-height:280px;overflow:auto}table{border-collapse:collapse;width:100%;margin-top:15px}th,td{text-align:left;border-bottom:1px solid var(--edge);padding:8px}summary{cursor:pointer;color:var(--accent);padding-top:14px}footer{border-top:1px solid var(--edge);color:var(--muted);margin-top:8px;padding-top:8px;font-size:11px}footer select{padding:6px}@media (width<=850px){.session-row{grid-template-columns:minmax(0,1fr)}.session-row.wide .context,.session-row .graph-panel{grid-column:auto}.connection{text-align:left}.threshold-list article{grid-template-columns:64px minmax(0,1fr)}.threshold-mode,.threshold-state{grid-column:2}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition:none!important;animation:none!important}} diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index b7429276..7a2ecef6 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,8 +5,8 @@ Codexometer // Experimental web - - + +
        diff --git a/internal/web/session_goal_test.go b/internal/web/session_goal_test.go new file mode 100644 index 00000000..684baefe --- /dev/null +++ b/internal/web/session_goal_test.go @@ -0,0 +1,35 @@ +package web + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/merefield/codexometer/internal/codex" +) + +func TestSessionGoalProjectionIsIsolatedSanitizedAndReadOnly(t *testing.T) { + s := newStore() + budget := int64(500) + observed := &codex.SessionGoal{ThreadID: "private-thread-capability", Status: "active", Objective: "\x1b[31mFinish\x1b[0m\x07 the task", TokenBudget: &budget, TokensUsed: 42, TimeUsedSeconds: 3} + rows := []codex.LiveUsageSession{{ID: "one", Goal: observed}, {ID: "two"}} + s.live(codex.LiveUsageSnapshot{Sessions: rows}, nil, time.Now()) + g := s.state.Sessions[0].Goal + if g == nil || g.Label != "PURSUING GOAL" || g.Objective != "Finish the task" || *g.TokenBudget != 500 || g.TokensUsed != 42 || s.state.Sessions[1].Goal != nil { + t.Fatal("goal projection missing, unsanitized or attached to another session", g) + } + budget = 600 + if *g.TokenBudget != 500 { + t.Fatal("projected goal aliased source state") + } + data, _ := json.Marshal(s.state) + if strings.Contains(string(data), "private-thread-capability") || s.state.Control { + t.Fatal("read-only telemetry leaked capabilities or enabled writes") + } + rows[0].Goal = nil + s.live(codex.LiveUsageSnapshot{Sessions: rows}, nil, time.Now()) + if s.state.Sessions[0].Goal != nil { + t.Fatal("cleared goal persisted in web state") + } +} diff --git a/internal/web/state.go b/internal/web/state.go index f4ae79f1..a8f234a7 100644 --- a/internal/web/state.go +++ b/internal/web/state.go @@ -23,6 +23,7 @@ type Source interface { // Deliberately project source types: never serialize approval/input capabilities, // account fingerprints, arbitrary errors, or authentication objects to browsers. type session struct { + Goal *goal `json:"goal,omitempty"` StatusLine map[string]string `json:"statusLine"` FileChanges []codex.FileDiffLine `json:"fileChanges,omitempty"` CurrentTask string `json:"currentTask,omitempty"` @@ -49,6 +50,25 @@ type session struct { Samples []sample `json:"samples"` } +type goal struct { + Status string `json:"status"` + Label string `json:"label"` + Objective string `json:"objective"` + TokenBudget *int64 `json:"tokenBudget"` + TokensUsed int64 `json:"tokensUsed"` + TimeUsedSeconds int64 `json:"timeUsedSeconds"` + Stale bool `json:"stale"` +} + +func projectGoal(observed *codex.SessionGoal) *goal { + if observed == nil { + return nil + } + copy := observed.Clone() + return &goal{Status: codex.SanitizeSessionContext(copy.Status), Label: copy.Label(), Objective: codex.SanitizeSessionContext(copy.Objective), + TokenBudget: copy.TokenBudget, TokensUsed: copy.TokensUsed, TimeUsedSeconds: copy.TimeUsedSeconds, Stale: copy.Stale} +} + type sample struct { At time.Time `json:"at"` Tokens int64 `json:"tokens"` @@ -336,7 +356,8 @@ func (s *store) live(l codex.LiveUsageSnapshot, err error, now time.Time) { text = row.Context.CommandDetails.Justification } s.state.Sessions = append(s.state.Sessions, session{ - ID: row.ID, Name: codex.SanitizeSessionContext(row.Name), Directory: row.WorkingDirectory, Tokens: row.TotalTokens, Agents: row.AgentCount, + Goal: projectGoal(row.Goal), + ID: row.ID, Name: codex.SanitizeSessionContext(row.Name), Directory: row.WorkingDirectory, Tokens: row.TotalTokens, Agents: row.AgentCount, StatusLine: statusline.Values(statusline.Data{Model: row.ModelSettings.Model, Effort: row.ModelSettings.ReasoningEffort, Speed: row.ModelSettings.ServiceTier, Directory: row.WorkingDirectory, Name: row.Name, ID: row.ID, State: sessionStatus(row), Source: row.Context.Source, Tokens: row.TotalTokens, Agents: row.AgentCount}), Status: sessionStatus(row), ContextKind: contextKind(row.Context.Kind), Text: text, Failed: row.Attention == codex.SessionAttentionError, diff --git a/intro-post.md b/intro-post.md index 21568db1..4f879318 100644 --- a/intro-post.md +++ b/intro-post.md @@ -95,7 +95,9 @@ Subtle animated dots in inline and full-screen detail indicate observed work, di On a shared-server session ready for input, the selected full-width detail row also offers a follow-up composer when there is room for the complete context. Click or press Enter to write, Enter to send, and Escape to leave the editor. Smaller panels and structured questions keep full-screen detail as the fallback. -**Live command menus:** type `/` in the composer for a vertical popup with help that shrinks as you type: Up/Down highlights, Tab completes, Enter opens options or applies a choice, and Escape dismisses. Terminal and writable web mode discover model/reasoning options, advertised speed tiers, collaboration modes and allowed permission profiles. Reversible session changes—name, model/reasoning, speed and Plan mode—apply on explicit selection without an extra confirmation. Permission and directory changes remain guarded by default. A loaded shared-server session is required. Speed changes can be sent immediately during a turn for subsequent turns; other settings require idle. Skills, apps, MCP tools, hooks and experimental flags have browse-only catalogues; this is not every Codex CLI slash command. Unsupported catalogues stay hidden, and slash text is never silently sent as a prompt (`//` escapes a literal leading slash). +**Live command menus:** type `/` in the composer for a vertical popup with help that shrinks as you type: Up/Down highlights, Tab completes, Enter opens options or applies a choice, and Escape dismisses. Terminal and writable web mode discover model/reasoning options, advertised speed tiers, collaboration modes and allowed permission profiles. Reversible session changes—name, model/reasoning, speed and Plan mode—apply on explicit selection without an extra confirmation. Permission, directory and goal changes remain guarded by default. A loaded shared-server session is required. Speed changes can be sent immediately during a turn for subsequent turns; other session settings require idle. Skills, apps, MCP tools, hooks and experimental flags have browse-only catalogues; this is not every Codex CLI slash command. Unsupported catalogues stay hidden, and slash text is never silently sent as a prompt (`//` escapes a literal leading slash). + +**Keep your goals in sight:** `/goal` inspects, sets, edits, pauses, resumes or clears a session’s goal and manages its total token budget. Goal status sits below session-row statusline fields and before COPY in the full-detail footer: **PURSUING GOAL**, **GOAL STALLED**, paused, limited or complete. These are official Codex states, separate from whether a turn is working or waiting for input; stale observations are labelled. Goal-capable shared app-server required; writable web mode is needed for browser changes. Creating/resuming a goal can start work and spend quota immediately. Pause/clear do not interrupt an already-running turn. Changes are reviewed by default (`--no-confirm` opts out), freshly checked and never automatically retried. Prefer fewer extra clicks? Launch with `--no-confirm` (plus `--web --web-control` for browser actions) to make Codexometer's other guarded actions single-step too. **Quota-reset redemption always keeps its confirmation.** This launch-only option never auto-selects an approval or bypasses Codex's sandbox, permissions, live capabilities or replay checks. It can make accidental clicks consequential—including permission grants and paid benchmark launches—so leave it off unless you want that trade-off. Confirmation instructions elsewhere in this post describe the default guarded mode. diff --git a/web/src/GoalStatus.svelte b/web/src/GoalStatus.svelte new file mode 100644 index 00000000..d6aa8a10 --- /dev/null +++ b/web/src/GoalStatus.svelte @@ -0,0 +1,45 @@ + + +{#if goal} + {outdated ? 'GOAL STALE' : goal.label} +{/if} + + diff --git a/web/src/SessionCommands.svelte b/web/src/SessionCommands.svelte index 1407a1ea..783e9966 100644 --- a/web/src/SessionCommands.svelte +++ b/web/src/SessionCommands.svelte @@ -152,9 +152,12 @@ input: string; } let history = $state([]); - const inputReview = $derived( - menu?.path.startsWith('rename/') || menu?.path.startsWith('cd/'), - ); + function isInputReview(path: string) { + return ['rename/', 'cd/', 'goal/set/', 'goal/edit/', 'goal/budget/'].some( + (prefix) => path.startsWith(prefix), + ); + } + const inputReview = $derived(isInputReview(menu?.path || '')); const canBack = $derived( (!!selected && !inputReview) || !!stagedChoice || history.length > 0, ); @@ -358,6 +361,14 @@ ); return; } + if ( + event.key === 'Enter' && + (menu?.path === '' || menu?.path === 'goal') && + /^\/goal\s+\S/.test(query.trim()) + ) { + void navigate(query.trim().slice(1)); + return; + } const option = choices[selectedIndex]; if (!option) return; if (event.key === 'Tab') oncomplete(option.label); @@ -435,11 +446,7 @@ if (result.input) commandPanel?.querySelector('input')?.focus(); else optionList?.focus(); }); - if ( - (result.path.startsWith('rename/') || - result.path.startsWith('cd/')) && - result.choices.length === 1 - ) { + if (isInputReview(result.path) && result.choices.length === 1) { busy = false; // The catalogue is ready before preparing its sole choice. void choose(result.choices[0]); } @@ -663,6 +670,9 @@ name changes. {:else if menu?.path.startsWith('cd/')}Only this session’s directory changes; project configuration is not reloaded. + {:else if menu?.path.startsWith('goal/')}Only this session's goal + changes. Active pursuit may immediately start further turns and + consume quota. {:else}No change sent yet. Model, reasoning and speed settings can change token usage and cost. Changes affect subsequent turns of this session, not global defaults. Automatic quota thresholds diff --git a/web/src/SessionCopy.svelte b/web/src/SessionCopy.svelte index ccfeda27..5c000e9c 100644 --- a/web/src/SessionCopy.svelte +++ b/web/src/SessionCopy.svelte @@ -1,8 +1,11 @@ - + +
        diff --git a/web/src/SessionCommands.svelte b/web/src/SessionCommands.svelte index 783e9966..93163c52 100644 --- a/web/src/SessionCommands.svelte +++ b/web/src/SessionCommands.svelte @@ -366,6 +366,18 @@ (menu?.path === '' || menu?.path === 'goal') && /^\/goal\s+\S/.test(query.trim()) ) { + const option = + menu?.path === 'goal' + ? choices.find( + (choice) => + query.trim().slice(6).trim().toLowerCase() === + choice.label.toLowerCase(), + ) + : undefined; + if (option) { + void choose(option); + return; + } void navigate(query.trim().slice(1)); return; } @@ -633,7 +645,13 @@ > {#if !suggesting}

        {menu?.title || '/ COMMANDS'}

        -

        {menu?.help || 'Loading live options…'}

        + {#if menu?.path === 'goal'} +
        + {#each menu.help.split('\n') as line}

        + {line} +

        {/each} +
        + {:else}

        {menu?.help || 'Loading live options…'}

        {/if} {/if} {#if notice}

        {notice}

        {/if} {#if busy}

        Loading / sending…

        {/if} @@ -671,8 +689,7 @@ {:else if menu?.path.startsWith('cd/')}Only this session’s directory changes; project configuration is not reloaded. {:else if menu?.path.startsWith('goal/')}Only this session's goal - changes. Active pursuit may immediately start further turns and - consume quota. + changes. {:else}No change sent yet. Model, reasoning and speed settings can change token usage and cost. Changes affect subsequent turns of this session, not global defaults. Automatic quota thresholds @@ -794,6 +811,12 @@ margin: 0.3rem 0; font-size: 0.8em; } + .goal-summary p { + margin: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } .command-options.vertical { display: flex; flex-direction: column; diff --git a/web/tests/browser.spec.ts b/web/tests/browser.spec.ts index 112d47a7..d3aaaf37 100644 --- a/web/tests/browser.spec.ts +++ b/web/tests/browser.spec.ts @@ -671,6 +671,14 @@ test('goal objective, budget and lifecycle commands retain explicit confirmation await mockActions(page, 'prompt'); const writes: string[] = []; const objective = 'Finish work / without changing another session'; + const labels: Record = { + set: 'Replace goal', + edit: 'Edit objective', + budget: 'Token budget', + pause: 'Pause goal', + resume: 'Resume goal', + clear: 'Clear goal', + }; let committed = ''; await page.route('**/api/control/commands', async (route) => { const body = route.request().postDataJSON(), @@ -708,11 +716,11 @@ test('goal objective, budget and lifecycle commands retain explicit confirmation title: '/goal', path: q.path, revision: 'goal', - help: 'PURSUING GOAL', + help: 'PURSUING GOAL // 200 / 10000 TOKENS\nOBJECTIVE // Old objective', choices: ['set', 'edit', 'budget', 'pause', 'resume', 'clear'].map( (name) => ({ id: name, - label: name, + label: labels[name], next: 'goal/' + name, help: 'Session-specific goal change', }), @@ -762,7 +770,19 @@ test('goal objective, budget and lifecycle commands retain explicit confirmation for (const name of ['set', 'edit', 'budget', 'pause', 'resume', 'clear']) { await text.fill('/goal'); await panel.getByRole('button', { name: '/goal →', exact: true }).click(); - await panel.getByRole('button', { name: name + ' →', exact: true }).click(); + const summary = panel.getByRole('note', { name: 'Current goal' }); + await expect(summary.locator('p')).toHaveCount(2); + await expect(summary).toContainText('200 / 10000 TOKENS'); + await expect( + panel.getByRole('button', { name: /PURSUING GOAL/ }), + ).toHaveCount(0); + if (name === 'edit') { + await text.fill('/goal Edit objective'); + await text.press('Enter'); + } else + await panel + .getByRole('button', { name: labels[name] + ' →', exact: true }) + .click(); let path = 'goal/' + name; if (['set', 'edit', 'budget'].includes(name)) { const input = panel.getByRole('textbox', { From 6bd035035ba0ab508663c83d7993cfa341d38e9a Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 4 Nov 2026 20:55:58 +0000 Subject: [PATCH 3/3] FIX: bound optional goal polling and prioritise core telemetry --- internal/codex/daemon_status_unix.go | 5 +- internal/codex/session_goal_unix.go | 94 ++++++-- internal/codex/session_goal_unix_test.go | 238 ++++++++++++++++++- internal/codex/session_settings_unix_test.go | 8 + 4 files changed, 322 insertions(+), 23 deletions(-) diff --git a/internal/codex/daemon_status_unix.go b/internal/codex/daemon_status_unix.go index 58ccd5bd..d810dd4d 100644 --- a/internal/codex/daemon_status_unix.go +++ b/internal/codex/daemon_status_unix.go @@ -111,7 +111,6 @@ func (p *daemonStatusProvider) Fetch(ctx context.Context, threadIDs []string) (s } } - p.refreshSessionGoals(ctx, threadIDs) coverage := p.readUsageCoverage(ctx, threadIDs) statuses := make(map[string]sessionRuntimeStatus, len(threadIDs)) for _, threadID := range threadIDs { @@ -145,6 +144,10 @@ func (p *daemonStatusProvider) Fetch(ctx context.Context, threadIDs []string) (s } } p.statuses = cloneRuntimeStatuses(statuses) + p.mu.Unlock() + + p.refreshSessionGoals(ctx, threadIDs) + p.mu.Lock() snapshot := p.statusSnapshotLocked(threadIDs) p.mu.Unlock() return snapshot, true diff --git a/internal/codex/session_goal_unix.go b/internal/codex/session_goal_unix.go index 6abe1867..a6ad6579 100644 --- a/internal/codex/session_goal_unix.go +++ b/internal/codex/session_goal_unix.go @@ -8,12 +8,18 @@ import ( "errors" "fmt" "net/url" + "slices" "strings" + "sync" "time" "unicode/utf8" ) -const goalRefreshEvery = 30 * time.Second +const ( + goalRefreshEvery = 30 * time.Second + goalRefreshBudget = 500 * time.Millisecond + goalRefreshWorkers = 4 +) type goalObservation struct { goal *SessionGoal @@ -104,33 +110,79 @@ func (p *daemonStatusProvider) readSessionGoal(ctx context.Context, id string) ( } func (p *daemonStatusProvider) refreshSessionGoals(ctx context.Context, ids []string) { + if ctx.Err() != nil { + return + } + type refresh struct { + id string + at time.Time + version uint64 + } + p.mu.Lock() + conn, generation := p.connection, p.goalGeneration + if conn == nil || p.goalsUnsupported { + p.mu.Unlock() + return + } + var due []refresh for _, id := range ids { - p.mu.Lock() observation, known := p.goals[id] - conn, version := p.connection, p.goalVersions[id] _, subscribed := p.subscribed[id] - refresh := subscribed && !p.goalsUnsupported && (!known || time.Since(observation.at) >= goalRefreshEvery) - p.mu.Unlock() - if !refresh || ctx.Err() != nil { - continue + if subscribed && (!known || time.Since(observation.at) >= goalRefreshEvery) { + due = append(due, refresh{id, observation.at, p.goalVersions[id]}) } - if _, err := p.readSessionGoal(ctx, id); err != nil { - p.mu.Lock() - // Back off failed reads too; preserve the last value as stale, never - // substitute "no goal" or claim pursuit after an unavailable read. - if current := p.goals[id]; p.connection == conn && p.goalVersions[id] == version && current.at == observation.at { - goal := current.goal.Clone() - if goal != nil { - goal.Stale = true + } + p.mu.Unlock() + if len(due) == 0 { + return + } + // Goal snapshots are optional telemetry: one shared budget, not a fresh + // timeout per session. Oldest/unattempted reads go first so a stalled batch + // cannot repeatedly starve the same sessions on later polls. + slices.SortStableFunc(due, func(a, b refresh) int { return a.at.Compare(b.at) }) + ctx, cancel := context.WithTimeout(ctx, goalRefreshBudget) + defer cancel() + failed := func(job refresh, at time.Time) { + p.mu.Lock() + defer p.mu.Unlock() + current := p.goals[job.id] + _, subscribed := p.subscribed[job.id] + if !subscribed || p.connection != conn || p.goalGeneration != generation || p.goalVersions[job.id] != job.version || current.at != job.at { + return // Never overwrite a newer observation, clear or reconnect. + } + goal := current.goal.Clone() + if goal != nil { + goal.Stale = true + } + p.observeGoalLocked(job.id, goal, at) + if observation, stored := p.goals[job.id]; stored { + observation.failed = true + p.goals[job.id] = observation + } + } + jobs := make(chan refresh, len(due)) + for _, job := range due { + jobs <- job + } + close(jobs) + var workers sync.WaitGroup + for range min(goalRefreshWorkers, len(due)) { + workers.Go(func() { + for job := range jobs { + if ctx.Err() != nil { + return } - p.observeGoalLocked(id, goal, time.Now()) - if failed, stored := p.goals[id]; stored { - failed.failed = true - p.goals[id] = failed + if _, err := p.readSessionGoal(ctx, job.id); err != nil { + failed(job, time.Now()) // Back off attempted failures too. } } - p.mu.Unlock() - } + }) + } + workers.Wait() + for _, job := range due { + // A deferred read is stale, not "no goal". Preserve its old timestamp + // so it stays ahead of attempted failures at the next refresh. + failed(job, job.at) } } diff --git a/internal/codex/session_goal_unix_test.go b/internal/codex/session_goal_unix_test.go index 4017db7f..58612e02 100644 --- a/internal/codex/session_goal_unix_test.go +++ b/internal/codex/session_goal_unix_test.go @@ -5,6 +5,7 @@ package codex import ( "context" "encoding/json" + "fmt" "net/url" "strings" "testing" @@ -246,7 +247,7 @@ func TestGoalConcurrentFailedObservationCannotVerifyChange(t *testing.T) { func TestGoalUnsupportedServerAndInvalidInputs(t *testing.T) { p, f := newQuotaDaemon(t) p.Fetch(context.Background(), []string{"one", "two"}) - if f.goalReads != 1 || !p.goalsUnsupported || len(p.statusSnapshotLocked([]string{"one"}).Goals) != 0 { + if f.goalReads < 1 || f.goalReads > 2 || !p.goalsUnsupported || len(p.statusSnapshotLocked([]string{"one"}).Goals) != 0 { t.Fatal("unsupported goal API was not gracefully suppressed", f.goalReads) } p, f = goalFixture(t) @@ -265,3 +266,238 @@ func TestGoalMaximumObjectiveHasCompleteActionableReview(t *testing.T) { t.Fatal("maximum objective was clipped or lost its guarded action", err) } } + +func TestGoalRefreshSharesBudgetAcross256StalledSessions(t *testing.T) { + p, f := goalFixture(t) + ids := []string{"one", "two"} + for len(ids) < 256 { + ids = append(ids, fmt.Sprintf("stalled-%03d", len(ids))) + } + past := time.Now().Add(-time.Minute) + p.mu.Lock() + for _, id := range ids { + p.subscribed[id] = struct{}{} + p.observeGoalLocked(id, &SessionGoal{ThreadID: id, Status: "active", Objective: "Retain this objective"}, past) + } + p.mu.Unlock() + f.mu.Lock() + before := f.goalReads + f.goalNoReply = make(map[string]bool, len(ids)) + for _, id := range ids { + f.goalNoReply[id] = true + } + f.mu.Unlock() + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + started := time.Now() + p.refreshSessionGoals(ctx, ids) + if elapsed := time.Since(started); ctx.Err() != nil || elapsed > goalRefreshBudget+time.Second { + t.Fatalf("goal reads used per-session timeouts: elapsed %v, parent %v", elapsed, ctx.Err()) + } + f.mu.Lock() + reads := f.goalReads - before + f.mu.Unlock() + if reads != goalRefreshWorkers { + t.Fatalf("stalled requests were not worker-bounded: got %d, want %d", reads, goalRefreshWorkers) + } + p.mu.Lock() + backedOff := 0 + for _, id := range ids { + observation := p.goals[id] + if observation.goal == nil || observation.goal.Objective != "Retain this objective" || !observation.goal.Stale || !observation.failed { + t.Errorf("failed/deferred goal %s was dropped or claimed fresh", id) + } + if observation.at.After(past) { + backedOff++ + } + } + pending := len(p.pending) + p.mu.Unlock() + if pending != 0 || backedOff != goalRefreshWorkers { + t.Fatal("worker requests leaked or deferred reads incorrectly backed off", pending, backedOff) + } + var status struct{ Thread struct{ ID string } } + if err := p.request(ctx, "thread/read", map[string]any{"threadId": "one"}, &status); err != nil || status.Thread.ID != "one" { + t.Fatal("stalled goal endpoint blocked ordinary telemetry", err) + } +} + +func TestGoalRefreshReadsHealthyBatchAndSkipsFresh(t *testing.T) { + p, f := goalFixture(t) + var ids []string + f.mu.Lock() + before := f.goalReads + for i := range goalRefreshWorkers * 2 { + id := fmt.Sprintf("healthy-%d", i) + ids = append(ids, id) + f.goals[id] = &SessionGoal{ThreadID: id, Objective: id, Status: "paused"} + } + f.mu.Unlock() + p.mu.Lock() + for _, id := range ids { + p.subscribed[id] = struct{}{} + } + p.mu.Unlock() + p.refreshSessionGoals(context.Background(), ids) + p.mu.Lock() + for _, id := range ids { + goal := p.goals[id].goal + if goal == nil || goal.Stale || goal.Objective != id { + t.Errorf("worker pool lost healthy goal %s", id) + } + } + p.mu.Unlock() + p.refreshSessionGoals(context.Background(), ids) + f.mu.Lock() + defer f.mu.Unlock() + if got := f.goalReads - before; got != len(ids) { + t.Fatal("healthy batch was duplicated or fresh observations were repolled", got) + } +} + +func TestGoalRefreshCollectsCoreStatusBeforeOptionalGoals(t *testing.T) { + p, f := goalFixture(t) + p.mu.Lock() + p.lastStatusAt = time.Time{} + for id, observation := range p.goals { + observation.at = time.Now().Add(-time.Minute) + p.goals[id] = observation + } + p.mu.Unlock() + f.mu.Lock() + f.commandStatus = "active" + f.goalNoReply = map[string]bool{"one": true, "two": true} + f.threadReads = 0 + coreBeforeGoals := true + f.goalReadHook = func() { coreBeforeGoals = coreBeforeGoals && f.threadReads == 2 } + f.mu.Unlock() + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + snapshot, ok := p.Fetch(ctx, []string{"one", "two"}) + if !ok || ctx.Err() != nil || snapshot.Statuses["one"] != sessionRuntimeWorking || snapshot.Statuses["two"] != sessionRuntimeWorking { + t.Fatal("optional goal failure delayed/lost core status", snapshot.Statuses, ctx.Err()) + } + f.mu.Lock() + readFirst := coreBeforeGoals + f.mu.Unlock() + if !readFirst { + t.Fatal("optional goal reads preceded core runtime status") + } + for _, id := range []string{"one", "two"} { + if goal := snapshot.Goals[id]; goal == nil || !goal.Stale { + t.Fatal("stalled goal was lost or claimed fresh state", id) + } + } +} + +func TestGoalRefreshKeepsNewerRuntimeSignals(t *testing.T) { + p, f := goalFixture(t) + p.mu.Lock() + p.lastStatusAt = time.Time{} + observation := p.goals["one"] + observation.at = time.Now().Add(-time.Minute) + p.goals["one"] = observation + p.mu.Unlock() + f.mu.Lock() + f.commandStatus = "active" + f.goalReadHook = func() { + // Same mutex/state updated by the daemon notification reader. This + // signal arrives after the core thread/read, during optional polling. + p.mu.Lock() + p.statuses["one"] = sessionRuntimeApproval + p.mu.Unlock() + } + f.mu.Unlock() + snapshot, ok := p.Fetch(context.Background(), []string{"one", "two"}) + if !ok || snapshot.Statuses["one"] != sessionRuntimeApproval { + t.Fatal("older core read overwrote a runtime signal received during goal refresh") + } +} + +func TestGoalRefreshDeferredReadsKeepTheirPlace(t *testing.T) { + p, f := goalFixture(t) + ids := []string{"stall-a", "stall-b", "stall-c", "stall-d", "healthy"} + past := time.Now().Add(-time.Minute) + p.mu.Lock() + for _, id := range ids { + p.subscribed[id] = struct{}{} + p.observeGoalLocked(id, &SessionGoal{ThreadID: id, Objective: "Old objective", Status: "active"}, past) + } + p.mu.Unlock() + f.mu.Lock() + f.goalNoReply = map[string]bool{} + for _, id := range ids[:goalRefreshWorkers] { + f.goalNoReply[id] = true + } + f.goals["healthy"] = &SessionGoal{ThreadID: "healthy", Objective: "Fresh objective", Status: "complete"} + f.mu.Unlock() + p.refreshSessionGoals(context.Background(), ids) + p.mu.Lock() + if observation := p.goals["healthy"]; observation.at != past || !observation.goal.Stale { + p.mu.Unlock() + t.Fatal("unattempted goal was backed off or claimed current") + } + // Simulate the attempted failures becoming due again before the whole + // backlog has been observed. The oldest/deferred session must go first. + for _, id := range ids[:goalRefreshWorkers] { + observation := p.goals[id] + observation.at = time.Now().Add(-goalRefreshEvery - time.Second) + p.goals[id] = observation + } + p.mu.Unlock() + p.refreshSessionGoals(context.Background(), ids) + p.mu.Lock() + goal := p.goals["healthy"].goal.Clone() + p.mu.Unlock() + if goal == nil || goal.Stale || goal.Objective != "Fresh objective" || goal.Status != "complete" { + t.Fatal("stalled sessions starved the oldest deferred read", goal) + } +} + +func TestGoalRefreshHonoursCancellationAndDoesNotOverwriteStream(t *testing.T) { + for _, event := range []string{"cancel", "update", "clear", "close", "disconnect"} { + t.Run(event, func(t *testing.T) { + p, f := goalFixture(t) + p.mu.Lock() + observation := p.goals["one"] + observation.at = time.Now().Add(-time.Minute) + p.goals["one"] = observation + p.mu.Unlock() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + f.mu.Lock() + f.goalNoReply = map[string]bool{"one": true} + f.goalReadHook = func() { + if event == "disconnect" { + p.disconnect(nil) + return + } + p.mu.Lock() + defer p.mu.Unlock() + switch event { + case "cancel": + cancel() + case "update": + p.goalNotificationLocked("thread/goal/updated", json.RawMessage(`{"threadId":"one","goal":{"threadId":"one","objective":"Streamed objective","status":"complete"}}`)) + case "clear": + p.goalNotificationLocked("thread/goal/cleared", json.RawMessage(`{"threadId":"one"}`)) + case "close": + p.promptLifecycleLocked("thread/closed", json.RawMessage(`{"threadId":"one"}`)) + } + } + f.mu.Unlock() + p.refreshSessionGoals(ctx, []string{"one"}) + p.mu.Lock() + defer p.mu.Unlock() + g := p.goals["one"].goal + if len(p.pending) != 0 { + t.Fatal("cancelled goal read leaked a pending request") + } + if event == "cancel" && (ctx.Err() != context.Canceled || g == nil || !g.Stale) || + event == "update" && (g == nil || g.Stale || g.Objective != "Streamed objective") || + (event == "clear" || event == "close" || event == "disconnect") && g != nil { + t.Fatal("deadline fallback overwrote a newer event", event, g) + } + }) + } +} diff --git a/internal/codex/session_settings_unix_test.go b/internal/codex/session_settings_unix_test.go index 797babea..7b8b5478 100644 --- a/internal/codex/session_settings_unix_test.go +++ b/internal/codex/session_settings_unix_test.go @@ -45,6 +45,8 @@ type quotaDaemonFixture struct { ignoreGoal bool goalReadError map[string]any goalReadHook func() + goalNoReply map[string]bool + threadReads int } func TestQuotaEffortDefaultFallback(t *testing.T) { @@ -120,6 +122,7 @@ func newQuotaDaemonTransport(t *testing.T, compressed bool) (*daemonStatusProvid fixture.mu.Lock() result := map[string]any{} failure := false + noReply := false var failureDetail map[string]any var settingsNotification map[string]any id, _ := req.Params["threadId"].(string) @@ -144,6 +147,7 @@ func newQuotaDaemonTransport(t *testing.T, compressed bool) (*daemonStatusProvid } result = map[string]any{"cwd": cwd, "model": s.Model, "reasoningEffort": s.Effort, "serviceTier": s.Tier, "thread": map[string]any{"id": id}, "activePermissionProfile": map[string]any{"id": fixture.permissions[id]}} case "thread/read": + fixture.threadReads++ status := fixture.commandStatus if status == "" { status = "idle" @@ -151,6 +155,7 @@ func newQuotaDaemonTransport(t *testing.T, compressed bool) (*daemonStatusProvid result["thread"] = map[string]any{"id": id, "cwd": "/work", "status": map[string]any{"type": status}, "name": fixture.names[id], "environments": fixture.environments} case "thread/goal/get": fixture.goalReads++ + noReply = fixture.goalNoReply[id] if fixture.goals == nil { failure = true failureDetail = map[string]any{"code": -32601, "message": "method unavailable"} @@ -279,6 +284,9 @@ func newQuotaDaemonTransport(t *testing.T, compressed bool) (*daemonStatusProvid } } fixture.mu.Unlock() + if noReply { + continue // Keep serving other RPCs while this goal read stalls. + } response := map[string]any{"id": *req.ID, "result": result} if failure { delete(response, "result")