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