eden-client 0.6.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.
- eden_client-0.6.1/LICENSE +185 -0
- eden_client-0.6.1/PKG-INFO +117 -0
- eden_client-0.6.1/README.md +103 -0
- eden_client-0.6.1/eden_client/__init__.py +592 -0
- eden_client-0.6.1/eden_client/aio.py +158 -0
- eden_client-0.6.1/eden_client/claude.py +310 -0
- eden_client-0.6.1/eden_client/cursor.py +63 -0
- eden_client-0.6.1/eden_client/devincli.py +66 -0
- eden_client-0.6.1/eden_client/gemini.py +99 -0
- eden_client-0.6.1/eden_client/gptme.py +362 -0
- eden_client-0.6.1/eden_client/hermes.py +439 -0
- eden_client-0.6.1/eden_client/local.py +548 -0
- eden_client-0.6.1/eden_client/model_probe.py +184 -0
- eden_client-0.6.1/eden_client/py.typed +0 -0
- eden_client-0.6.1/eden_client/qwen.py +61 -0
- eden_client-0.6.1/eden_client/windsurf.py +134 -0
- eden_client-0.6.1/eden_client.egg-info/PKG-INFO +117 -0
- eden_client-0.6.1/eden_client.egg-info/SOURCES.txt +21 -0
- eden_client-0.6.1/eden_client.egg-info/dependency_links.txt +1 -0
- eden_client-0.6.1/eden_client.egg-info/top_level.txt +1 -0
- eden_client-0.6.1/pyproject.toml +25 -0
- eden_client-0.6.1/setup.cfg +14 -0
|
@@ -0,0 +1,185 @@
|
|
|
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 portion incorporated within it constitutes direct or contributory
|
|
85
|
+
patent infringement, then any patent licenses granted to You under
|
|
86
|
+
this License for that Work shall terminate as of the date such
|
|
87
|
+
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 this
|
|
133
|
+
License. However, nothing in this License shall exclude the rights
|
|
134
|
+
of any Contributor under the License, including the rights to
|
|
135
|
+
sublicense under the terms of this License.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides such Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (such as deliberate and grossly
|
|
155
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
156
|
+
liable to You, or accept responsibility for error, for the Work
|
|
157
|
+
distributed under the License (including under an open-source
|
|
158
|
+
license as described in Section 1 of this License).
|
|
159
|
+
|
|
160
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
161
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
162
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
163
|
+
or other liability obligations and/or rights consistent with this
|
|
164
|
+
License. However, in accepting such obligations, You may act only
|
|
165
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
166
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
167
|
+
defend, and hold each Contributor harmless for any liability
|
|
168
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
169
|
+
of your accepting any such warranty or additional liability.
|
|
170
|
+
|
|
171
|
+
END OF TERMS AND CONDITIONS
|
|
172
|
+
|
|
173
|
+
Copyright 2026 Kaiav Nihalani
|
|
174
|
+
|
|
175
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
176
|
+
you may not use this file except in compliance with the License.
|
|
177
|
+
You may obtain a copy of the License at
|
|
178
|
+
|
|
179
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
+
|
|
181
|
+
Unless required by applicable law or agreed to in writing, software
|
|
182
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
183
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
184
|
+
See the License for the specific language governing permissions and
|
|
185
|
+
limitations under the License.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eden-client
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: Python client for the Eden context partner: report agent events, collect injections, ask. Standard library only; fails open.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Keywords: agents,llm,context,eden
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Typing :: Typed
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# eden-client (Python)
|
|
16
|
+
|
|
17
|
+
The Python client for Eden: the same calls and the same fail-open contract as the TypeScript client. Standard
|
|
18
|
+
library only (`urllib`), Python 3.9+, synchronous; asyncio agents use `eden_client.aio.AsyncEden` or the async one-call `eden_client.aio.start_local_eden`
|
|
19
|
+
(the same calls as coroutines, run in a worker thread — D2013).
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from eden_client import with_context, eden_id, ASK_CONTEXT_DESCRIPTION, probe_local_model
|
|
23
|
+
from eden_client.local import start_local_eden
|
|
24
|
+
|
|
25
|
+
# Optional preflight: catches a reasoning-only or unreachable local model before the first agent turn.
|
|
26
|
+
probe = probe_local_model("http://localhost:11434/v1", "qwen3:4b-instruct")
|
|
27
|
+
if not probe["ok"]:
|
|
28
|
+
raise RuntimeError("local model preflight: " + "; ".join(probe["problems"]))
|
|
29
|
+
|
|
30
|
+
# Embedded local mode: your app owns the sidecar. Ship bin/eden-local beside it or pass another binary path.
|
|
31
|
+
started = start_local_eden("bin/eden-local", ".eden", sources_file="sources.json",
|
|
32
|
+
model_base_url="http://localhost:11434/v1", model="qwen3:4b-instruct",
|
|
33
|
+
user_id=eden_id(user.email), session_id=eden_id(chat.id),
|
|
34
|
+
client_options={"on_error": log.warning})
|
|
35
|
+
if started is None:
|
|
36
|
+
raise RuntimeError("eden-local did not start")
|
|
37
|
+
eden = started.client # call started.close() when your app exits
|
|
38
|
+
eden.observe({"kind": "session_start"}) # when the user connects: Eden starts reading
|
|
39
|
+
|
|
40
|
+
result = eden.observe({"kind": "user_message", "text": text}) # each event (waits up to 3 s on a user message)
|
|
41
|
+
messages = with_context(messages, eden.collect(result["injection"])) # before each model call
|
|
42
|
+
answer = eden.ask("What did Dana say about the renewal?") # behind your ask_context tool
|
|
43
|
+
eden.source_changed("gmail", items=[{"ref": msg_id, "title": subject, "text": body}]) # from a source's webhook
|
|
44
|
+
for d in eden.explain(): # why Eden spoke or stayed silent (no content)
|
|
45
|
+
print(d["turn"], d["decision"], d["why"])
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **Fails open (D14).** A network error, a timeout, a non-2xx or an answer of the wrong shape is "no context"
|
|
49
|
+
(`None`, `[]`, `proceed` for `check`), never an exception. With no `on_error`, each problem is printed to stderr
|
|
50
|
+
once with its fix (with `EDEN_ENV=production`, the first of each kind; D850); pass your logger, or `on_error=None`
|
|
51
|
+
to silence it. Errors carry the server's reason (`eden /v1/whoami: 401 missing or unknown API key`),
|
|
52
|
+
never the request or the key.
|
|
53
|
+
- **A hosted or separate server**: construct `EdenClient` with that server's `base_url` and key instead of the
|
|
54
|
+
`LocalEden` endpoint. Unset `base_url` and `api_key` come from `EDEN_URL` and `EDEN_API_KEY` (D856), default
|
|
55
|
+
`http://127.0.0.1:8790`. A local dev server (`EDEN_DEV=1`) takes no `api_key` at all.
|
|
56
|
+
- **One `session_id` per conversation.** Eden hands an item out once per session; an ask in the same session cites
|
|
57
|
+
it as `(shown above)` (it is in the packet already in your messages). A second script reusing a session id sees
|
|
58
|
+
that too.
|
|
59
|
+
- **What comes back:** `observe` returns `{"injection": dict or None, "pending": bool}`; `collect` and `pending` a
|
|
60
|
+
list of injections (`{"id", "text", "citations", …}`); `ask` `{"answer", "citations", …}` or None; `check`
|
|
61
|
+
`{"verdict": "proceed" or "finding", "finding": …}`; `health` `{"ok": bool, "error"?: str}`.
|
|
62
|
+
- **Ids.** `user_id`, `session_id` and `tenant_id` are 1-128 characters of `[A-Za-z0-9._:@-]`; map any other string
|
|
63
|
+
with `eden_id`, which gives exactly the TypeScript `edenId`'s id (tested), so a mixed stack finds one user's state.
|
|
64
|
+
- **Events** are the protocol's (`docs/INTEGRATION.md`): `user_message`, `agent_message`, `tool_call`
|
|
65
|
+
(`tool`, `input`), `tool_result` (`tool`, `output`), `external`, `session_end`. Report every one.
|
|
66
|
+
- Register Eden's ask tool with `ASK_CONTEXT_DESCRIPTION` (docs/INTEGRATION.md, "Keep `ask_context`").
|
|
67
|
+
|
|
68
|
+
Tests: `bun run test:pkg client-python` (the unit tests, an end-to-end run against the real HTTP handler, and id
|
|
69
|
+
parity with TypeScript), or `python3 -m unittest -v test_eden_client` from this directory.
|
|
70
|
+
|
|
71
|
+
Install from a checkout with `pip install ./packages/client-python` (or copy the whole `eden_client` directory), or from a local release archive with `pip install ./sdk/python/eden-client`. Registry publishing is the
|
|
72
|
+
release owner's deliberate act (docs/RELEASE.md).
|
|
73
|
+
|
|
74
|
+
### Local process ownership
|
|
75
|
+
|
|
76
|
+
`eden_client.local.start_local_eden(binary, data_dir, user_id=..., session_id=...)` supervises a local-protocol
|
|
77
|
+
binary and returns a `StartedLocalEden` with `.client`, `.local` and `.close()`, or `None` fail-open. The lower-level
|
|
78
|
+
`LocalEden.endpoint()` remains `(base_url, token, generation)` or `None` for owners that manage clients themselves;
|
|
79
|
+
discard cached clients when the generation changes. The owner must register `close()` with `atexit` and any plugin
|
|
80
|
+
unload callback; closing stdin ends the child's lifetime.
|
|
81
|
+
|
|
82
|
+
Child configuration starts with only runtime/path/locale variables, plus connector credentials named by exact
|
|
83
|
+
`{"env": "NAME"}` objects in `user_sources_file`. Runtime variables, proxy variables, `EDEN_`, `LD_`, `DYLD_`,
|
|
84
|
+
`PYTHON`, `BUN_`, `NODE_` prefixes and `OPENROUTER_API_KEY` cannot be imported as connector credentials.
|
|
85
|
+
Local token, loopback host, ephemeral port, data directory and supplied sources paths are applied last. Invalid or
|
|
86
|
+
unreadable sources files forward no credentials. Other ambient secrets and Eden configuration are never inherited.
|
|
87
|
+
Startup is bounded to 10 seconds, crashes back off from 1 to 60 seconds, and optional stderr logs rotate at 1 MiB
|
|
88
|
+
with one backup. `close()` is idempotent; it waits up to two seconds each before terminate and kill escalation.
|
|
89
|
+
|
|
90
|
+
### Hermes plugin
|
|
91
|
+
|
|
92
|
+
Copy `examples/hermes/eden` into `<Hermes home>/plugins/eden`, enable `plugins: enabled: [eden]`, and select toolset
|
|
93
|
+
`eden`. Install this Python package into Hermes' environment, or copy the entire `eden_client` directory into the
|
|
94
|
+
plugin directory (the wrapper prefers this vendored copy). No model call is needed to discover/register the plugin.
|
|
95
|
+
|
|
96
|
+
- **Hosted:** set a non-empty `EDEN_URL` and required `EDEN_USER_ID`; `EDEN_API_KEY` and `EDEN_TENANT_ID` retain
|
|
97
|
+
their usual client meaning.
|
|
98
|
+
- **Local (no `EDEN_URL`):** user defaults to `local`, or `eden_id(EDEN_USER_ID)`; tenant is always `local`.
|
|
99
|
+
Ambient `EDEN_API_KEY` and `EDEN_TENANT_ID` are ignored with a warning. Supply a local-protocol binary:
|
|
100
|
+
`EDEN_LOCAL_BINARY` (existing file), else wrapper-local `bin/eden-local` (`.exe` on Windows), else
|
|
101
|
+
`<Hermes home>/plugins/eden/bin/eden-local`. Nothing is downloaded or looked up on PATH. A missing binary
|
|
102
|
+
disables registration. Child data is `<home>/eden/data`, stderr log `<home>/eden/logs/eden-local.log`.
|
|
103
|
+
- Source paths `EDEN_SOURCES_FILE` and `EDEN_USER_SOURCES_FILE` become absolute. With neither set, an existing
|
|
104
|
+
`<home>/eden/sources.json` is used as the per-user source file (`{"users":{"local/local":[...]}}` for the default
|
|
105
|
+
identity). Hermes configuration is never read for sources or credentials.
|
|
106
|
+
- Registration refuses active homes different from the routing/process launch home, in either mode: environment
|
|
107
|
+
variables belong to the launch profile. Every hook/tool also checks its registered home before touching Eden.
|
|
108
|
+
Without Hermes' home helpers, `$HERMES_HOME` or the platform default supplies a standalone home (`~/.hermes`,
|
|
109
|
+
Windows `%LOCALAPPDATA%/hermes` with fallback `~/AppData/Local/hermes`).
|
|
110
|
+
- Registration is lazy: one supervisor per plugin instance, no child until the first Eden call. Sessions keep
|
|
111
|
+
generation-aware clients; a restarted child drops stale clients. `end_session` never starts a child.
|
|
112
|
+
Both process exit (`atexit`) and Hermes `ctx.on_unload` close it; rediscovery creates a fresh lazy owner.
|
|
113
|
+
|
|
114
|
+
Configured local request budget: startup ≤10 s; `pre_llm_call` adds 3.8 s observe + 0.8 s pending (14.6 s total),
|
|
115
|
+
`pre_tool_call` adds 0.8 s (10.8 s total), and `ask_context` adds 8 s (18 s total). These are below Hermes v0.21.5's
|
|
116
|
+
30 s hook cap, whose `pre_tool_call` timeout can fail closed. As documented on the client's transport, urllib's
|
|
117
|
+
socket timeout is not an absolute deadline for trickled HTTP status/headers; the local binary is trusted.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# eden-client (Python)
|
|
2
|
+
|
|
3
|
+
The Python client for Eden: the same calls and the same fail-open contract as the TypeScript client. Standard
|
|
4
|
+
library only (`urllib`), Python 3.9+, synchronous; asyncio agents use `eden_client.aio.AsyncEden` or the async one-call `eden_client.aio.start_local_eden`
|
|
5
|
+
(the same calls as coroutines, run in a worker thread — D2013).
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from eden_client import with_context, eden_id, ASK_CONTEXT_DESCRIPTION, probe_local_model
|
|
9
|
+
from eden_client.local import start_local_eden
|
|
10
|
+
|
|
11
|
+
# Optional preflight: catches a reasoning-only or unreachable local model before the first agent turn.
|
|
12
|
+
probe = probe_local_model("http://localhost:11434/v1", "qwen3:4b-instruct")
|
|
13
|
+
if not probe["ok"]:
|
|
14
|
+
raise RuntimeError("local model preflight: " + "; ".join(probe["problems"]))
|
|
15
|
+
|
|
16
|
+
# Embedded local mode: your app owns the sidecar. Ship bin/eden-local beside it or pass another binary path.
|
|
17
|
+
started = start_local_eden("bin/eden-local", ".eden", sources_file="sources.json",
|
|
18
|
+
model_base_url="http://localhost:11434/v1", model="qwen3:4b-instruct",
|
|
19
|
+
user_id=eden_id(user.email), session_id=eden_id(chat.id),
|
|
20
|
+
client_options={"on_error": log.warning})
|
|
21
|
+
if started is None:
|
|
22
|
+
raise RuntimeError("eden-local did not start")
|
|
23
|
+
eden = started.client # call started.close() when your app exits
|
|
24
|
+
eden.observe({"kind": "session_start"}) # when the user connects: Eden starts reading
|
|
25
|
+
|
|
26
|
+
result = eden.observe({"kind": "user_message", "text": text}) # each event (waits up to 3 s on a user message)
|
|
27
|
+
messages = with_context(messages, eden.collect(result["injection"])) # before each model call
|
|
28
|
+
answer = eden.ask("What did Dana say about the renewal?") # behind your ask_context tool
|
|
29
|
+
eden.source_changed("gmail", items=[{"ref": msg_id, "title": subject, "text": body}]) # from a source's webhook
|
|
30
|
+
for d in eden.explain(): # why Eden spoke or stayed silent (no content)
|
|
31
|
+
print(d["turn"], d["decision"], d["why"])
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- **Fails open (D14).** A network error, a timeout, a non-2xx or an answer of the wrong shape is "no context"
|
|
35
|
+
(`None`, `[]`, `proceed` for `check`), never an exception. With no `on_error`, each problem is printed to stderr
|
|
36
|
+
once with its fix (with `EDEN_ENV=production`, the first of each kind; D850); pass your logger, or `on_error=None`
|
|
37
|
+
to silence it. Errors carry the server's reason (`eden /v1/whoami: 401 missing or unknown API key`),
|
|
38
|
+
never the request or the key.
|
|
39
|
+
- **A hosted or separate server**: construct `EdenClient` with that server's `base_url` and key instead of the
|
|
40
|
+
`LocalEden` endpoint. Unset `base_url` and `api_key` come from `EDEN_URL` and `EDEN_API_KEY` (D856), default
|
|
41
|
+
`http://127.0.0.1:8790`. A local dev server (`EDEN_DEV=1`) takes no `api_key` at all.
|
|
42
|
+
- **One `session_id` per conversation.** Eden hands an item out once per session; an ask in the same session cites
|
|
43
|
+
it as `(shown above)` (it is in the packet already in your messages). A second script reusing a session id sees
|
|
44
|
+
that too.
|
|
45
|
+
- **What comes back:** `observe` returns `{"injection": dict or None, "pending": bool}`; `collect` and `pending` a
|
|
46
|
+
list of injections (`{"id", "text", "citations", …}`); `ask` `{"answer", "citations", …}` or None; `check`
|
|
47
|
+
`{"verdict": "proceed" or "finding", "finding": …}`; `health` `{"ok": bool, "error"?: str}`.
|
|
48
|
+
- **Ids.** `user_id`, `session_id` and `tenant_id` are 1-128 characters of `[A-Za-z0-9._:@-]`; map any other string
|
|
49
|
+
with `eden_id`, which gives exactly the TypeScript `edenId`'s id (tested), so a mixed stack finds one user's state.
|
|
50
|
+
- **Events** are the protocol's (`docs/INTEGRATION.md`): `user_message`, `agent_message`, `tool_call`
|
|
51
|
+
(`tool`, `input`), `tool_result` (`tool`, `output`), `external`, `session_end`. Report every one.
|
|
52
|
+
- Register Eden's ask tool with `ASK_CONTEXT_DESCRIPTION` (docs/INTEGRATION.md, "Keep `ask_context`").
|
|
53
|
+
|
|
54
|
+
Tests: `bun run test:pkg client-python` (the unit tests, an end-to-end run against the real HTTP handler, and id
|
|
55
|
+
parity with TypeScript), or `python3 -m unittest -v test_eden_client` from this directory.
|
|
56
|
+
|
|
57
|
+
Install from a checkout with `pip install ./packages/client-python` (or copy the whole `eden_client` directory), or from a local release archive with `pip install ./sdk/python/eden-client`. Registry publishing is the
|
|
58
|
+
release owner's deliberate act (docs/RELEASE.md).
|
|
59
|
+
|
|
60
|
+
### Local process ownership
|
|
61
|
+
|
|
62
|
+
`eden_client.local.start_local_eden(binary, data_dir, user_id=..., session_id=...)` supervises a local-protocol
|
|
63
|
+
binary and returns a `StartedLocalEden` with `.client`, `.local` and `.close()`, or `None` fail-open. The lower-level
|
|
64
|
+
`LocalEden.endpoint()` remains `(base_url, token, generation)` or `None` for owners that manage clients themselves;
|
|
65
|
+
discard cached clients when the generation changes. The owner must register `close()` with `atexit` and any plugin
|
|
66
|
+
unload callback; closing stdin ends the child's lifetime.
|
|
67
|
+
|
|
68
|
+
Child configuration starts with only runtime/path/locale variables, plus connector credentials named by exact
|
|
69
|
+
`{"env": "NAME"}` objects in `user_sources_file`. Runtime variables, proxy variables, `EDEN_`, `LD_`, `DYLD_`,
|
|
70
|
+
`PYTHON`, `BUN_`, `NODE_` prefixes and `OPENROUTER_API_KEY` cannot be imported as connector credentials.
|
|
71
|
+
Local token, loopback host, ephemeral port, data directory and supplied sources paths are applied last. Invalid or
|
|
72
|
+
unreadable sources files forward no credentials. Other ambient secrets and Eden configuration are never inherited.
|
|
73
|
+
Startup is bounded to 10 seconds, crashes back off from 1 to 60 seconds, and optional stderr logs rotate at 1 MiB
|
|
74
|
+
with one backup. `close()` is idempotent; it waits up to two seconds each before terminate and kill escalation.
|
|
75
|
+
|
|
76
|
+
### Hermes plugin
|
|
77
|
+
|
|
78
|
+
Copy `examples/hermes/eden` into `<Hermes home>/plugins/eden`, enable `plugins: enabled: [eden]`, and select toolset
|
|
79
|
+
`eden`. Install this Python package into Hermes' environment, or copy the entire `eden_client` directory into the
|
|
80
|
+
plugin directory (the wrapper prefers this vendored copy). No model call is needed to discover/register the plugin.
|
|
81
|
+
|
|
82
|
+
- **Hosted:** set a non-empty `EDEN_URL` and required `EDEN_USER_ID`; `EDEN_API_KEY` and `EDEN_TENANT_ID` retain
|
|
83
|
+
their usual client meaning.
|
|
84
|
+
- **Local (no `EDEN_URL`):** user defaults to `local`, or `eden_id(EDEN_USER_ID)`; tenant is always `local`.
|
|
85
|
+
Ambient `EDEN_API_KEY` and `EDEN_TENANT_ID` are ignored with a warning. Supply a local-protocol binary:
|
|
86
|
+
`EDEN_LOCAL_BINARY` (existing file), else wrapper-local `bin/eden-local` (`.exe` on Windows), else
|
|
87
|
+
`<Hermes home>/plugins/eden/bin/eden-local`. Nothing is downloaded or looked up on PATH. A missing binary
|
|
88
|
+
disables registration. Child data is `<home>/eden/data`, stderr log `<home>/eden/logs/eden-local.log`.
|
|
89
|
+
- Source paths `EDEN_SOURCES_FILE` and `EDEN_USER_SOURCES_FILE` become absolute. With neither set, an existing
|
|
90
|
+
`<home>/eden/sources.json` is used as the per-user source file (`{"users":{"local/local":[...]}}` for the default
|
|
91
|
+
identity). Hermes configuration is never read for sources or credentials.
|
|
92
|
+
- Registration refuses active homes different from the routing/process launch home, in either mode: environment
|
|
93
|
+
variables belong to the launch profile. Every hook/tool also checks its registered home before touching Eden.
|
|
94
|
+
Without Hermes' home helpers, `$HERMES_HOME` or the platform default supplies a standalone home (`~/.hermes`,
|
|
95
|
+
Windows `%LOCALAPPDATA%/hermes` with fallback `~/AppData/Local/hermes`).
|
|
96
|
+
- Registration is lazy: one supervisor per plugin instance, no child until the first Eden call. Sessions keep
|
|
97
|
+
generation-aware clients; a restarted child drops stale clients. `end_session` never starts a child.
|
|
98
|
+
Both process exit (`atexit`) and Hermes `ctx.on_unload` close it; rediscovery creates a fresh lazy owner.
|
|
99
|
+
|
|
100
|
+
Configured local request budget: startup ≤10 s; `pre_llm_call` adds 3.8 s observe + 0.8 s pending (14.6 s total),
|
|
101
|
+
`pre_tool_call` adds 0.8 s (10.8 s total), and `ask_context` adds 8 s (18 s total). These are below Hermes v0.21.5's
|
|
102
|
+
30 s hook cap, whose `pre_tool_call` timeout can fail closed. As documented on the client's transport, urllib's
|
|
103
|
+
socket timeout is not an absolute deadline for trickled HTTP status/headers; the local binary is trusted.
|