novakit 0.1.0__tar.gz

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 (99) hide show
  1. novakit-0.1.0/LICENSE +201 -0
  2. novakit-0.1.0/PKG-INFO +402 -0
  3. novakit-0.1.0/README.md +369 -0
  4. novakit-0.1.0/novakit/__init__.py +31 -0
  5. novakit-0.1.0/novakit/agent/__init__.py +86 -0
  6. novakit-0.1.0/novakit/agent/compaction.py +15 -0
  7. novakit-0.1.0/novakit/agent/config.py +61 -0
  8. novakit-0.1.0/novakit/agent/core.py +748 -0
  9. novakit-0.1.0/novakit/agent/hierarchy.py +49 -0
  10. novakit-0.1.0/novakit/agent/llm_stream.py +338 -0
  11. novakit-0.1.0/novakit/agent/messages.py +145 -0
  12. novakit-0.1.0/novakit/agent/overflow.py +93 -0
  13. novakit-0.1.0/novakit/agent/ports.py +69 -0
  14. novakit-0.1.0/novakit/agent/protocol.py +48 -0
  15. novakit-0.1.0/novakit/agent/services.py +86 -0
  16. novakit-0.1.0/novakit/agent/session.py +274 -0
  17. novakit-0.1.0/novakit/agent/spawn.py +13 -0
  18. novakit-0.1.0/novakit/agent/state.py +19 -0
  19. novakit-0.1.0/novakit/agent/title.py +149 -0
  20. novakit-0.1.0/novakit/agent/tool_guardrails.py +119 -0
  21. novakit-0.1.0/novakit/agent/tool_invoker.py +503 -0
  22. novakit-0.1.0/novakit/checkpoints.py +467 -0
  23. novakit-0.1.0/novakit/compaction/__init__.py +104 -0
  24. novakit-0.1.0/novakit/compaction/compactor.py +612 -0
  25. novakit-0.1.0/novakit/compaction/config.py +32 -0
  26. novakit-0.1.0/novakit/compaction/messages.py +253 -0
  27. novakit-0.1.0/novakit/compaction/policy.py +541 -0
  28. novakit-0.1.0/novakit/compaction/store.py +166 -0
  29. novakit-0.1.0/novakit/compaction/summary.py +168 -0
  30. novakit-0.1.0/novakit/constants.py +1 -0
  31. novakit-0.1.0/novakit/events.py +161 -0
  32. novakit-0.1.0/novakit/llm/__init__.py +47 -0
  33. novakit-0.1.0/novakit/llm/accumulator.py +109 -0
  34. novakit-0.1.0/novakit/llm/faker.py +1123 -0
  35. novakit-0.1.0/novakit/llm/framing.py +106 -0
  36. novakit-0.1.0/novakit/llm/http_provider.py +616 -0
  37. novakit-0.1.0/novakit/llm/images.py +213 -0
  38. novakit-0.1.0/novakit/llm/oneshot.py +99 -0
  39. novakit-0.1.0/novakit/llm/policy.py +179 -0
  40. novakit-0.1.0/novakit/llm/provider.py +388 -0
  41. novakit-0.1.0/novakit/llm/providers/__init__.py +18 -0
  42. novakit-0.1.0/novakit/llm/providers/anthropic.py +1172 -0
  43. novakit-0.1.0/novakit/llm/providers/ollama.py +283 -0
  44. novakit-0.1.0/novakit/llm/providers/openai_chat.py +517 -0
  45. novakit-0.1.0/novakit/llm/providers/openai_responses.py +645 -0
  46. novakit-0.1.0/novakit/llm/reasoning.py +122 -0
  47. novakit-0.1.0/novakit/llm/request_hook.py +125 -0
  48. novakit-0.1.0/novakit/llm/stream_driver.py +200 -0
  49. novakit-0.1.0/novakit/llm/stream_read.py +249 -0
  50. novakit-0.1.0/novakit/llm/stream_trace.py +130 -0
  51. novakit-0.1.0/novakit/llm/tokenizer.py +372 -0
  52. novakit-0.1.0/novakit/llm/user_agent.py +31 -0
  53. novakit-0.1.0/novakit/mcp/__init__.py +33 -0
  54. novakit-0.1.0/novakit/mcp/client.py +96 -0
  55. novakit-0.1.0/novakit/mcp/naming.py +186 -0
  56. novakit-0.1.0/novakit/mcp/transport.py +239 -0
  57. novakit-0.1.0/novakit/pricing.py +121 -0
  58. novakit-0.1.0/novakit/prompt/__init__.py +41 -0
  59. novakit-0.1.0/novakit/prompt/composition.py +130 -0
  60. novakit-0.1.0/novakit/prompt/project_instructions.py +196 -0
  61. novakit-0.1.0/novakit/prompt/threat_patterns.py +77 -0
  62. novakit-0.1.0/novakit/py.typed +0 -0
  63. novakit-0.1.0/novakit/session/__init__.py +27 -0
  64. novakit-0.1.0/novakit/session/fork.py +151 -0
  65. novakit-0.1.0/novakit/session/memory.py +276 -0
  66. novakit-0.1.0/novakit/session/models.py +196 -0
  67. novakit-0.1.0/novakit/session/protocol.py +155 -0
  68. novakit-0.1.0/novakit/skills/__init__.py +25 -0
  69. novakit-0.1.0/novakit/skills/catalog.py +53 -0
  70. novakit-0.1.0/novakit/skills/models.py +44 -0
  71. novakit-0.1.0/novakit/skills/scanner.py +162 -0
  72. novakit-0.1.0/novakit/tasks/__init__.py +44 -0
  73. novakit-0.1.0/novakit/tasks/manager.py +614 -0
  74. novakit-0.1.0/novakit/tasks/models.py +161 -0
  75. novakit-0.1.0/novakit/tasks/process.py +95 -0
  76. novakit-0.1.0/novakit/tools/__init__.py +25 -0
  77. novakit-0.1.0/novakit/tools/approval.py +253 -0
  78. novakit-0.1.0/novakit/tools/behavior.py +119 -0
  79. novakit-0.1.0/novakit/tools/context.py +25 -0
  80. novakit-0.1.0/novakit/tools/registry.py +215 -0
  81. novakit-0.1.0/novakit/version.py +5 -0
  82. novakit-0.1.0/novakit.egg-info/PKG-INFO +402 -0
  83. novakit-0.1.0/novakit.egg-info/SOURCES.txt +97 -0
  84. novakit-0.1.0/novakit.egg-info/dependency_links.txt +1 -0
  85. novakit-0.1.0/novakit.egg-info/requires.txt +14 -0
  86. novakit-0.1.0/novakit.egg-info/top_level.txt +1 -0
  87. novakit-0.1.0/pyproject.toml +78 -0
  88. novakit-0.1.0/setup.cfg +4 -0
  89. novakit-0.1.0/tests/test_agent_leaves.py +171 -0
  90. novakit-0.1.0/tests/test_agent_primitives.py +66 -0
  91. novakit-0.1.0/tests/test_agent_runtime.py +319 -0
  92. novakit-0.1.0/tests/test_approval.py +90 -0
  93. novakit-0.1.0/tests/test_boundaries.py +85 -0
  94. novakit-0.1.0/tests/test_checkpoints.py +279 -0
  95. novakit-0.1.0/tests/test_inmemory_session.py +108 -0
  96. novakit-0.1.0/tests/test_llm_stream_reader.py +392 -0
  97. novakit-0.1.0/tests/test_pricing.py +63 -0
  98. novakit-0.1.0/tests/test_release_script.py +53 -0
  99. novakit-0.1.0/tests/test_tool_invoker.py +72 -0
