Skip to main content

Crate newt_core

Crate newt_core 

Source
Expand description

Newt-Agent core: shared types, errors, and the tier router.

The router is the NeMoCode inheritance — it classifies an incoming turn into a Tier (FAST / STANDARD / COMPLEX / REVIEW), and asks the configured backends which can serve that tier.

Re-exports§

pub use agent_identity::AgentIdentity;
pub use agent_identity::GithubApp;
pub use agent_identity::IdentitySource;
pub use agent_identity::Secret;
pub use agent_identity::SecretRef;
pub use agent_identity::DEFAULT_AGENT_EMAIL;
pub use agent_identity::DEFAULT_AGENT_NAME;
pub use agentic::append_denial;
pub use agentic::chat_complete;
pub use agentic::compress_user_initiated;
pub use agentic::execute_tool;
pub use agentic::experience_block;
pub use agentic::gather_code_files;
pub use agentic::index_files;
pub use agentic::load_denials;
pub use agentic::memory_fetch_tool_definition;
pub use agentic::openai_chat_complete;
pub use agentic::plan_block;
pub use agentic::retrieve_evidence;
pub use agentic::transcript_lines;
pub use agentic::transcript_lines_styled;
pub use agentic::trim_for_summary;
pub use agentic::widen_caveats;
pub use agentic::ChatCtx;
pub use agentic::CodeSearch;
pub use agentic::CompressCounters;
pub use agentic::CompressState;
pub use agentic::DenialKind;
pub use agentic::Embedder;
pub use agentic::EmbeddingsClient;
pub use agentic::ExperienceStore;
pub use agentic::ManualCompressOutcome;
pub use agentic::McpTools;
pub use agentic::MemAddr;
pub use agentic::MemPayload;
pub use agentic::MemorySource;
pub use agentic::NoMcp;
pub use agentic::NoteNudge;
pub use agentic::NoteSink;
pub use agentic::PermissionDecision;
pub use agentic::PermissionGate;
pub use agentic::PermissionRecord;
pub use agentic::PermissionRequest;
pub use agentic::PlanSnapshot;
pub use agentic::RecallSource;
pub use agentic::RoundObservation;
pub use agentic::ScratchpadStore;
pub use agentic::SemanticIndex;
pub use agentic::SessionExperienceStore;
pub use agentic::SessionScratchpadStore;
pub use agentic::SessionSemanticIndex;
pub use agentic::SessionSpillStore;
pub use agentic::SessionStepLedger;
pub use agentic::ShellObservation;
pub use agentic::SpillStore;
pub use agentic::Step;
pub use agentic::StepLedger;
pub use agentic::StepStatus;
pub use agentic::StoreMemorySource;
pub use agentic::StoreRecallSource;
pub use agentic::SummarizeFn;
pub use agentic::SummarizeFuture;
pub use agentic::Summarizer;
pub use agentic::TranscriptLine;
pub use agentic::TranscriptRole;
pub use agentic::TranscriptStyle;
pub use agentic::TurnDriver;
pub use agentic::TurnDriverConfig;
pub use agentic::TurnDriverError;
pub use agentic::TurnOutcome;
pub use agentic::TurnStatus;
pub use agentic::EXPERIENCE_TOP_K;
pub use agents::AgentsProvider;
pub use api_surface::ApiSurfaceProvider;
pub use caveats::CaveatsExt;
pub use caveats::CountBoundExt;
pub use caveats::ScopeExt;
pub use classifiers::classifier_config_dir;
pub use classifiers::NudgeClass;
pub use classifiers::NudgeClassification;
pub use classifiers::NudgeClassifier;
pub use classifiers::NudgeClassifierConfig;
pub use config::full_access_default_engine;
pub use config::ocap_l3_backend;
pub use config::resolve_shell_engine;
pub use config::AgentsConfig;
pub use config::BackendConfig;
pub use config::BackendKind;
pub use config::BundleConfig;
pub use config::ChatStyle;
pub use config::ColorMode;
pub use config::Config;
pub use config::ContextConfig;
pub use config::ContextFeature;
pub use config::ContextFeatureSet;
pub use config::ContextFeatures;
pub use config::ContextManager;
pub use config::ConversationsConfig;
pub use config::CrewPolicyConfig;
pub use config::EditMode;
pub use config::FooterMode;
pub use config::Loadout;
pub use config::LoadoutSettings;
pub use config::LogConfig;
pub use config::MarkdownMode;
pub use config::MemoryConfig;
pub use config::MemoryDisclosure;
pub use config::MemoryProviderKind;
pub use config::OnEmbedFailure;
pub use config::OpenAiApi;
pub use config::PermissionPreset;
pub use config::PickVia;
pub use config::PlanConfig;
pub use config::PlanPruneConfig;
pub use config::ProfilePick;
pub use config::ProviderConfig;
pub use config::ScratchConfig;
pub use config::SemanticConfig;
pub use config::ShellConfig;
pub use config::ShellEngine;
pub use config::SkillsConfig;
pub use config::SummarizerConfig;
pub use config::ThinkingMode;
pub use config::ToolPermissions;
pub use config::TuiConfig;
pub use conversation::new_conversation_id;
pub use conversation::session_plan_dir;
pub use conversation::session_plan_path;
pub use conversation::ConversationRecord;
pub use conversation::ConversationSummary;
pub use conversation::ConversationTurn;
pub use conversation::PhantomReach;
pub use conversation::PhantomResolution;
pub use conversation::ToolEvent;
pub use ffi_surface::FfiSurfaceProvider;
pub use kit::Axis;
pub use kit::MountKind;
pub use kit::RegistryEntry;
pub use kit::COMPONENT_REGISTRY;
pub use dgx::DgxConfig;
pub use dgx::DgxFormation;
pub use dgx::DgxNode;
pub use dgx::DgxNotConfigured;
pub use dgx::EndpointKind;
pub use error::NewtError;
pub use memory::MemMessage;
pub use memory::MemoryIndex;
pub use memory::MemoryManager;
pub use memory::MemoryProvider;
pub use memory::NoteStore;
pub use memory::NotesUnsupported;
pub use memory::Role;
pub use memory::RollingWindow;
pub use memory::SessionContext;
pub use memory::SoulProvider;
pub use memory::SoulSource;
pub use memory::Summarizing;
pub use memory::TokenBudget;
pub use memory::DEFAULT_CONTEXT_TOKENS;
pub use memory::DEFAULT_SOUL;
pub use memory::MEMORY_INDEX_BUDGET;
pub use metrics::TokenUsage;
pub use metrics::TurnMetrics;
pub use model_id::ModelId;
pub use pricing::ModelRate;
pub use pricing::PricingConfig;
pub use reasoning::split_reasoning;
pub use reasoning::ThinkFilter;
pub use role_profile::CaveatProfile;
pub use role_profile::NamedPermissionPreset;
pub use role_profile::RoleProfile;
pub use role_profile::ScopeKeyword;
pub use role_profile::ScopeSpec;
pub use router::Router;
pub use router::Tier;
pub use session::SessionId;
pub use store::sanitize_fts5_query;
pub use store::ConversationStore;
pub use store::SearchHit;
pub use tokens::TokenEstimation;
pub use workflows::builtin_workflows;
pub use workflows::load_workflows_from_dir;
pub use workflows::merge_workflows;
pub use workflows::workflow_config_dir;
pub use workflows::WorkflowClassifierConfig;
pub use workflows::WorkflowConfig;
pub use workflows::WorkflowSteerer;
pub use workflows::WorkflowStep;
pub use workspace_key::workspace_key_v2;

