entropic-engine 2.2.0__tar.gz → 2.2.1__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 (28) hide show
  1. {entropic_engine-2.2.0/python/src/entropic_engine.egg-info → entropic_engine-2.2.1}/PKG-INFO +1 -1
  2. entropic_engine-2.2.1/VERSION +1 -0
  3. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/__init__.py +10 -52
  4. entropic_engine-2.2.1/python/src/entropic/_bindings.py +336 -0
  5. entropic_engine-2.2.1/python/src/entropic/_bindings_manifest.py +126 -0
  6. {entropic_engine-2.2.0 → entropic_engine-2.2.1/python/src/entropic_engine.egg-info}/PKG-INFO +1 -1
  7. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic_engine.egg-info/SOURCES.txt +1 -0
  8. entropic_engine-2.2.0/VERSION +0 -1
  9. entropic_engine-2.2.0/python/src/entropic/_bindings.py +0 -493
  10. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/AUTHORS +0 -0
  11. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/LICENSE +0 -0
  12. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/NOTICE +0 -0
  13. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/README.md +0 -0
  14. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/pyproject.toml +0 -0
  15. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/__main__.py +0 -0
  16. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/_loader.py +0 -0
  17. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/cli.py +0 -0
  18. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/helpers.py +0 -0
  19. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/hooks.py +0 -0
  20. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/install_engine.py +0 -0
  21. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/mcp.py +0 -0
  22. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/py.typed +0 -0
  23. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic/streams.py +0 -0
  24. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic_engine.egg-info/dependency_links.txt +0 -0
  25. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic_engine.egg-info/entry_points.txt +0 -0
  26. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic_engine.egg-info/requires.txt +0 -0
  27. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/python/src/entropic_engine.egg-info/top_level.txt +0 -0
  28. {entropic_engine-2.2.0 → entropic_engine-2.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: entropic-engine
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Local-first agentic inference engine — Python wrapper over librentropic.so
5
5
  Author: Tristan VanFossen
6
6
  License-Expression: LGPL-3.0-or-later
@@ -0,0 +1 @@
1
+ 2.2.1
@@ -44,58 +44,16 @@ except PackageNotFoundError: # pragma: no cover — uninstalled source-tree run
44
44
  _version_file = Path(__file__).resolve().parents[3] / "VERSION"
45
45
  __version__ = _version_file.read_text().strip() if _version_file.exists() else "0.0.0+local"
46
46
 
47
- _LAZY_EXPORTS = frozenset(
48
- {
49
- "AgentState",
50
- "EntropicError",
51
- # Issue #8 (v2.1.4): EntropicHookPoint enum + 4 new ABI symbols.
52
- "EntropicHookPoint",
53
- "HOOK_CB",
54
- # gh#22 (v2.1.5): C-ABI-documentation-spelled CFUNCTYPE aliases.
55
- "HOOK_CALLBACK_CB",
56
- "TOKEN_STREAM_CB",
57
- "STATE_OBSERVER_CB",
58
- "STREAM_OBSERVER_CB",
59
- "TOKEN_CB",
60
- # gh#29 (v2.1.5): delegation callbacks — replaces auto-merge.
61
- "DELEGATION_START_CB",
62
- "DELEGATION_COMPLETE_CB",
63
- "EntDecision",
64
- "EntDelegationRequest",
65
- "EntDelegationResult",
66
- "entropic_set_delegation_callbacks",
67
- # gh#30 (v2.1.5): validation retry controls.
68
- "ATTEMPT_BOUNDARY_CB",
69
- "entropic_set_attempt_boundary_cb",
70
- "entropic_validation_accept_last",
71
- "entropic_validation_resume_retry",
72
- "entropic_validation_set_auto_retry",
73
- "entropic_alloc",
74
- "entropic_api_version",
75
- "entropic_configure_dir",
76
- "entropic_context_clear",
77
- "entropic_context_count",
78
- # gh#22 (v2.1.5): closes gh#8 partial gap.
79
- "entropic_context_get",
80
- # gh#39 (v2.1.8): token-level context pressure.
81
- "entropic_context_usage",
82
- "entropic_create",
83
- "entropic_destroy",
84
- "entropic_free",
85
- "entropic_handle_t",
86
- "entropic_interrupt",
87
- "entropic_register_hook",
88
- "entropic_register_mcp_server",
89
- "entropic_run",
90
- "entropic_run_streaming",
91
- # gh#37 (v2.1.8): multimodal messages entry points.
92
- "entropic_run_messages",
93
- "entropic_run_messages_streaming",
94
- "entropic_set_state_observer",
95
- "entropic_set_stream_observer",
96
- "entropic_version",
97
- }
98
- )
47
+ # v2.2.1: the lazy-export set is now derived from the auto-generated
48
+ # manifest emitted by ``scripts/gen_bindings.py``. The manifest module
49
+ # does NOT import ctypes or load librentropic.so, so reading it here
50
+ # preserves the PEP 562 lazy-binding contract: ``entropic install-engine``
51
+ # can run before the .so exists on disk and still ``import entropic``
52
+ # successfully. The set covers every ENTROPIC_EXPORT in the C header
53
+ # plus the IntEnum / Structure / CFUNCTYPE typedefs the generator
54
+ # produces. To audit the surface, read
55
+ # ``python/src/entropic/_bindings_manifest.py``.
56
+ from entropic._bindings_manifest import EXPORTS as _LAZY_EXPORTS
99
57
 
100
58
  # Issue #8 (v2.1.4): Pythonic facade — top-level re-exports of the
101
59
  # decorator + helpers from the per-module surfaces. Keeps `entropic`
@@ -0,0 +1,336 @@
1
+ # SPDX-License-Identifier: LGPL-3.0-or-later
2
+ # AUTO-GENERATED by scripts/gen_bindings.py — do not edit.
3
+ # Run ``inv gen-bindings`` to regenerate; ``inv gen-bindings --check``
4
+ # runs in pre-commit and fails if the committed file drifts from the
5
+ # header. Source: include/entropic/entropic.h + types/*.h.
6
+ """ctypes bindings for librentropic.so (auto-generated).
7
+
8
+ This module exposes the entropic C ABI as a flat collection of ctypes
9
+ function objects, IntEnum classes, ctypes.Structure types, and CFUNCTYPE
10
+ callback typedefs. Symbol names match the C header verbatim.
11
+
12
+ For symbols not exposed here (none, by construction — the generator
13
+ covers every ENTROPIC_EXPORT in entropic.h), load librentropic.so
14
+ directly via :func:`entropic._loader.load`.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import ctypes
20
+ import enum
21
+
22
+ from entropic._loader import load
23
+
24
+ _lib = load()
25
+
26
+ # Opaque handle. C side: ``struct entropic_engine*``. From Python it is
27
+ # a void* the C functions interpret; pass ``ctypes.byref(handle)`` for
28
+ # out-params and ``handle`` for in-params.
29
+ entropic_handle_t = ctypes.c_void_p
30
+
31
+
32
+ ## @brief Pin restype/argtypes on a ctypes symbol from the loaded .so.
33
+ ## @utility
34
+ ## @version 2.2.1
35
+ def _bind(name, restype, *argtypes):
36
+ """Pin restype/argtypes on a symbol from the loaded library.
37
+
38
+ Helper used by every binding line below.
39
+ """
40
+ fn = getattr(_lib, name)
41
+ fn.restype = restype
42
+ fn.argtypes = list(argtypes)
43
+ return fn
44
+
45
+
46
+ # ── Enums ─────────────────────────────────────
47
+
48
+ class EntropicError(enum.IntEnum):
49
+ """Mirrors ``entropic_error_t`` from the C header."""
50
+
51
+ OK = 0
52
+ INVALID_ARGUMENT = 1
53
+ INVALID_CONFIG = 2
54
+ INVALID_STATE = 3
55
+ MODEL_NOT_FOUND = 4
56
+ LOAD_FAILED = 5
57
+ GENERATE_FAILED = 6
58
+ TOOL_NOT_FOUND = 7
59
+ PERMISSION_DENIED = 8
60
+ PLUGIN_VERSION_MISMATCH = 9
61
+ PLUGIN_LOAD_FAILED = 10
62
+ TIMEOUT = 11
63
+ CANCELLED = 12
64
+ OUT_OF_MEMORY = 13
65
+ IO = 14
66
+ INTERNAL = 15
67
+ SERVER_ALREADY_EXISTS = 16
68
+ SERVER_NOT_FOUND = 17
69
+ CONNECTION_FAILED = 18
70
+ INVALID_HANDLE = 19
71
+ TOOL_EXECUTION_FAILED = 20
72
+ STORAGE_FAILED = 21
73
+ IDENTITY_NOT_FOUND = 22
74
+ ALREADY_RUNNING = 23
75
+ NOT_RUNNING = 24
76
+ NOT_IMPLEMENTED = 25
77
+ INTERRUPTED = 26
78
+ ADAPTER_NOT_FOUND = 27
79
+ ADAPTER_LOAD_FAILED = 28
80
+ ADAPTER_SWAP_FAILED = 29
81
+ ADAPTER_CANCELLED = 30
82
+ GRAMMAR_NOT_FOUND = 31
83
+ GRAMMAR_INVALID = 32
84
+ MCP_KEY_DENIED = 33
85
+ LIMIT_REACHED = 34
86
+ ALREADY_EXISTS = 35
87
+ IN_USE = 36
88
+ PROFILE_NOT_FOUND = 37
89
+ TIME_LIMIT_EXCEEDED = 38
90
+ VALIDATION_FAILED = 39
91
+ COMPACTION_FAILED = 40
92
+ MODEL_NOT_ACTIVE = 41
93
+ EVAL_CONTEXT_FULL = 42
94
+ EVAL_FAILED = 43
95
+ IMAGE_LOAD_FAILED = 44
96
+ IMAGE_TOO_LARGE = 45
97
+ MMPROJ_LOAD_FAILED = 46
98
+ UNSUPPORTED_URL = 47
99
+ NOT_SUPPORTED = 48
100
+ STATE_INCOMPATIBLE = 49
101
+ NO_VISION_TIER = 50
102
+ QUEUE_FULL = 51
103
+ SPECULATIVE_INCOMPATIBLE_ARCH = 52
104
+
105
+ class AgentState(enum.IntEnum):
106
+ """Mirrors ``entropic_agent_state_t`` from the C header."""
107
+
108
+ IDLE = 0
109
+ PLANNING = 1
110
+ EXECUTING = 2
111
+ WAITING_TOOL = 3
112
+ VERIFYING = 4
113
+ DELEGATING = 5
114
+ COMPLETE = 6
115
+ ERROR = 7
116
+ INTERRUPTED = 8
117
+ PAUSED = 9
118
+
119
+ class EntropicModelState(enum.IntEnum):
120
+ """Mirrors ``entropic_model_state_t`` from the C header."""
121
+
122
+ COLD = 0
123
+ WARM = 1
124
+ ACTIVE = 2
125
+
126
+ class EntropicDirectiveType(enum.IntEnum):
127
+ """Mirrors ``entropic_directive_type_t`` from the C header."""
128
+
129
+ STOP_PROCESSING = 0
130
+ TIER_CHANGE = 1
131
+ DELEGATE = 2
132
+ PIPELINE = 3
133
+ COMPLETE = 4
134
+ CLEAR_SELF_TODOS = 5
135
+ INJECT_CONTEXT = 6
136
+ PRUNE_MESSAGES = 7
137
+ CONTEXT_ANCHOR = 8
138
+ PHASE_CHANGE = 9
139
+ NOTIFY_PRESENTER = 10
140
+
141
+ class EntropicComputeBackend(enum.IntEnum):
142
+ """Mirrors ``entropic_compute_backend_t`` from the C header."""
143
+
144
+ CPU = 0
145
+ CUDA = 1
146
+ VULKAN = 2
147
+
148
+ class EntropicHookPoint(enum.IntEnum):
149
+ """Mirrors ``entropic_hook_point_t`` from the C header."""
150
+
151
+ PRE_GENERATE = 0
152
+ POST_GENERATE = 1
153
+ ON_STREAM_TOKEN = 2
154
+ PRE_TOOL_CALL = 3
155
+ POST_TOOL_CALL = 4
156
+ ON_LOOP_ITERATION = 5
157
+ ON_STATE_CHANGE = 6
158
+ ON_ERROR = 7
159
+ ON_DELEGATE = 8
160
+ ON_DELEGATE_COMPLETE = 9
161
+ ON_CONTEXT_ASSEMBLE = 10
162
+ ON_PRE_COMPACT = 11
163
+ ON_POST_COMPACT = 12
164
+ ON_MODEL_LOAD = 13
165
+ ON_MODEL_UNLOAD = 14
166
+ ON_PERMISSION_CHECK = 15
167
+ ON_ADAPTER_SWAP = 16
168
+ ON_VRAM_PRESSURE = 17
169
+ ON_DIRECTIVE = 18
170
+ ON_CUSTOM_DIRECTIVE = 19
171
+ ON_LOOP_START = 20
172
+ ON_LOOP_END = 21
173
+ ON_COMPLETE = 22
174
+
175
+ class EntDecision(enum.IntEnum):
176
+ """Mirrors ``ent_decision_t`` from the C header."""
177
+
178
+ ACCEPT = 0
179
+ REJECT = 1
180
+
181
+ class EntropicMcpAccessLevel(enum.IntEnum):
182
+ """Mirrors ``entropic_mcp_access_level_t`` from the C header."""
183
+
184
+ NONE = 0
185
+ READ = 1
186
+ WRITE = 2
187
+
188
+ # ── Structs ───────────────────────────────────
189
+
190
+ class EntDelegationRequest(ctypes.Structure):
191
+ """Mirrors ``ent_delegation_request_t`` from the C header."""
192
+
193
+ _fields_ = [
194
+ ("delegation_id", ctypes.c_char_p),
195
+ ("target_tier", ctypes.c_char_p),
196
+ ("task", ctypes.c_char_p),
197
+ ("depth", ctypes.c_int),
198
+ ("is_pipeline", ctypes.c_int),
199
+ ]
200
+
201
+ class EntDelegationResult(ctypes.Structure):
202
+ """Mirrors ``ent_delegation_result_t`` from the C header."""
203
+
204
+ _fields_ = [
205
+ ("delegation_id", ctypes.c_char_p),
206
+ ("target_tier", ctypes.c_char_p),
207
+ ("success", ctypes.c_int),
208
+ ("summary", ctypes.c_char_p),
209
+ ("patch", ctypes.c_char_p),
210
+ ("patch_len", ctypes.c_size_t),
211
+ ("files_touched", ctypes.POINTER(ctypes.c_char_p)),
212
+ ("files_touched_len", ctypes.c_size_t),
213
+ ]
214
+
215
+ class EntropicLogprobResult(ctypes.Structure):
216
+ """Mirrors ``entropic_logprob_result_t`` from the C header."""
217
+
218
+ _fields_ = [
219
+ ("logprobs", ctypes.POINTER(ctypes.c_float)),
220
+ ("tokens", ctypes.POINTER(ctypes.c_int32)),
221
+ ("perplexity", ctypes.c_float),
222
+ ("total_logprob", ctypes.c_float),
223
+ ("n_tokens", ctypes.c_int),
224
+ ("n_logprobs", ctypes.c_int),
225
+ ]
226
+
227
+ # ── Callback typedefs (named) ─────────────────
228
+
229
+ HOOK_CB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p), ctypes.c_void_p)
230
+ DELEGATION_START_CB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(EntDelegationRequest), ctypes.c_void_p)
231
+ DELEGATION_COMPLETE_CB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(EntDelegationResult), ctypes.c_void_p)
232
+ ATTEMPT_BOUNDARY_CB = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p)
233
+ COMPACTOR_CB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_char_p), ctypes.c_void_p)
234
+
235
+ # ── Callback typedefs (from inline params) ────
236
+
237
+ TOKEN_CB = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p)
238
+ STREAM_OBSERVER_CB = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p)
239
+ STATE_OBSERVER_CB = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p)
240
+ CRITIQUE_START_CB = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
241
+ CRITIQUE_END_CB = ctypes.CFUNCTYPE(None, ctypes.c_void_p)
242
+ QUEUE_OBSERVER_CB = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p)
243
+
244
+ # gh#22 backward-compat aliases for the CFUNCTYPE typedefs.
245
+ HOOK_CALLBACK_CB = HOOK_CB
246
+ TOKEN_STREAM_CB = TOKEN_CB
247
+
248
+ # ── Bindings ──────────────────────────────────
249
+
250
+ entropic_create = _bind("entropic_create", ctypes.c_int, ctypes.POINTER(entropic_handle_t))
251
+ entropic_configure = _bind("entropic_configure", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
252
+ entropic_configure_from_file = _bind("entropic_configure_from_file", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
253
+ entropic_configure_dir = _bind("entropic_configure_dir", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
254
+ entropic_destroy = _bind("entropic_destroy", None, entropic_handle_t)
255
+ entropic_version = _bind("entropic_version", ctypes.c_char_p)
256
+ entropic_api_version = _bind("entropic_api_version", ctypes.c_int)
257
+ entropic_alloc = _bind("entropic_alloc", ctypes.c_void_p, ctypes.c_size_t)
258
+ entropic_free = _bind("entropic_free", None, ctypes.c_void_p)
259
+ entropic_run = _bind("entropic_run", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p))
260
+ entropic_run_streaming = _bind("entropic_run_streaming", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, TOKEN_CB, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int))
261
+ entropic_run_messages = _bind("entropic_run_messages", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p))
262
+ entropic_run_messages_streaming = _bind("entropic_run_messages_streaming", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, TOKEN_CB, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int))
263
+ entropic_set_stream_observer = _bind("entropic_set_stream_observer", ctypes.c_int, entropic_handle_t, STREAM_OBSERVER_CB, ctypes.c_void_p)
264
+ entropic_set_state_observer = _bind("entropic_set_state_observer", ctypes.c_int, entropic_handle_t, STATE_OBSERVER_CB, ctypes.c_void_p)
265
+ entropic_set_critique_callbacks = _bind("entropic_set_critique_callbacks", ctypes.c_int, entropic_handle_t, CRITIQUE_START_CB, CRITIQUE_END_CB, ctypes.c_void_p)
266
+ entropic_interrupt = _bind("entropic_interrupt", ctypes.c_int, entropic_handle_t)
267
+ entropic_queue_user_message = _bind("entropic_queue_user_message", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
268
+ entropic_user_message_queue_depth = _bind("entropic_user_message_queue_depth", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_size_t))
269
+ entropic_clear_user_message_queue = _bind("entropic_clear_user_message_queue", ctypes.c_int, entropic_handle_t)
270
+ entropic_set_queue_observer = _bind("entropic_set_queue_observer", ctypes.c_int, entropic_handle_t, QUEUE_OBSERVER_CB, ctypes.c_void_p)
271
+ entropic_speculative_compat = _bind("entropic_speculative_compat", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_char_p))
272
+ entropic_context_clear = _bind("entropic_context_clear", ctypes.c_int, entropic_handle_t)
273
+ entropic_context_get = _bind("entropic_context_get", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_char_p))
274
+ entropic_context_count = _bind("entropic_context_count", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_size_t))
275
+ entropic_context_usage = _bind("entropic_context_usage", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_size_t), ctypes.POINTER(ctypes.c_size_t))
276
+ entropic_metrics_json = _bind("entropic_metrics_json", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_char_p))
277
+ entropic_set_delegation_callbacks = _bind("entropic_set_delegation_callbacks", ctypes.c_int, entropic_handle_t, DELEGATION_START_CB, DELEGATION_COMPLETE_CB, ctypes.c_void_p)
278
+ entropic_validation_set_auto_retry = _bind("entropic_validation_set_auto_retry", ctypes.c_int, entropic_handle_t, ctypes.c_int)
279
+ entropic_validation_resume_retry = _bind("entropic_validation_resume_retry", ctypes.c_int, entropic_handle_t)
280
+ entropic_validation_accept_last = _bind("entropic_validation_accept_last", ctypes.c_int, entropic_handle_t)
281
+ entropic_set_attempt_boundary_cb = _bind("entropic_set_attempt_boundary_cb", ctypes.c_int, entropic_handle_t, ATTEMPT_BOUNDARY_CB, ctypes.c_void_p)
282
+ entropic_register_mcp_server = _bind("entropic_register_mcp_server", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p)
283
+ entropic_deregister_mcp_server = _bind("entropic_deregister_mcp_server", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
284
+ entropic_list_mcp_servers = _bind("entropic_list_mcp_servers", ctypes.c_char_p, entropic_handle_t)
285
+ entropic_storage_open = _bind("entropic_storage_open", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
286
+ entropic_storage_close = _bind("entropic_storage_close", ctypes.c_int, entropic_handle_t)
287
+ entropic_load_identity = _bind("entropic_load_identity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
288
+ entropic_get_identity = _bind("entropic_get_identity", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_char_p))
289
+ entropic_register_hook = _bind("entropic_register_hook", ctypes.c_int, entropic_handle_t, ctypes.c_int, HOOK_CB, ctypes.c_void_p, ctypes.c_int)
290
+ entropic_deregister_hook = _bind("entropic_deregister_hook", ctypes.c_int, entropic_handle_t, ctypes.c_int, HOOK_CB, ctypes.c_void_p)
291
+ entropic_adapter_load = _bind("entropic_adapter_load", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_float)
292
+ entropic_adapter_unload = _bind("entropic_adapter_unload", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
293
+ entropic_adapter_swap = _bind("entropic_adapter_swap", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
294
+ entropic_adapter_state = _bind("entropic_adapter_state", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
295
+ entropic_adapter_info = _bind("entropic_adapter_info", ctypes.c_char_p, entropic_handle_t, ctypes.c_char_p)
296
+ entropic_adapter_list = _bind("entropic_adapter_list", ctypes.c_char_p, entropic_handle_t)
297
+ entropic_grammar_register = _bind("entropic_grammar_register", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p)
298
+ entropic_grammar_register_file = _bind("entropic_grammar_register_file", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p)
299
+ entropic_grammar_deregister = _bind("entropic_grammar_deregister", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
300
+ entropic_grammar_get = _bind("entropic_grammar_get", ctypes.c_char_p, entropic_handle_t, ctypes.c_char_p)
301
+ entropic_grammar_validate = _bind("entropic_grammar_validate", ctypes.c_char_p, ctypes.c_char_p)
302
+ entropic_grammar_list = _bind("entropic_grammar_list", ctypes.c_char_p, entropic_handle_t)
303
+ entropic_profile_register = _bind("entropic_profile_register", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
304
+ entropic_profile_deregister = _bind("entropic_profile_deregister", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
305
+ entropic_profile_get = _bind("entropic_profile_get", ctypes.c_char_p, entropic_handle_t, ctypes.c_char_p)
306
+ entropic_profile_list = _bind("entropic_profile_list", ctypes.c_char_p, entropic_handle_t)
307
+ entropic_throughput_tok_per_sec = _bind("entropic_throughput_tok_per_sec", ctypes.c_double, entropic_handle_t, ctypes.c_char_p)
308
+ entropic_throughput_reset = _bind("entropic_throughput_reset", None, entropic_handle_t, ctypes.c_char_p)
309
+ entropic_grant_mcp_key = _bind("entropic_grant_mcp_key", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int)
310
+ entropic_revoke_mcp_key = _bind("entropic_revoke_mcp_key", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p)
311
+ entropic_check_mcp_key = _bind("entropic_check_mcp_key", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int)
312
+ entropic_list_mcp_keys = _bind("entropic_list_mcp_keys", ctypes.c_char_p, entropic_handle_t, ctypes.c_char_p)
313
+ entropic_grant_mcp_key_from = _bind("entropic_grant_mcp_key_from", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int)
314
+ entropic_serialize_mcp_keys = _bind("entropic_serialize_mcp_keys", ctypes.c_char_p, entropic_handle_t)
315
+ entropic_deserialize_mcp_keys = _bind("entropic_deserialize_mcp_keys", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
316
+ entropic_audit_flush = _bind("entropic_audit_flush", ctypes.c_int, entropic_handle_t)
317
+ entropic_audit_count = _bind("entropic_audit_count", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_size_t))
318
+ entropic_audit_read = _bind("entropic_audit_read", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p))
319
+ entropic_create_identity = _bind("entropic_create_identity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
320
+ entropic_update_identity = _bind("entropic_update_identity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_char_p)
321
+ entropic_destroy_identity = _bind("entropic_destroy_identity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
322
+ entropic_get_identity_config = _bind("entropic_get_identity_config", ctypes.c_char_p, entropic_handle_t, ctypes.c_char_p)
323
+ entropic_list_identities = _bind("entropic_list_identities", ctypes.c_char_p, entropic_handle_t)
324
+ entropic_identity_count = _bind("entropic_identity_count", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_size_t), ctypes.POINTER(ctypes.c_size_t))
325
+ entropic_compact = _bind("entropic_compact", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.POINTER(ctypes.c_char_p))
326
+ entropic_register_compactor = _bind("entropic_register_compactor", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, COMPACTOR_CB, ctypes.c_void_p)
327
+ entropic_deregister_compactor = _bind("entropic_deregister_compactor", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
328
+ entropic_get_default_compactor = _bind("entropic_get_default_compactor", ctypes.c_int, entropic_handle_t, ctypes.POINTER(COMPACTOR_CB), ctypes.POINTER(ctypes.c_void_p))
329
+ entropic_get_logprobs = _bind("entropic_get_logprobs", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.POINTER(ctypes.c_int32), ctypes.c_int, ctypes.POINTER(EntropicLogprobResult))
330
+ entropic_compute_perplexity = _bind("entropic_compute_perplexity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.POINTER(ctypes.c_int32), ctypes.c_int, ctypes.POINTER(ctypes.c_float))
331
+ entropic_free_logprob_result = _bind("entropic_free_logprob_result", None, ctypes.POINTER(EntropicLogprobResult))
332
+ entropic_validation_set_enabled = _bind("entropic_validation_set_enabled", ctypes.c_int, entropic_handle_t, ctypes.c_bool)
333
+ entropic_validation_set_identity = _bind("entropic_validation_set_identity", ctypes.c_int, entropic_handle_t, ctypes.c_char_p, ctypes.c_bool)
334
+ entropic_validation_last_result = _bind("entropic_validation_last_result", ctypes.c_char_p, entropic_handle_t)
335
+ entropic_model_has_vision = _bind("entropic_model_has_vision", ctypes.c_int, entropic_handle_t, ctypes.c_char_p)
336
+ entropic_get_diagnostic_prompt = _bind("entropic_get_diagnostic_prompt", ctypes.c_int, entropic_handle_t, ctypes.POINTER(ctypes.c_char_p))
@@ -0,0 +1,126 @@
1
+ # SPDX-License-Identifier: LGPL-3.0-or-later
2
+ # AUTO-GENERATED by scripts/gen_bindings.py — do not edit.
3
+ """Exported names for the entropic ctypes bindings.
4
+
5
+ This file is imported eagerly by ``entropic.__init__`` to populate
6
+ the public ``_LAZY_EXPORTS`` set without loading ``librentropic.so``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ EXPORTS = frozenset(
12
+ {
13
+ "ATTEMPT_BOUNDARY_CB",
14
+ "AgentState",
15
+ "COMPACTOR_CB",
16
+ "CRITIQUE_END_CB",
17
+ "CRITIQUE_START_CB",
18
+ "DELEGATION_COMPLETE_CB",
19
+ "DELEGATION_START_CB",
20
+ "EntDecision",
21
+ "EntDelegationRequest",
22
+ "EntDelegationResult",
23
+ "EntropicComputeBackend",
24
+ "EntropicDirectiveType",
25
+ "EntropicError",
26
+ "EntropicHookPoint",
27
+ "EntropicLogprobResult",
28
+ "EntropicMcpAccessLevel",
29
+ "EntropicModelState",
30
+ "HOOK_CALLBACK_CB",
31
+ "HOOK_CB",
32
+ "QUEUE_OBSERVER_CB",
33
+ "STATE_OBSERVER_CB",
34
+ "STREAM_OBSERVER_CB",
35
+ "TOKEN_CB",
36
+ "TOKEN_STREAM_CB",
37
+ "entropic_adapter_info",
38
+ "entropic_adapter_list",
39
+ "entropic_adapter_load",
40
+ "entropic_adapter_state",
41
+ "entropic_adapter_swap",
42
+ "entropic_adapter_unload",
43
+ "entropic_alloc",
44
+ "entropic_api_version",
45
+ "entropic_audit_count",
46
+ "entropic_audit_flush",
47
+ "entropic_audit_read",
48
+ "entropic_check_mcp_key",
49
+ "entropic_clear_user_message_queue",
50
+ "entropic_compact",
51
+ "entropic_compute_perplexity",
52
+ "entropic_configure",
53
+ "entropic_configure_dir",
54
+ "entropic_configure_from_file",
55
+ "entropic_context_clear",
56
+ "entropic_context_count",
57
+ "entropic_context_get",
58
+ "entropic_context_usage",
59
+ "entropic_create",
60
+ "entropic_create_identity",
61
+ "entropic_deregister_compactor",
62
+ "entropic_deregister_hook",
63
+ "entropic_deregister_mcp_server",
64
+ "entropic_deserialize_mcp_keys",
65
+ "entropic_destroy",
66
+ "entropic_destroy_identity",
67
+ "entropic_free",
68
+ "entropic_free_logprob_result",
69
+ "entropic_get_default_compactor",
70
+ "entropic_get_diagnostic_prompt",
71
+ "entropic_get_identity",
72
+ "entropic_get_identity_config",
73
+ "entropic_get_logprobs",
74
+ "entropic_grammar_deregister",
75
+ "entropic_grammar_get",
76
+ "entropic_grammar_list",
77
+ "entropic_grammar_register",
78
+ "entropic_grammar_register_file",
79
+ "entropic_grammar_validate",
80
+ "entropic_grant_mcp_key",
81
+ "entropic_grant_mcp_key_from",
82
+ "entropic_handle_t",
83
+ "entropic_identity_count",
84
+ "entropic_interrupt",
85
+ "entropic_list_identities",
86
+ "entropic_list_mcp_keys",
87
+ "entropic_list_mcp_servers",
88
+ "entropic_load_identity",
89
+ "entropic_metrics_json",
90
+ "entropic_model_has_vision",
91
+ "entropic_profile_deregister",
92
+ "entropic_profile_get",
93
+ "entropic_profile_list",
94
+ "entropic_profile_register",
95
+ "entropic_queue_user_message",
96
+ "entropic_register_compactor",
97
+ "entropic_register_hook",
98
+ "entropic_register_mcp_server",
99
+ "entropic_revoke_mcp_key",
100
+ "entropic_run",
101
+ "entropic_run_messages",
102
+ "entropic_run_messages_streaming",
103
+ "entropic_run_streaming",
104
+ "entropic_serialize_mcp_keys",
105
+ "entropic_set_attempt_boundary_cb",
106
+ "entropic_set_critique_callbacks",
107
+ "entropic_set_delegation_callbacks",
108
+ "entropic_set_queue_observer",
109
+ "entropic_set_state_observer",
110
+ "entropic_set_stream_observer",
111
+ "entropic_speculative_compat",
112
+ "entropic_storage_close",
113
+ "entropic_storage_open",
114
+ "entropic_throughput_reset",
115
+ "entropic_throughput_tok_per_sec",
116
+ "entropic_update_identity",
117
+ "entropic_user_message_queue_depth",
118
+ "entropic_validation_accept_last",
119
+ "entropic_validation_last_result",
120
+ "entropic_validation_resume_retry",
121
+ "entropic_validation_set_auto_retry",
122
+ "entropic_validation_set_enabled",
123
+ "entropic_validation_set_identity",
124
+ "entropic_version",
125
+ }
126
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: entropic-engine
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Local-first agentic inference engine — Python wrapper over librentropic.so
5
5
  Author: Tristan VanFossen
6
6
  License-Expression: LGPL-3.0-or-later
@@ -7,6 +7,7 @@ pyproject.toml
7
7
  python/src/entropic/__init__.py
8
8
  python/src/entropic/__main__.py
9
9
  python/src/entropic/_bindings.py
10
+ python/src/entropic/_bindings_manifest.py
10
11
  python/src/entropic/_loader.py
11
12
  python/src/entropic/cli.py
12
13
  python/src/entropic/helpers.py
@@ -1 +0,0 @@
1
- 2.2.0
@@ -1,493 +0,0 @@
1
- # SPDX-License-Identifier: LGPL-3.0-or-later
2
- """ctypes bindings for librentropic.so.
3
-
4
- This module exposes the entropic C ABI as a flat collection of ctypes
5
- function objects. It is *not* an OOP wrapper — symbols match the C
6
- header verbatim (``entropic_create``, ``entropic_run_streaming``, etc.).
7
-
8
- Bindings are intentionally a hand-curated subset of the full surface
9
- declared in ``include/entropic/entropic.h``. The full surface can be
10
- regenerated via ``inv gen-bindings``; this hand-written file pins the
11
- symbols most consumers need at v2.1.0 release time and keeps the
12
- wheel small (~50 KB).
13
-
14
- For symbols not exposed here, load librentropic.so directly:
15
-
16
- from entropic._loader import load
17
- lib = load()
18
- lib.entropic_some_other_symbol.argtypes = [...]
19
- """
20
-
21
- from __future__ import annotations
22
-
23
- import ctypes
24
- import enum
25
-
26
- from entropic._loader import load
27
-
28
- _lib = load()
29
-
30
- # ── Opaque handle ────────────────────────────────────────────────────────
31
- # The C header types entropic_handle_t as `struct entropic_engine*`, an
32
- # opaque forward declaration. From Python it's just a void* — callers
33
- # pass `ctypes.byref(handle)` for out-params and `handle` for ins.
34
- entropic_handle_t = ctypes.c_void_p
35
-
36
-
37
- # ── Enums ────────────────────────────────────────────────────────────────
38
- class EntropicError(enum.IntEnum):
39
- """Mirrors ``entropic_error_t`` from include/entropic/types/error.h.
40
-
41
- Same drift hazard as :class:`AgentState`: an IntEnum that doesn't match
42
- the C ABI silently mislabels error codes (issue #1: pre-2.1.1 wrapper
43
- had 11 entries against 47 in the C header, and the entries it did have
44
- were misaligned by integer value). ``tests/unit/test_bindings_abi.py``
45
- pins these against the canonical header — do not edit one without
46
- the other.
47
- """
48
-
49
- OK = 0
50
- INVALID_ARGUMENT = 1
51
- INVALID_CONFIG = 2
52
- INVALID_STATE = 3
53
- MODEL_NOT_FOUND = 4
54
- LOAD_FAILED = 5
55
- GENERATE_FAILED = 6
56
- TOOL_NOT_FOUND = 7
57
- PERMISSION_DENIED = 8
58
- PLUGIN_VERSION_MISMATCH = 9
59
- PLUGIN_LOAD_FAILED = 10
60
- TIMEOUT = 11
61
- CANCELLED = 12
62
- OUT_OF_MEMORY = 13
63
- IO = 14
64
- INTERNAL = 15
65
- SERVER_ALREADY_EXISTS = 16
66
- SERVER_NOT_FOUND = 17
67
- CONNECTION_FAILED = 18
68
- INVALID_HANDLE = 19
69
- TOOL_EXECUTION_FAILED = 20
70
- STORAGE_FAILED = 21
71
- IDENTITY_NOT_FOUND = 22
72
- ALREADY_RUNNING = 23
73
- NOT_RUNNING = 24
74
- NOT_IMPLEMENTED = 25
75
- INTERRUPTED = 26
76
- ADAPTER_NOT_FOUND = 27
77
- ADAPTER_LOAD_FAILED = 28
78
- ADAPTER_SWAP_FAILED = 29
79
- ADAPTER_CANCELLED = 30
80
- GRAMMAR_NOT_FOUND = 31
81
- GRAMMAR_INVALID = 32
82
- MCP_KEY_DENIED = 33
83
- LIMIT_REACHED = 34
84
- ALREADY_EXISTS = 35
85
- IN_USE = 36
86
- PROFILE_NOT_FOUND = 37
87
- TIME_LIMIT_EXCEEDED = 38
88
- VALIDATION_FAILED = 39
89
- COMPACTION_FAILED = 40
90
- MODEL_NOT_ACTIVE = 41
91
- EVAL_CONTEXT_FULL = 42
92
- EVAL_FAILED = 43
93
- IMAGE_LOAD_FAILED = 44
94
- IMAGE_TOO_LARGE = 45
95
- MMPROJ_LOAD_FAILED = 46
96
- UNSUPPORTED_URL = 47
97
- NOT_SUPPORTED = 48
98
- STATE_INCOMPATIBLE = 49
99
- NO_VISION_TIER = 50 # gh#41 (v2.1.8)
100
-
101
-
102
- class AgentState(enum.IntEnum):
103
- """Mirrors ``entropic_agent_state_t`` from include/entropic/types/enums.h.
104
-
105
- Drift from the C header silently mislabels every state from 1 onward,
106
- since IntEnum maps by integer value. ``tests/unit/test_bindings_abi.py``
107
- parses the canonical header and asserts every (name, value) pair here
108
- matches; do not edit one without the other.
109
- """
110
-
111
- IDLE = 0
112
- PLANNING = 1
113
- EXECUTING = 2
114
- WAITING_TOOL = 3
115
- VERIFYING = 4
116
- DELEGATING = 5
117
- COMPLETE = 6
118
- ERROR = 7
119
- INTERRUPTED = 8
120
- PAUSED = 9
121
-
122
-
123
- class EntropicHookPoint(enum.IntEnum):
124
- """Mirrors ``entropic_hook_point_t`` from include/entropic/types/hooks.h.
125
-
126
- Issue #8 (v2.1.4). ``ENTROPIC_HOOK_COUNT_`` (the sentinel) is
127
- intentionally NOT included — it's not a valid hook point. The
128
- ABI conformance test pins every (name, value) pair against the
129
- canonical header.
130
- """
131
-
132
- PRE_GENERATE = 0
133
- POST_GENERATE = 1
134
- ON_STREAM_TOKEN = 2
135
- PRE_TOOL_CALL = 3
136
- POST_TOOL_CALL = 4
137
- ON_LOOP_ITERATION = 5
138
- ON_STATE_CHANGE = 6
139
- ON_ERROR = 7
140
- ON_DELEGATE = 8
141
- ON_DELEGATE_COMPLETE = 9
142
- ON_CONTEXT_ASSEMBLE = 10
143
- ON_PRE_COMPACT = 11
144
- ON_POST_COMPACT = 12
145
- ON_MODEL_LOAD = 13
146
- ON_MODEL_UNLOAD = 14
147
- ON_PERMISSION_CHECK = 15
148
- ON_ADAPTER_SWAP = 16
149
- ON_VRAM_PRESSURE = 17
150
- ON_DIRECTIVE = 18
151
- ON_CUSTOM_DIRECTIVE = 19
152
- ON_LOOP_START = 20
153
- ON_LOOP_END = 21
154
- ON_COMPLETE = 22
155
-
156
-
157
- # ── Callback signatures (CFUNCTYPE) ──────────────────────────────────────
158
- # Each named here has a stable address; reusing the same CFUNCTYPE across
159
- # bindings ensures function pointers we hand to C remain alive as long
160
- # as the holding Python reference does.
161
- TOKEN_CB = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p)
162
- """Stream callback: (token: bytes, len: size_t, user_data: void*) -> None."""
163
-
164
- STATE_OBSERVER_CB = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p)
165
- """State observer: (state: AgentState, user_data: void*) -> None."""
166
-
167
- # Issue #8 (v2.1.4): stream observer + hook callback signatures.
168
- STREAM_OBSERVER_CB = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p)
169
- """Stream observer: (token: bytes, len: size_t, user_data: void*) -> None.
170
-
171
- Same shape as TOKEN_CB; lives in a distinct CFUNCTYPE so streams.py can
172
- keep its observer registry independent of the per-call streaming path.
173
- """
174
-
175
- HOOK_CB = ctypes.CFUNCTYPE(
176
- ctypes.c_int, # return: int (0=ok, !=0=cancel)
177
- ctypes.c_int, # hook_point: entropic_hook_point_t
178
- ctypes.c_char_p, # context_json: const char*
179
- ctypes.POINTER(ctypes.c_char_p), # modified_json: char**
180
- ctypes.c_void_p, # user_data: void*
181
- )
182
- """Hook callback signature.
183
-
184
- Maps to ``entropic_hook_callback_t`` in include/entropic/types/hooks.h.
185
- The callback receives the hook context as JSON, may write a transformed
186
- result via ``*modified_json`` (allocate with malloc — engine free()s),
187
- and returns 0 for OK or non-zero to cancel/reject.
188
- """
189
-
190
- # gh#22 (v2.1.5): C-ABI-documentation-spelled aliases for the CFUNCTYPE
191
- # typedefs. The wrapper picked terse names internally (HOOK_CB, TOKEN_CB,
192
- # STREAM_OBSERVER_CB); the C header documents them as
193
- # entropic_hook_callback_t, entropic_token_callback_t, etc. Consumers
194
- # coming from the C ABI docs expect the spelled-out names. Keep both
195
- # spellings; old code continues to work.
196
- HOOK_CALLBACK_CB = HOOK_CB
197
- """Alias for :data:`HOOK_CB` matching the C ABI docs (gh#22)."""
198
-
199
- TOKEN_STREAM_CB = TOKEN_CB
200
- """Alias for :data:`TOKEN_CB` matching the C ABI docs (gh#22)."""
201
-
202
-
203
- ## @brief Pin restype/argtypes on a symbol from the loaded library.
204
- ## @utility
205
- ## @version 2.1.0
206
- def _bind(name: str, restype, *argtypes):
207
- """Pin restype/argtypes on a symbol from the loaded library."""
208
- fn = getattr(_lib, name)
209
- fn.restype = restype
210
- fn.argtypes = list(argtypes)
211
- return fn
212
-
213
-
214
- # ── Lifecycle ────────────────────────────────────────────────────────────
215
- entropic_create = _bind("entropic_create", ctypes.c_int, ctypes.POINTER(entropic_handle_t))
216
- entropic_destroy = _bind("entropic_destroy", None, entropic_handle_t)
217
-
218
- entropic_configure_dir = _bind(
219
- "entropic_configure_dir",
220
- ctypes.c_int,
221
- entropic_handle_t,
222
- ctypes.c_char_p,
223
- )
224
-
225
- # ── Version / API ────────────────────────────────────────────────────────
226
- entropic_api_version = _bind("entropic_api_version", ctypes.c_int)
227
- entropic_version = _bind("entropic_version", ctypes.c_char_p)
228
-
229
- # ── Inference ────────────────────────────────────────────────────────────
230
- entropic_run = _bind(
231
- "entropic_run",
232
- ctypes.c_int,
233
- entropic_handle_t,
234
- ctypes.c_char_p,
235
- ctypes.POINTER(ctypes.c_char_p),
236
- )
237
- """(handle, input, out_result_json) → entropic_error_t.
238
-
239
- The C function allocates ``*out_result_json`` via malloc; callers must
240
- free it via :data:`entropic_free`.
241
- """
242
-
243
- entropic_run_streaming = _bind(
244
- "entropic_run_streaming",
245
- ctypes.c_int,
246
- entropic_handle_t,
247
- ctypes.c_char_p,
248
- TOKEN_CB,
249
- ctypes.c_void_p,
250
- ctypes.POINTER(ctypes.c_int),
251
- )
252
-
253
- # gh#37 (v2.1.8): multimodal messages entry points. messages_json is a
254
- # JSON array (OpenAI-compatible content arrays); content_parts survive
255
- # end-to-end. See entropic_run() for the back-compat text-only path.
256
- entropic_run_messages = _bind(
257
- "entropic_run_messages",
258
- ctypes.c_int,
259
- entropic_handle_t,
260
- ctypes.c_char_p,
261
- ctypes.POINTER(ctypes.c_char_p),
262
- )
263
- """(handle, messages_json, out_result_json) → entropic_error_t.
264
-
265
- The C function allocates ``*out_result_json`` via malloc; callers must
266
- free it via :data:`entropic_free`.
267
- """
268
-
269
- entropic_run_messages_streaming = _bind(
270
- "entropic_run_messages_streaming",
271
- ctypes.c_int,
272
- entropic_handle_t,
273
- ctypes.c_char_p,
274
- TOKEN_CB,
275
- ctypes.c_void_p,
276
- ctypes.POINTER(ctypes.c_int),
277
- )
278
-
279
- entropic_interrupt = _bind("entropic_interrupt", ctypes.c_int, entropic_handle_t)
280
-
281
- entropic_free = _bind("entropic_free", None, ctypes.c_void_p)
282
-
283
- # ── Conversation context ─────────────────────────────────────────────────
284
- entropic_context_clear = _bind("entropic_context_clear", ctypes.c_int, entropic_handle_t)
285
- entropic_context_count = _bind(
286
- "entropic_context_count",
287
- ctypes.c_int,
288
- entropic_handle_t,
289
- ctypes.POINTER(ctypes.c_size_t),
290
- )
291
-
292
- # gh#39 (v2.1.8): token-level context pressure for consumer UIs
293
- # (e.g. "6727/32768 tokens (20%)" gauges). Mirrors the
294
- # `Context: N/M tokens` line emitted by core.context_manager.
295
- entropic_context_usage = _bind(
296
- "entropic_context_usage",
297
- ctypes.c_int,
298
- entropic_handle_t,
299
- ctypes.POINTER(ctypes.c_size_t),
300
- ctypes.POINTER(ctypes.c_size_t),
301
- )
302
- """(handle, out_tokens_used, out_capacity) -> entropic_error_t.
303
-
304
- Reads the active tier's current context pressure. Both outputs are
305
- ``size_t``. Returns ``ENTROPIC_ERROR_INVALID_STATE`` before any tier
306
- is locked.
307
- """
308
-
309
- # gh#22 (v2.1.5): closes the gh#8 partial gap. The C ABI exposes
310
- # entropic_context_get(handle, char** out_messages_json) — the engine
311
- # allocates *out_messages_json via malloc and the caller must free it
312
- # via entropic_free.
313
- entropic_context_get = _bind(
314
- "entropic_context_get",
315
- ctypes.c_int,
316
- entropic_handle_t,
317
- ctypes.POINTER(ctypes.c_char_p),
318
- )
319
- """(handle, out_messages_json) -> entropic_error_t.
320
-
321
- Returns the current conversation as a JSON array string in
322
- ``*out_messages_json``. Caller frees with :data:`entropic_free`.
323
- """
324
-
325
- # ── Observers ────────────────────────────────────────────────────────────
326
- entropic_set_state_observer = _bind(
327
- "entropic_set_state_observer",
328
- ctypes.c_int,
329
- entropic_handle_t,
330
- STATE_OBSERVER_CB,
331
- ctypes.c_void_p,
332
- )
333
-
334
- # Issue #8 (v2.1.4): persistent stream observer (fires for ALL streaming
335
- # output regardless of which entry point invoked the model — vs. the
336
- # per-call TOKEN_CB on entropic_run_streaming). Wired by streams.py.
337
- entropic_set_stream_observer = _bind(
338
- "entropic_set_stream_observer",
339
- ctypes.c_int,
340
- entropic_handle_t,
341
- STREAM_OBSERVER_CB,
342
- ctypes.c_void_p,
343
- )
344
-
345
-
346
- # ── Delegation callbacks (v2.1.5, gh#29) ─────────────────────────────────
347
- # Replaces the silent auto-merge-to-develop behavior. Consumers register
348
- # on_start (pre-delegation gate) and on_complete (patch delivery). The
349
- # engine NEVER applies patches; the consumer does it with user consent
350
- # (see entropic.helpers.apply_patch). See include/entropic/entropic.h for
351
- # the C ABI documentation.
352
-
353
-
354
- class EntDecision(enum.IntEnum):
355
- """Mirrors ``ent_decision_t`` from entropic.h (gh#29, v2.1.5)."""
356
-
357
- ACCEPT = 0
358
- REJECT = 1
359
-
360
-
361
- class EntDelegationRequest(ctypes.Structure):
362
- """Mirrors ``ent_delegation_request_t`` from entropic.h.
363
-
364
- All pointers are owned by the engine and valid only for the
365
- callback's duration. Copy any string the Python side needs to retain.
366
- """
367
-
368
- _fields_ = [
369
- ("delegation_id", ctypes.c_char_p),
370
- ("target_tier", ctypes.c_char_p),
371
- ("task", ctypes.c_char_p),
372
- ("depth", ctypes.c_int),
373
- ("is_pipeline", ctypes.c_int),
374
- ]
375
-
376
-
377
- class EntDelegationResult(ctypes.Structure):
378
- """Mirrors ``ent_delegation_result_t`` from entropic.h.
379
-
380
- ``files_touched`` is a NULL-terminated array of relative path
381
- strings; iterate by index up to ``files_touched_len``. The patch
382
- buffer is a unified diff suitable for ``git apply``.
383
- """
384
-
385
- _fields_ = [
386
- ("delegation_id", ctypes.c_char_p),
387
- ("target_tier", ctypes.c_char_p),
388
- ("success", ctypes.c_int),
389
- ("summary", ctypes.c_char_p),
390
- ("patch", ctypes.c_char_p),
391
- ("patch_len", ctypes.c_size_t),
392
- ("files_touched", ctypes.POINTER(ctypes.c_char_p)),
393
- ("files_touched_len", ctypes.c_size_t),
394
- ]
395
-
396
-
397
- DELEGATION_START_CB = ctypes.CFUNCTYPE(
398
- ctypes.c_int, # ent_decision_t
399
- ctypes.POINTER(EntDelegationRequest),
400
- ctypes.c_void_p,
401
- )
402
- """CFUNCTYPE for ``ent_delegation_start_cb`` (gh#29, v2.1.5)."""
403
-
404
- DELEGATION_COMPLETE_CB = ctypes.CFUNCTYPE(
405
- ctypes.c_int, # ent_decision_t
406
- ctypes.POINTER(EntDelegationResult),
407
- ctypes.c_void_p,
408
- )
409
- """CFUNCTYPE for ``ent_delegation_complete_cb`` (gh#29, v2.1.5)."""
410
-
411
- entropic_set_delegation_callbacks = _bind(
412
- "entropic_set_delegation_callbacks",
413
- ctypes.c_int,
414
- entropic_handle_t,
415
- DELEGATION_START_CB,
416
- DELEGATION_COMPLETE_CB,
417
- ctypes.c_void_p,
418
- )
419
-
420
-
421
- # ── Validation retry controls (v2.1.5, gh#30) ────────────────────────────
422
- # Lets consumers gate the constitutional revision loop instead of having
423
- # the engine race them with auto-revision. See entropic.h for the full
424
- # behavior contract.
425
-
426
- ATTEMPT_BOUNDARY_CB = ctypes.CFUNCTYPE(
427
- None, # void
428
- ctypes.c_int, # attempt_n
429
- ctypes.c_void_p,
430
- )
431
- """CFUNCTYPE for ``ent_validation_attempt_boundary_cb`` (gh#30, v2.1.5)."""
432
-
433
- entropic_validation_set_auto_retry = _bind(
434
- "entropic_validation_set_auto_retry",
435
- ctypes.c_int,
436
- entropic_handle_t,
437
- ctypes.c_int, # enabled
438
- )
439
-
440
- entropic_validation_resume_retry = _bind(
441
- "entropic_validation_resume_retry",
442
- ctypes.c_int,
443
- entropic_handle_t,
444
- )
445
-
446
- entropic_validation_accept_last = _bind(
447
- "entropic_validation_accept_last",
448
- ctypes.c_int,
449
- entropic_handle_t,
450
- )
451
-
452
- entropic_set_attempt_boundary_cb = _bind(
453
- "entropic_set_attempt_boundary_cb",
454
- ctypes.c_int,
455
- entropic_handle_t,
456
- ATTEMPT_BOUNDARY_CB,
457
- ctypes.c_void_p,
458
- )
459
-
460
-
461
- # ── Memory ───────────────────────────────────────────────────────────────
462
- # Issue #8 (v2.1.4): heap allocator that pairs with entropic_free. Hook
463
- # callbacks use this when writing modified_json (engine free()s on
464
- # consumption — a Python `bytes` reference would be freed by Python's
465
- # refcounter long before the engine reads it).
466
- entropic_alloc = _bind("entropic_alloc", ctypes.c_void_p, ctypes.c_size_t)
467
-
468
-
469
- # ── MCP server registration ──────────────────────────────────────────────
470
- # Issue #8 (v2.1.4): runtime MCP server registration (vs. config-file
471
- # discovery). Pythonic wrapper in entropic.mcp.register_server.
472
- entropic_register_mcp_server = _bind(
473
- "entropic_register_mcp_server",
474
- ctypes.c_int,
475
- entropic_handle_t,
476
- ctypes.c_char_p, # name
477
- ctypes.c_char_p, # config_json
478
- )
479
-
480
-
481
- # ── Hook registration ────────────────────────────────────────────────────
482
- # Issue #8 (v2.1.4): low-level hook registration. Pythonic @hook
483
- # decorator in entropic.hooks; that module owns the CFUNCTYPE-keepalive
484
- # registry so callbacks aren't garbage-collected mid-call.
485
- entropic_register_hook = _bind(
486
- "entropic_register_hook",
487
- ctypes.c_int,
488
- entropic_handle_t,
489
- ctypes.c_int, # hook_point
490
- HOOK_CB, # callback
491
- ctypes.c_void_p, # user_data
492
- ctypes.c_int, # priority
493
- )
File without changes
File without changes
File without changes