Metadata-Version: 2.4
Name: agentivium-core
Version: 0.5.0
Summary: Core abstractions for Agentivium agent-native systems.
Author: Agentivium AI
License: MIT License
        
        Copyright (c) 2026 Agentivium AI
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: pydantic<3,>=2.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

# Agentivium Core

`agentivium-core` defines the small, domain-neutral contracts shared by
Agentivium agent-native systems. It provides typed schemas and abstract
interfaces for intent parsing, policy validation, planning, tool adaptation,
provider-neutral LLM calls, execution tracing, evaluation, and stateful
assistant runtimes. Version 0.5.0 adds scoped conversation memory, deterministic
context compaction, structured retrieval, optional vector-store adapters, and
durable support for long-running threads on top of the 0.4 verification kernel.

It is not an agent runtime, a provider-specific LLM wrapper, or a domain
implementation. Schedulers, provider clients, policies, and orchestration
belong in extension packages.

## Install

```bash
pip install agentivium-core
```

For local development:

```bash
pip install -e ".[dev]"
```

## Extend the core

Domain packages subclass schemas and implement interfaces:

```python
from agentivium_core.intent import IntentIR, IntentParser


class MyIntentIR(IntentIR):
    domain: str = "my_domain"
    task: str


class MyIntentParser(IntentParser):
    def parse(
        self,
        request: str,
        context: dict[str, object] | None = None,
    ) -> MyIntentIR:
        return MyIntentIR(raw_request=request, task=request)
```

The dependency direction stays one-way: domain packages import
`agentivium_core`; the core never imports a domain package.

## Verifiable intent kernel

The 0.4.0 kernel keeps domain semantics in extensions while core provides the
mechanism:

```text
Intent + snapshots + candidate decision + evidence
  → verification checks
  → intent-decision relation
  → admissibility
  → approval / escalation
  → guarded domain execution
  → audit trace
```

The default policy fails closed: unsupported hard constraints, unknown policy
compliance, missing required evidence, contradictions, expired snapshots, and
provider exceptions cannot produce an accepted decision. Admissibility remains
separate from authorization and approval.

Stable cross-package imports are documented in the
[0.4 compatibility note](docs/compatibility_0_4.md). See the
[verifiable-intent guide](docs/verifiable_intent.md) for a complete non-domain
extension example and strictness behavior.

## Memory and retrieval

The 0.5.0 memory layer makes lifecycle and authority boundaries explicit.
Records declare scope, namespace, provenance, confidence, expiry, and
supersession. Retrieval excludes expired or superseded records by default.
Compaction is an application-replaceable contract; the offline reference
implementation preserves recent turns verbatim and produces a traceable summary
without storing hidden reasoning.

```python
from agentivium_core.memory import InMemoryMemoryStore, MemoryQuery, MemoryRecord
from agentivium_core.retrieval import MemoryRetriever

store = InMemoryMemoryStore()
store.add(
    MemoryRecord(
        memory_id="preference-1",
        memory_type="preference",
        text="Prefer concise answers",
        content={"response_style": "concise"},
        thread_id="thread-1",
    )
)

matches = store.query(MemoryQuery(text="concise", thread_id="thread-1"))
results = MemoryRetriever(store, thread_id="thread-1").retrieve("concise")
```

Vector retrieval remains optional: applications inject an `EmbeddingClient`
and a `VectorStore`; Core includes only an in-memory cosine adapter for tests
and small local deployments. See the [0.5 compatibility note](docs/compatibility_0_5.md).

## Public API

```python
from agentivium_core.intent import IntentIR, IntentParser
from agentivium_core.planner import ActionPlan, Planner
from agentivium_core.policy import (
    PolicyValidator,
    ValidationIssue,
    ValidationResult,
)
from agentivium_core.tools import ToolAdapter
from agentivium_core.trace import ExecutionTrace
from agentivium_core.eval import EvaluationRecord
```

## Stateful assistant runtime

Agentivium Core 0.3.0 added reusable abstractions for multi-turn assistant
systems: conversation state, context packs, memory, retrieval, ambiguity
modeling, clarification requests, intent updates, tool permissions, trace
events, and multi-turn evaluation records.

```python
from agentivium_core.clarification import (
    BlockingFirstClarificationPlanner,
    IntentAmbiguity,
)

ambiguities = [
    IntentAmbiguity(
        field="policy.account",
        ambiguity_type="missing_required",
        severity="blocking",
        reason="Account is required.",
        question="Which account should I use?",
    )
]

planner = BlockingFirstClarificationPlanner()
request = planner.plan_clarification(ambiguities)

print(request.questions[0].question)
```

Domain packages specialize these contracts. For example, `hpc-claw` can build
HPC-specific context providers, policy checks, and tool adapters on top of the
core assistant-runtime interfaces without adding scheduler logic to core.

## Provider-neutral LLM abstraction

`agentivium-core` defines `LLMClient`, `LLMRequest`, `LLMResponse`,
`PromptTemplate`, `StructuredOutputSpec`, and `LLMCallTrace` so downstream
packages can use LLMs without coupling core to OpenAI, Anthropic, Gemini,
Ollama, vLLM, llama.cpp, or any other provider.

```python
from agentivium_core.llm import (
    LLMClient,
    LLMRequest,
    LLMResponse,
    PromptTemplate,
)


class MyLocalLLMClient(LLMClient):
    def generate(self, request: LLMRequest) -> LLMResponse:
        return LLMResponse(content='{"intent": "example"}', model="local")


template = PromptTemplate(
    name="intent_parser",
    system="You extract structured intent.",
    user_template="Request: {request}",
)

messages = template.render({"request": "Run a small MPI job."})
client = MyLocalLLMClient()
response = client.generate(LLMRequest(messages=messages))
print(response.content)
```

Production provider clients live in domain or provider packages. Core only
defines the contracts and a `MockLLMClient` for tests and demos.

See the [concepts](docs/concepts.md), [API reference](docs/api.md),
[extension guide](docs/extension_guide.md), and
[examples](docs/examples.md). The complete v0.1 rationale and boundaries are
preserved in the original [design guideline](docs/design-guideline.md).