Modules§

agent_identity
Agent commit identity (.newt/agent-identity.toml).
agentic
The agentic loop — call model → execute tool calls → feed results back → repeat — extracted verbatim from newt-tui in Step 9.7 so the same battle-tested loop can serve both the TUI and the ACP worker (Step 9.8) without being written twice.
agents
Project-instruction provider — loads AGENTS.md / CLAUDE.md from the workspace and injects them as a frozen system-prompt block.
api_surface
The knowledge_base workspace API-surface technique (#669), with a pluggable language-pack model.
caveats
Caveats — the attenuated authority lattice consumed at every tool dispatch site.
classifiers
Configurable lightweight classifiers.
config
Configuration loading for Newt-Agent.
conversation
Shared conversation types and free functions.
dgx
NVIDIA DGX endpoint configuration — the data model behind the newt dgx command suite.
error
ffi_manifest
FFI-introspection manifest — the knowledge-base support part (#74).
ffi_surface
The knowledge_base technique (R1) as a memory provider.
git_caveats
GitCaveats — the custom OCAP capability surface for the embedded git tool.
kit
The component registry — the model support kit’s catalog of parts.
lazy_emission
Detect lazy / elided whole-file emissions — a model returning a placeholder (<the full file content remains unchanged>, … rest of the file …) or an empty body instead of the complete file. The crew apply path must REFUSE these: applying one silently overwrites real code with a placeholder, which only surfaces downstream as a compile error (the second failure in the #548 real-issue experiment). Pure — no fs, no model. (#688)
mcp
Shared MCP server discovery.
memory
Pluggable memory architecture for newt’s chat REPL.
metrics
Inference turn telemetry — timing, token counts, and cost estimates.
model_card
Data-driven model cards (#853) — the central abstraction for standing a model up. One card holds all the settings needed to serve exactly one model on one backend (vLLM or ollama), plus its sampling tuning and reasoning capability bits. Authoring a new card is how you add a model newt has never heard of.
model_id
notes
NoteStore v2 — persistent, agent-curated notes (Step 19.1, #248).
notes_scan
Write-time security scan for agent notes (Step 19.2, #248).
ocap
OCAP enforcement scaffold — the runtime side of the deviation ratchet.
plan
The canonical agent plan: one serde Plan / Subtask definition shared by the human-driven collaborative /plan surface (#334) and the swarm scheduler (Workstream C / the future newt-scheduler).
pricing
Cost estimation for inference backends.
prune
Structural prune — zero-LLM context compression over the wire-shape message list (Step 18.3, issue #247).
reasoning
Separating a model’s reasoning from its content.
retry
Shared HTTP retry/backoff for inference backends.
role_profile
RoleProfile — promotes a persona from a prompt-only overlay into a “role profile” that binds a system-prompt overlay together with a toolset, a capability (caveat) profile, and backend/router policy.
router
Tier-based router — NeMoCode inheritance.
scope_grounding
Shared def-site scope grounding (#812, #840): derive a subtask’s file scope from the harness’s OWN grounding — a def_sites grep closure the caller injects — rather than trusting a model’s self-reported file list alone. derive_subtask_scope/ground_scope are the ONE implementation shared by crew mode’s plan::Subtask.context (newt-cli/src/crew.rs) and team mode’s per-subtask fence (newt-scheduler/src/team.rs), ported here (not forked) so the two paths cannot drift out of sync.
scratch
.scratch/ — the project-local ephemeral state root (#844), and its configurable relocation.
session
settings
Sticky user preferences (~/.newt/settings.toml).
ssh_caveats
SshCaveats — the custom OCAP surface for SSH (the long-haul transport and the carrier for git network ops). Sibling of GitCaveats: a separate capability lattice composed alongside the signed Caveats, by meet.
store
SQLite-backed conversation store — Phase 17.1a/17.1b (issue #246).
symbols
The verify oracle’s symbol index — “does the symbol this code references actually exist?”
templates
Project templates (#892) — the DATA sibling of tooling packs (#880).
tokens
Token-estimation settings — the chars-per-token heuristic as a config-backed value threaded explicitly through the estimators (no global state).
tooling
Lifecycle phases — a repo’s build/dev commands as configurable DATA, not hard-coded match arms (#880).
tuning
Community model tuning profiles.
verify_gate
The verify gate (#73) — the harness’s red-squiggle for fabricated imports, and R2’s decision core.
workflows
Configurable workflow steers.
workspace_key
Workspace identity v2 — step 17.2 (issue #246).

Structs§

Caveats
The capability set an agent holds — one element of the authority meet-semilattice. See the module docs.

Enums§

CountBound
A numeric upper bound axis (e.g. “at most N tool calls”).
Scope
A set-valued authority axis: either unrestricted (All, the top of this axis) or exactly the listed items.

Functions§

maybe_dispatch
Carried-coreutils dispatch (agent-bridle #206): a newt binary calls this at the top of main to become dispatch-capable, so the brush engine’s carried ls/cat shims re-exec against the newt binary itself. Run the bundled-command fast path if the process was invoked for it.