Synced from monorepo Changes: - Shell: accept target response id on rewind execute - Shell: stamp response id on chat user message chunks - Worktree: optional rebuild and stale git registration cleanup in auto-GC - Worktree: kind-aware auto-GC TTLs and config knobs - Worktree: macOS process CWD scan and Unix PID liveness for GC guards - Worktree: automatic throttled GC on startup (Linux age-based; non-Linux dead-only) - Pager: add `[ui].combine_queued_prompts` to batch queued follow-ups - Shell: stop overwriting user skills - Tools: read markdown in `skills/` directories untruncated - `/usage` shows per-session token and dollar usage in the TUI - Security: prompt on environment-dumping `ps` variants - Security: always-safe `kubectl` no longer runs arbitrary kubeconfig credential plugins without permission - Tools: make scheduler deletion durable - Shell: add relocation storage primitives - Shell: give side model calls their own conversation ids - Fix five workflow-runtime bugs (budget, pause, cancel, reconnect) - Security: peel `env -S` / `--split-string` operands in the Bash permission gate (managed deny/ask) - Pager: expose doctor in the TUI - Security: block unauthorized RCE via abused safe commands - Pager idle watcher cue: "1 subagent still running" instead of "watching · 1 subagent" - Security: block `rg --pre` arbitrary code execution in auto-mode - Voice: diagnose silent-mic failures (macOS permission) and add doctor/terminal-setup Voice section - App builder deployer: `allow_forking` and `show_built_with_grok` - Pager: stop stacking duplicate "Worked for" markers on parked turns - Shell: support `max` as a distinct reasoning effort tier - Tools: serialize background `/loop` fires on the whole work unit - Shell: add working-directory relocation state primitives - Proto: `ClientToolResult` and `ChatConfig` client-side tools - Shell: model providers - Chat: select App Builder product on the Build path - Shell: attach author identity to feedback when the deployment opts in - Doctor: fix for SSH wrap setup - Workflow authoring skills: create-workflow and import-claude-workflow docs - Add read-only grok doctor - Sandbox: apply Landlock without a controlling TTY - Pager: recover image paste over grok wrap on headless remotes - Pager: make actions screen-mode aware - Shell: resume sessions when the working directory moves - Pager: centralize terminal diagnostics - Workspace: gate inline shell file access - Pager: centralize terminal probes - Pager: edit minimal prompts in an external editor - Pager: standardize backgrounding on Ctrl+B - Shell: recap rides the parent turn's prompt cache - Tools: add scheduler lifecycle version clock Source-Revision: 0f4d7c91b8b2b408333f6de1e8a76cb8eaa71899
55 lines
3 KiB
Rust
55 lines
3 KiB
Rust
//! xai-chat-state — Actor-based chat state management for xAI agents.
|
|
//!
|
|
//! This crate extracts conversation state management from `xai-grok-shell`'s
|
|
//! `acp_session.rs` into a standalone actor. It follows the same actor pattern
|
|
//! as `xai-hunk-tracker`:
|
|
//!
|
|
//! ```text
|
|
//! ┌────────────────┐ ┌──────────────────────────────────────┐
|
|
//! │ SessionActor │ ─── Command ───▶ │ ChatStateActor │
|
|
//! │ (push_user, │ │ (runs in dedicated tokio task) │
|
|
//! │ build_req) │ │ │
|
|
//! └────────────────┘ │ State (no locks needed): │
|
|
//! │ - conversation: Vec<ConversationItem>│
|
|
//! ┌────────────────┐ │ - sampling_config: SamplingConfig │
|
|
//! │ Query (e.g. │ ── Cmd+Oneshot ─▶│ - prompt_index: usize │
|
|
//! │ get_conv) │ ◀── Response ────│ - total_tokens: u64 │
|
|
//! └────────────────┘ │ │
|
|
//! │ │ ChatStateEvent │
|
|
//! │ ▼ │
|
|
//! │ ┌──────────────────┐ │
|
|
//! │ │ event_tx │───▶ Session │
|
|
//! │ └──────────────────┘ │
|
|
//! └──────────────────────────────────────┘
|
|
//! ```
|
|
|
|
pub mod actor;
|
|
pub mod commands;
|
|
pub mod compaction_mode;
|
|
pub mod compaction_transcript;
|
|
pub mod compaction_utils;
|
|
pub mod conversation_util;
|
|
pub mod events;
|
|
pub mod handle;
|
|
pub mod persistence;
|
|
pub mod types;
|
|
pub mod usage;
|
|
|
|
// Re-export main types for convenience
|
|
pub use actor::ChatStateActor;
|
|
pub use actor::state::{
|
|
estimate_conversation_tokens, estimate_item_tokens, estimate_messages_tokens,
|
|
estimate_system_message_tokens, estimate_tool_definition_tokens,
|
|
estimate_tool_definitions_tokens,
|
|
};
|
|
pub use commands::{ModelMetadata, StrictAppendAck, StrictAppendError};
|
|
pub use compaction_mode::CompactionMode;
|
|
pub use compaction_transcript::CompactionDetail;
|
|
pub use events::ChatStateEvent;
|
|
pub use handle::ChatStateHandle;
|
|
pub use persistence::{
|
|
ChatPersistence, MockChatPersistence, MockPersistenceReceiver, NullChatPersistence,
|
|
PersistenceRecord,
|
|
};
|
|
pub use types::*;
|
|
pub use usage::{UsageLedger, UsageTotals};
|