novakit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. novakit/__init__.py +31 -0
  2. novakit/agent/__init__.py +86 -0
  3. novakit/agent/compaction.py +15 -0
  4. novakit/agent/config.py +61 -0
  5. novakit/agent/core.py +748 -0
  6. novakit/agent/hierarchy.py +49 -0
  7. novakit/agent/llm_stream.py +338 -0
  8. novakit/agent/messages.py +145 -0
  9. novakit/agent/overflow.py +93 -0
  10. novakit/agent/ports.py +69 -0
  11. novakit/agent/protocol.py +48 -0
  12. novakit/agent/services.py +86 -0
  13. novakit/agent/session.py +274 -0
  14. novakit/agent/spawn.py +13 -0
  15. novakit/agent/state.py +19 -0
  16. novakit/agent/title.py +149 -0
  17. novakit/agent/tool_guardrails.py +119 -0
  18. novakit/agent/tool_invoker.py +503 -0
  19. novakit/checkpoints.py +467 -0
  20. novakit/compaction/__init__.py +104 -0
  21. novakit/compaction/compactor.py +612 -0
  22. novakit/compaction/config.py +32 -0
  23. novakit/compaction/messages.py +253 -0
  24. novakit/compaction/policy.py +541 -0
  25. novakit/compaction/store.py +166 -0
  26. novakit/compaction/summary.py +168 -0
  27. novakit/constants.py +1 -0
  28. novakit/events.py +161 -0
  29. novakit/llm/__init__.py +47 -0
  30. novakit/llm/accumulator.py +109 -0
  31. novakit/llm/faker.py +1123 -0
  32. novakit/llm/framing.py +106 -0
  33. novakit/llm/http_provider.py +616 -0
  34. novakit/llm/images.py +213 -0
  35. novakit/llm/oneshot.py +99 -0
  36. novakit/llm/policy.py +179 -0
  37. novakit/llm/provider.py +388 -0
  38. novakit/llm/providers/__init__.py +18 -0
  39. novakit/llm/providers/anthropic.py +1172 -0
  40. novakit/llm/providers/ollama.py +283 -0
  41. novakit/llm/providers/openai_chat.py +517 -0
  42. novakit/llm/providers/openai_responses.py +645 -0
  43. novakit/llm/reasoning.py +122 -0
  44. novakit/llm/request_hook.py +125 -0
  45. novakit/llm/stream_driver.py +200 -0
  46. novakit/llm/stream_read.py +249 -0
  47. novakit/llm/stream_trace.py +130 -0
  48. novakit/llm/tokenizer.py +372 -0
  49. novakit/llm/user_agent.py +31 -0
  50. novakit/mcp/__init__.py +33 -0
  51. novakit/mcp/client.py +96 -0
  52. novakit/mcp/naming.py +186 -0
  53. novakit/mcp/transport.py +239 -0
  54. novakit/pricing.py +121 -0
  55. novakit/prompt/__init__.py +41 -0
  56. novakit/prompt/composition.py +130 -0
  57. novakit/prompt/project_instructions.py +196 -0
  58. novakit/prompt/threat_patterns.py +77 -0
  59. novakit/py.typed +0 -0
  60. novakit/session/__init__.py +27 -0
  61. novakit/session/fork.py +151 -0
  62. novakit/session/memory.py +276 -0
  63. novakit/session/models.py +196 -0
  64. novakit/session/protocol.py +155 -0
  65. novakit/skills/__init__.py +25 -0
  66. novakit/skills/catalog.py +53 -0
  67. novakit/skills/models.py +44 -0
  68. novakit/skills/scanner.py +162 -0
  69. novakit/tasks/__init__.py +44 -0
  70. novakit/tasks/manager.py +614 -0
  71. novakit/tasks/models.py +161 -0
  72. novakit/tasks/process.py +95 -0
  73. novakit/tools/__init__.py +25 -0
  74. novakit/tools/approval.py +253 -0
  75. novakit/tools/behavior.py +119 -0
  76. novakit/tools/context.py +25 -0
  77. novakit/tools/registry.py +215 -0
  78. novakit/version.py +5 -0
  79. novakit-0.1.0.dist-info/METADATA +402 -0
  80. novakit-0.1.0.dist-info/RECORD +83 -0
  81. novakit-0.1.0.dist-info/WHEEL +5 -0
  82. novakit-0.1.0.dist-info/licenses/LICENSE +201 -0
  83. novakit-0.1.0.dist-info/top_level.txt +1 -0
