Skip to main content

newt_core/
lib.rs

1//! Newt-Agent core: shared types, errors, and the tier router.
2//!
3//! The router is the NeMoCode inheritance — it classifies an incoming turn
4//! into a `Tier` (FAST / STANDARD / COMPLEX / REVIEW), and asks the
5//! configured backends which can serve that tier.
6
7pub mod agent_identity;
8pub mod agentic;
9pub mod agents;
10pub mod api_surface;
11pub mod caveats;
12pub mod classifiers;
13pub mod config;
14pub mod conversation;
15pub mod dgx;
16pub mod error;
17pub mod ffi_manifest;
18pub mod ffi_surface;
19pub mod git_caveats;
20pub mod kit;
21pub mod lazy_emission;
22pub mod mcp;
23pub mod memory;
24pub mod metrics;
25pub mod model_card;
26pub mod model_id;
27pub mod notes;
28pub mod notes_scan;
29pub mod ocap;
30pub mod plan;
31pub mod pricing;
32pub mod prune;
33pub mod reasoning;
34pub mod retry;
35pub mod role_profile;
36pub mod router;
37pub mod scope_grounding;
38pub mod scratch;
39pub mod session;
40pub mod settings;
41pub mod ssh_caveats;
42pub mod store;
43pub mod symbols;
44pub mod templates;
45pub mod tokens;
46pub mod tooling;
47pub mod tuning;
48pub mod verify_gate;
49pub mod workflows;
50pub mod workspace_key;
51
52#[cfg(feature = "pyo3")]
53pub mod pyo3_module;
54
55/// Carried-coreutils dispatch (agent-bridle #206): a newt binary calls this at
56/// the top of `main` to become dispatch-capable, so the brush engine's carried
57/// `ls`/`cat` shims re-exec against the newt binary itself.
58pub use agent_bridle::maybe_dispatch;
59pub use agent_identity::{
60    AgentIdentity, GithubApp, IdentitySource, Secret, SecretRef, DEFAULT_AGENT_EMAIL,
61    DEFAULT_AGENT_NAME,
62};
63pub use agent_mesh_protocol::{Caveats, CountBound, Scope};
64// Step 9.7: clean top-level import paths for the relocated agentic loop.
65// Step 18.4 (#247): CompressState (session anti-thrash) + Summarizer (the
66// loop's injected compression summarizer) join the surface.
67// Step 19.4 (#248): trim_for_summary joins it — the TUI's close-time note
68// extraction bounds its transcript with the cap-exit summary's own helper.
69// Step 18.6 (#247): compress_user_initiated (the `/compress` entry into the
70// same pipeline) + CompressCounters (read-only `/memory` snapshot).
71// Issue #263: the prompted-ocap-grant seam (PermissionGate + friends) joins
72// the surface — the TUI implements the gate; headless callers pass None.
73pub use agentic::{
74    append_denial, chat_complete, compress_user_initiated, execute_tool, experience_block,
75    gather_code_files, index_files, load_denials, memory_fetch_tool_definition,
76    openai_chat_complete, plan_block, retrieve_evidence, transcript_lines, transcript_lines_styled,
77    trim_for_summary, widen_caveats, ChatCtx, CodeSearch, CompressCounters, CompressState,
78    DenialKind, Embedder, EmbeddingsClient, ExperienceStore, ManualCompressOutcome, McpTools,
79    MemAddr, MemPayload, MemorySource, NoMcp, NoteNudge, NoteSink, PermissionDecision,
80    PermissionGate, PermissionRecord, PermissionRequest, PlanSnapshot, RecallSource,
81    RoundObservation, ScratchpadStore, SemanticIndex, SessionExperienceStore,
82    SessionScratchpadStore, SessionSemanticIndex, SessionSpillStore, SessionStepLedger,
83    ShellObservation, SpillStore, Step, StepLedger, StepStatus, StoreMemorySource,
84    StoreRecallSource, SummarizeFn, SummarizeFuture, Summarizer, TranscriptLine, TranscriptRole,
85    TranscriptStyle, TurnDriver, TurnDriverConfig, TurnDriverError, TurnOutcome, TurnStatus,
86    EXPERIENCE_TOP_K,
87};
88pub use agents::AgentsProvider;
89pub use api_surface::ApiSurfaceProvider;
90pub use caveats::{CaveatsExt, CountBoundExt, ScopeExt};
91pub use classifiers::{
92    classifier_config_dir, NudgeClass, NudgeClassification, NudgeClassifier, NudgeClassifierConfig,
93};
94pub use config::{
95    full_access_default_engine, ocap_l3_backend, resolve_shell_engine, AgentsConfig, BackendConfig,
96    BackendKind, BundleConfig, ChatStyle, ColorMode, Config, ContextConfig, ContextFeature,
97    ContextFeatureSet, ContextFeatures, ContextManager, ConversationsConfig, CrewPolicyConfig,
98    EditMode, FooterMode, Loadout, LoadoutSettings, LogConfig, MarkdownMode, MemoryConfig,
99    MemoryDisclosure, MemoryProviderKind, OnEmbedFailure, OpenAiApi, PermissionPreset, PickVia,
100    PlanConfig, PlanPruneConfig, ProfilePick, ProviderConfig, ScratchConfig, SemanticConfig,
101    ShellConfig, ShellEngine, SkillsConfig, SummarizerConfig, ThinkingMode, ToolPermissions,
102    TuiConfig,
103};
104pub use conversation::{
105    new_conversation_id, session_plan_dir, session_plan_path, ConversationRecord,
106    ConversationSummary, ConversationTurn, PhantomReach, PhantomResolution, ToolEvent,
107};
108pub use ffi_surface::FfiSurfaceProvider;
109// `kit::Tier` (Headless|TuiOnly) is *not* re-exported here — it would collide with
110// the router's task-complexity `Tier`; reach it as `kit::Tier`.
111pub use kit::{Axis, MountKind, RegistryEntry, COMPONENT_REGISTRY};
112// Steps 17.1a/17.1b (issue #246): `ConversationStore` is the SQLite backend
113// (`store` module, §6 causal ordering). The legacy JSON write path is gone;
114// any legacy tree is imported once on open. The `conversation` module keeps
115// the storage-agnostic shared types and free functions re-exported above.
116pub use dgx::{DgxConfig, DgxFormation, DgxNode, DgxNotConfigured, EndpointKind};
117pub use error::NewtError;
118pub use memory::{
119    MemMessage, MemoryIndex, MemoryManager, MemoryProvider, NoteStore, NotesUnsupported, Role,
120    RollingWindow, SessionContext, SoulProvider, SoulSource, Summarizing, TokenBudget,
121    DEFAULT_CONTEXT_TOKENS, DEFAULT_SOUL, MEMORY_INDEX_BUDGET,
122};
123pub use metrics::{TokenUsage, TurnMetrics};
124pub use model_id::ModelId;
125pub use pricing::{ModelRate, PricingConfig};
126pub use reasoning::{split_reasoning, ThinkFilter};
127pub use role_profile::{
128    CaveatProfile, NamedPermissionPreset, RoleProfile, ScopeKeyword, ScopeSpec,
129};
130pub use router::{Router, Tier};
131pub use session::SessionId;
132pub use store::{sanitize_fts5_query, ConversationStore, SearchHit};
133pub use tokens::TokenEstimation;
134pub use workflows::{
135    builtin_workflows, load_workflows_from_dir, merge_workflows, workflow_config_dir,
136    WorkflowClassifierConfig, WorkflowConfig, WorkflowSteerer, WorkflowStep,
137};
138pub use workspace_key::workspace_key_v2;