novakit-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 bigrivi
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
novakit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,402 @@
1
+ Metadata-Version: 2.4
2
+ Name: novakit
3
+ Version: 0.1.0
4
+ Summary: Embeddable Python runtime for LLM agents, tools, events, and conversations.
5
+ Author: bigrivi
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/bigrivi/novakit
8
+ Project-URL: Repository, https://github.com/bigrivi/novakit
9
+ Project-URL: Issues, https://github.com/bigrivi/novakit/issues
10
+ Project-URL: Changelog, https://github.com/bigrivi/novakit/blob/main/CHANGELOG.md
11
+ Keywords: ai,ai-agent,llm,tools,sdk
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: aiohttp
22
+ Requires-Dist: tiktoken
23
+ Provides-Extra: images
24
+ Requires-Dist: pillow; extra == "images"
25
+ Provides-Extra: mcp
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.11; extra == "dev"
28
+ Requires-Dist: pytest>=7.4; extra == "dev"
29
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
30
+ Requires-Dist: pytest-cov>=6.0; extra == "dev"
31
+ Requires-Dist: ruff<0.18,>=0.17.4; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # novakit
35
+
36
+ `novakit` is an embeddable, in-memory-first Python runtime for LLM agents. It
37
+ provides providers, streaming events, tool execution, sessions, and approvals
38
+ without coupling applications to Nova's server, desktop, user directory, or
39
+ database.
40
+
41
+ ## Installation
42
+
43
+ Python 3.12 or newer is required.
44
+
45
+ ```bash
46
+ pip install novakit
47
+ ```
48
+
49
+ For local development:
50
+
51
+ ```bash
52
+ git clone git@github.com:bigrivi/novakit.git
53
+ cd novakit
54
+ uv sync --extra dev
55
+ ```
56
+
57
+ ## Quickstart
58
+
59
+ ```python
60
+ import asyncio
61
+
62
+ from novakit import Agent, AgentConfig
63
+ from novakit.llm import FakerLLMProvider
64
+
65
+
66
+ async def main() -> None:
67
+ agent = Agent(
68
+ AgentConfig(model="fake", max_iterations=4),
69
+ FakerLLMProvider(seed=1),
70
+ )
71
+ async for event, payload in agent.chat_stream("Hello"):
72
+ print(event, payload)
73
+
74
+
75
+ asyncio.run(main())
76
+ ```
77
+
78
+ The default session lives only in the `Agent` instance. Nothing is written to
79
+ `HOME`, `NOVA_HOME`, or `~/.nova`, and no database connection is opened.
80
+
81
+ ## Core concepts
82
+
83
+ ### Agent runtime
84
+
85
+ `Agent` owns the shared turn loop:
86
+
87
+ 1. Resolve or create a session.
88
+ 2. Persist the user message.
89
+ 3. Build provider messages.
90
+ 4. Consume the model stream.
91
+ 5. Persist the assistant message.
92
+ 6. Execute requested tools.
93
+ 7. Repeat until completion, input is required, execution stops, or the iteration
94
+ limit is reached.
95
+
96
+ Every tool call announced to the caller receives a terminal result, error,
97
+ rejection, or cancellation result.
98
+
99
+ Hosts can use `InMemoryHierarchy` for live parent/child links and `SPAWN_DEPTH`
100
+ for task-local delegation depth; neither performs persistence or global lookups.
101
+
102
+ ### Configuration
103
+
104
+ The runtime depends on the narrow `CoreConfig` protocol:
105
+
106
+ - `model`
107
+ - `provider`
108
+ - `max_iterations`
109
+ - `reasoning_effort`
110
+
111
+ `AgentConfig` remains a concrete, backward-compatible superset with Nova's
112
+ original field order. Only the four `CoreConfig` fields affect the standalone
113
+ core; the rest are host compatibility fields the core ignores:
114
+
115
+ | Field | Owner | Meaning |
116
+ | --- | --- | --- |
117
+ | `model` / `provider` / `max_iterations` / `reasoning_effort` | core | Read by the turn loop |
118
+ | `max_tokens` / `temperature` / `tools` / `memory_review_interval` / `shell_review` / `permission_mode` / `shell_read_only` | host | Kept for compatibility; ignored by core |
119
+
120
+ Field order is frozen in `0.x`: do not add host fields to `AgentConfig`, and
121
+ removing or reordering fields is a major change. New hosts can depend on a
122
+ `CoreConfig`-shaped object instead of inheriting compatibility fields:
123
+
124
+ ```python
125
+ from dataclasses import dataclass
126
+
127
+
128
+ @dataclass
129
+ class MyConfig:
130
+ model: str = "my-model"
131
+ provider: str = "my-provider"
132
+ max_iterations: int = 10
133
+ reasoning_effort: str | None = None
134
+ ```
135
+
136
+ This object satisfies `CoreConfig` and can be passed directly to `Agent`. Keep
137
+ host-specific settings in your own configuration type rather than adding them to
138
+ `AgentConfig`.
139
+
140
+ ### Sessions and persistence
141
+
142
+ `InMemorySession` is the default. Each instance owns its sessions, messages, and
143
+ current-session `ContextVar`.
144
+
145
+ Implement `SessionProtocol` and inject it through `AgentOptions(session=...)` to
146
+ use a database or another persistence backend.
147
+
148
+ Hosts that need branching can use `novakit.session.fork.fork_session` with a
149
+ `SessionForkStore`; it copies whole messages, preserves tool pairing and route
150
+ metadata, and never mutates the source session.
151
+
152
+ ### Session titles
153
+
154
+ `novakit.agent.title.generate_session_title` builds the untrusted-message prompt,
155
+ cleans markdown/quote wrappers, enforces the length limit, and applies a one-shot
156
+ timeout. It returns `None` on failure and never schedules work or writes a title;
157
+ the host decides when to run it and how to persist the result.
158
+
159
+ ```python
160
+ from novakit.agent.title import generate_session_title
161
+
162
+ title = await generate_session_title(
163
+ llm,
164
+ first_message="Investigate the flaky tests",
165
+ model="my-model",
166
+ session_id=session.id,
167
+ )
168
+ if title is not None:
169
+ await session.apply_generated_title(session.id, title, expected_title)
170
+ ```
171
+
172
+ ### Project instructions
173
+
174
+ `novakit.prompt.discover_project_instructions` discovers host-supplied global
175
+ instructions and project files from the git root to the workspace, applies
176
+ filename precedence, screens project files for high-confidence injection shapes,
177
+ and truncates from the broadest end. The host supplies the global directory and
178
+ policy through `ProjectInstructionConfig`; novakit never reads `HOME` or
179
+ `NOVA_HOME` itself.
180
+
181
+ ```python
182
+ from novakit.prompt import ProjectInstructionConfig, discover_project_instructions
183
+
184
+ instructions = discover_project_instructions(
185
+ workspace,
186
+ ProjectInstructionConfig(global_dir=host_instruction_dir),
187
+ )
188
+ ```
189
+
190
+ `novakit.prompt` also exposes product-neutral section helpers for ordered
191
+ composition, environment rendering, sub-agent rosters, and abbreviated skill
192
+ lists. Product persona, delegation policy, and final section order remain with
193
+ the host.
194
+
195
+ ### Tools and approvals
196
+
197
+ Register tools with `ToolRegistry` and the `@tool` decorator. Tool behaviors can
198
+ normalize input, authorize execution, post-process results, and run success
199
+ hooks.
200
+
201
+ Approvals use a process-local `InMemoryApprovalManager` by default. Subscribe to
202
+ `APPROVAL_REQUIRED` and call:
203
+
204
+ ```python
205
+ agent.resolve_approval(request_id, approved)
206
+ ```
207
+
208
+ Inject a different manager through `AgentPorts(approval=...)` when the host has
209
+ its own approval policy.
210
+
211
+ Loop guardrails default to the historical host read-tool names for
212
+ compatibility. Pass your own set explicitly:
213
+
214
+ ```python
215
+ from novakit.agent import ToolGuardrails
216
+
217
+ guardrails = ToolGuardrails(read_tools=frozenset({"read", "search"}))
218
+ ```
219
+
220
+ A convenient source is the registry's `Tool.read_only` flags. The default
221
+ set is frozen in `0.x`; changing it is a behavior change, not a patch fix.
222
+
223
+ ### Host ports
224
+
225
+ ```python
226
+ from novakit import AgentOptions
227
+ from novakit.agent import AgentPorts
228
+
229
+ options = AgentOptions(
230
+ session=my_session,
231
+ tools=my_tools,
232
+ events=my_events,
233
+ ports=AgentPorts(
234
+ compactor=my_compactor,
235
+ approval=my_approval_manager,
236
+ begin_turn=my_checkpoint_recorder,
237
+ ),
238
+ )
239
+ ```
240
+
241
+ - `SessionProtocol` controls persistence.
242
+ - `Compactor` controls context compaction and never receives a Nova database type.
243
+ - `ApprovalManager` controls tool approval policy.
244
+ - `begin_turn` records host-specific checkpoints.
245
+
246
+ Broader stream-end cleanup remains the host server or UI's responsibility;
247
+ `novakit` guarantees terminal pairing inside its tool invoker.
248
+
249
+ ### Compaction
250
+
251
+ `novakit.compaction.DefaultCompactor` provides portable history planning, tool
252
+ result snipping, summary generation, retry, and circuit-breaking while satisfying
253
+ the existing `Compactor` port. The default in-memory persistence adapter works
254
+ with `InMemorySession`:
255
+
256
+ ```python
257
+ from novakit import AgentOptions
258
+ from novakit.agent import AgentPorts
259
+ from novakit.compaction import (
260
+ CompactionConfig,
261
+ DefaultCompactor,
262
+ MemoryCompactionStore,
263
+ )
264
+ from novakit.session import InMemorySession
265
+
266
+ session = InMemorySession()
267
+ compactor = DefaultCompactor(
268
+ model="my-model",
269
+ provider="my-provider",
270
+ store=MemoryCompactionStore(session),
271
+ config=CompactionConfig(summary_keep_tokens=20_000),
272
+ )
273
+ options = AgentOptions(
274
+ session=session,
275
+ ports=AgentPorts(compactor=compactor),
276
+ )
277
+ ```
278
+
279
+ Hosts inject the pieces that depend on their environment:
280
+
281
+ - `TokenResolver` supplies token estimates and context limits. The default uses
282
+ novakit's built-in model table; hosts with a model catalogue can inject their
283
+ own resolver.
284
+ - `ToolOutputSink` optionally stores full tool output before it is snipped.
285
+ novakit calls the sink but never chooses or creates an offload directory.
286
+ - `CompactionStore` persists content updates, summaries, compaction markers, and
287
+ timestamps. `MemoryCompactionStore` is the standalone default; database hosts
288
+ provide a thin adapter.
289
+
290
+ No compaction path reads `HOME`/`NOVA_HOME`, creates user directories, or performs
291
+ database I/O unless the host injects code that does.
292
+
293
+ ### Background tasks
294
+
295
+ `novakit.tasks.BackgroundTaskManager` provides executor registration, separate
296
+ foreground/background concurrency pools, per-session quotas, timeouts,
297
+ cancellation, progress, listeners, retention, and bounded output. Hosts supply
298
+ executors; the manager has no process-global singleton or built-in registry.
299
+
300
+ ```python
301
+ from novakit.tasks import BackgroundTaskManager
302
+
303
+ manager = BackgroundTaskManager(max_concurrent=2)
304
+ # Register a host executor that implements kind and execute(...).
305
+ record = manager.submit(
306
+ "host_kind",
307
+ {"argument": "value"},
308
+ session_id=session.id,
309
+ label="Host work",
310
+ timeout_seconds=30,
311
+ background=True,
312
+ )
313
+ completed = await manager.wait(record.task_id, session.id, timeout=5)
314
+ ```
315
+
316
+ ## Optional runtime utilities
317
+
318
+ - `novakit.tasks.process.run_process` executes an explicit argv/cwd/environment,
319
+ streams merged output, and kills the process tree on cancellation.
320
+ - `novakit.skills` parses and scans `SKILL.md` files under a caller-supplied root
321
+ and provides a case-insensitive catalog.
322
+ - `novakit.checkpoints.CheckpointStore` captures and restores file pre-images
323
+ under an explicit root path or root provider. It never chooses a home directory.
324
+
325
+ ## Providers
326
+
327
+ Included providers:
328
+
329
+ - OpenAI Chat Completions
330
+ - OpenAI Responses
331
+ - Anthropic
332
+ - Ollama
333
+
334
+ The package also includes streaming framing, retry policy, image handling,
335
+ tokenization, reasoning metadata, and configurable User-Agent support.
336
+
337
+ `novakit.pricing` provides pure per-million-token cost math and unknown-price
338
+ handling. Catalogue loading and model discovery remain host responsibilities.
339
+
340
+ ### Optional MCP support
341
+
342
+ Install the optional namespace with `pip install novakit[mcp]`. It provides a
343
+ JSON-RPC client, stdio/HTTP transports, and deterministic tool-name allocation
344
+ without choosing servers, settings, or permissions for the host.
345
+
346
+ ```python
347
+ from novakit.mcp import McpClient, create_transport
348
+
349
+ transport = create_transport({"command": "my-mcp-server"})
350
+ await transport.connect()
351
+ client = McpClient(
352
+ "my-server",
353
+ transport,
354
+ client_name="my-product",
355
+ client_version="1.0",
356
+ )
357
+ await client.initialize()
358
+ tools = await client.list_tools()
359
+ ```
360
+
361
+ ## Development
362
+
363
+ ```bash
364
+ uv sync --locked --extra dev
365
+ uv run pytest -q --cov=novakit --cov-report=term-missing
366
+ uv run ruff check novakit tests
367
+ uv run ruff format novakit tests
368
+ uv run mypy
369
+ uv build --wheel --out-dir dist
370
+ bash scripts/smoke_wheel.sh
371
+ ```
372
+
373
+ The test suite enforces at least 99% line coverage for the `novakit` package.
374
+ Coverage runs offline; provider transports, filesystem access, and external
375
+ services are replaced with test doubles.
376
+
377
+ The wheel smoke test installs the built wheel into an isolated directory and
378
+ verifies that a default agent can complete an in-memory conversation without
379
+ loading Nova.
380
+
381
+ ## Documentation
382
+
383
+ - [Changelog](CHANGELOG.md)
384
+ - [Issues](https://github.com/bigrivi/novakit/issues)
385
+
386
+ ## Release process
387
+
388
+ Tagging `vX.Y.Z` starts `.github/workflows/publish.yml`. It verifies the tag
389
+ against both `pyproject.toml` and `novakit/version.py`, runs the full test/lint/type
390
+ preflight, checks distribution metadata, builds and smoke-tests sdist/wheel, then
391
+ publishes the same artifacts to TestPyPI. An isolated TestPyPI installation must
392
+ pass before the protected PyPI environment can publish through OIDC Trusted
393
+ Publishing.
394
+
395
+ Repository administrators must create protected GitHub environments named
396
+ `testpypi` and `pypi`, enable required reviewers for manual approval, and register
397
+ both environments as trusted publishers on their respective PyPI indexes. The
398
+ workflow deliberately has no long-lived API tokens.
399
+
400
+ ## License
401
+
402
+ Apache-2.0. See [LICENSE](LICENSE).