novakit/__init__.py ADDED
@@ -0,0 +1,31 @@
1
+ """Embeddable LLM agent primitives.
2
+
3
+ The first release exposes providers, stream events, tool registration, session
4
+ models, and agent event frames. It intentionally has no user-directory or
5
+ persistence defaults.
6
+ """
7
+
8
+ from novakit.agent import Agent, AgentConfig, AgentOptions, CoreConfig
9
+ from novakit.events import AgentEvent, AgentEventFrame, EventBus
10
+ from novakit.llm import LLMProvider, Message
11
+ from novakit.session import Message as SessionMessage
12
+ from novakit.session import SessionProtocol
13
+ from novakit.tools import ToolRegistry, tool
14
+ from novakit.version import __version__
15
+
16
+ __all__ = [
17
+ "Agent",
18
+ "AgentConfig",
19
+ "AgentEvent",
20
+ "AgentEventFrame",
21
+ "AgentOptions",
22
+ "CoreConfig",
23
+ "EventBus",
24
+ "LLMProvider",
25
+ "Message",
26
+ "SessionMessage",
27
+ "SessionProtocol",
28
+ "ToolRegistry",
29
+ "__version__",
30
+ "tool",
31
+ ]
@@ -0,0 +1,86 @@
1
+ """Agent runtime primitives shared by hosts and standalone novakit users."""
2
+
3
+ from novakit.agent.compaction import CompactionError
4
+ from novakit.agent.config import AgentConfig, CoreConfig
5
+ from novakit.agent.core import (
6
+ Agent,
7
+ AgentOptions,
8
+ AgentRuntimeDependencies,
9
+ ChatOptions,
10
+ PreparedRequest,
11
+ )
12
+ from novakit.agent.llm_stream import EventData, TurnOutcome, TurnStreamReader
13
+ from novakit.agent.messages import (
14
+ build_user_message,
15
+ convert_to_llm_messages,
16
+ count_user_turns,
17
+ )
18
+ from novakit.agent.overflow import (
19
+ NON_OVERFLOW_PATTERNS,
20
+ OVERFLOW_PATTERNS,
21
+ is_context_overflow,
22
+ )
23
+ from novakit.agent.ports import AgentPorts
24
+ from novakit.agent.protocol import ChatAgent, InterruptibleAgent
25
+ from novakit.agent.session import AgentSession, AgentSessionContext
26
+ from novakit.agent.state import TurnState
27
+ from novakit.agent.title import (
28
+ MAX_TITLE_LENGTH,
29
+ TITLE_CALL_TIMEOUT_SECONDS,
30
+ TITLE_SYSTEM_PROMPT,
31
+ TITLE_USER_TEMPLATE,
32
+ build_title_messages,
33
+ clean_title,
34
+ generate_session_title,
35
+ )
36
+ from novakit.agent.tool_guardrails import (
37
+ GuardrailAction,
38
+ GuardrailObservation,
39
+ ToolGuardrails,
40
+ )
41
+ from novakit.agent.tool_invoker import (
42
+ ToolInvoker,
43
+ ToolOutcome,
44
+ has_parsable_arguments,
45
+ parse_tool_arguments,
46
+ )
47
+
48
+ __all__ = [
49
+ "MAX_TITLE_LENGTH",
50
+ "NON_OVERFLOW_PATTERNS",
51
+ "OVERFLOW_PATTERNS",
52
+ "TITLE_CALL_TIMEOUT_SECONDS",
53
+ "TITLE_SYSTEM_PROMPT",
54
+ "TITLE_USER_TEMPLATE",
55
+ "Agent",
56
+ "AgentConfig",
57
+ "AgentOptions",
58
+ "AgentPorts",
59
+ "AgentRuntimeDependencies",
60
+ "AgentSession",
61
+ "AgentSessionContext",
62
+ "ChatAgent",
63
+ "ChatOptions",
64
+ "CompactionError",
65
+ "CoreConfig",
66
+ "EventData",
67
+ "GuardrailAction",
68
+ "GuardrailObservation",
69
+ "InterruptibleAgent",
70
+ "PreparedRequest",
71
+ "ToolGuardrails",
72
+ "ToolInvoker",
73
+ "ToolOutcome",
74
+ "TurnOutcome",
75
+ "TurnState",
76
+ "TurnStreamReader",
77
+ "build_title_messages",
78
+ "build_user_message",
79
+ "clean_title",
80
+ "convert_to_llm_messages",
81
+ "count_user_turns",
82
+ "generate_session_title",
83
+ "has_parsable_arguments",
84
+ "is_context_overflow",
85
+ "parse_tool_arguments",
86
+ ]
@@ -0,0 +1,15 @@
1
+ """Compaction error type shared by hosts and standalone novakit users."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ class CompactionError(RuntimeError):
7
+ """Raised when a required summary cannot be generated.
8
+
9
+ Compaction is load-bearing: a turn that must compact but cannot would
10
+ otherwise continue with an oversized history and fail later for an
11
+ unrelated-looking reason, so the failure is surfaced to the caller instead.
12
+ """
13
+
14
+
15
+ __all__ = ["CompactionError"]
@@ -0,0 +1,61 @@
1
+ """Core agent configuration plus host compatibility superset.
2
+
3
+ The runtime depends only on :class:`CoreConfig`. :class:`AgentConfig` keeps
4
+ the original field order for host compatibility.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass
10
+ from typing import Protocol, runtime_checkable
11
+
12
+
13
+ @runtime_checkable
14
+ class CoreConfig(Protocol):
15
+ """Configuration fields read by the shared agent turn loop."""
16
+
17
+ model: str
18
+ provider: str
19
+ max_iterations: int
20
+ reasoning_effort: str | None
21
+
22
+
23
+ @dataclass
24
+ class AgentConfig:
25
+ """Tunable inputs for one agent run.
26
+
27
+ Only ``model``, ``provider``, ``max_iterations``, and ``reasoning_effort``
28
+ (the :class:`CoreConfig` fields) are read by the standalone core; the rest
29
+ are host compatibility fields the core ignores.
30
+
31
+ Field order is frozen in 0.x: do not add new host fields here, and
32
+ removing or reordering fields is a major change.
33
+ """
34
+
35
+ # Model key as defined in config.json (e.g., "my-gemma")
36
+ model: str = "gpt-4o"
37
+ provider: str = "ollama"
38
+ max_iterations: int = 100
39
+ # Host compatibility field; the core ignores it.
40
+ max_tokens: int = 8192
41
+ # Host compatibility field; the core ignores it.
42
+ temperature: float = 0.7
43
+ # Host compatibility field; the core ignores it.
44
+ tools: list | None = None
45
+ # Host compatibility field; the core ignores it.
46
+ memory_review_interval: int = 10
47
+ # Reasoning level for this run. None means "whatever the model config
48
+ # declares", which is also what a provider that has no such concept gets.
49
+ reasoning_effort: str | None = None
50
+ # Host compatibility field; the core ignores it. Ask a model to review
51
+ # flagged actions instead of interrupting the user for every one.
52
+ shell_review: bool = False
53
+ # Host compatibility field; the core ignores it. ``ask`` waits for a
54
+ # human; ``dontAsk`` refuses instead, for runs with nobody at keyboard.
55
+ permission_mode: str = "ask"
56
+ # Host compatibility field; the core ignores it. When True, the shell
57
+ # tool refuses anything it cannot prove only reads.
58
+ shell_read_only: bool = False
59
+
60
+
61
+ __all__ = ["AgentConfig", "CoreConfig"]