elan-cli 0.1.6__tar.gz → 0.1.8__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.
- {elan_cli-0.1.6 → elan_cli-0.1.8}/CHANGELOG.md +26 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/PKG-INFO +2 -2
- {elan_cli-0.1.6 → elan_cli-0.1.8}/pyproject.toml +2 -2
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/adk.py +51 -2
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/deploy.py +26 -10
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/invoke.py +39 -3
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/main.py +19 -3
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/manifests.py +103 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/project.py +10 -1
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/scaffold.py +27 -2
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/validate.py +11 -3
- {elan_cli-0.1.6 → elan_cli-0.1.8}/.gitignore +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/LICENSE +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/README.md +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/__init__.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/auth.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/child.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/client.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/config.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/destroy.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/doctor.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/env.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/files.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/logs.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/projects.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/prompt.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/rollback.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/scan.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/secret.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/stream.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/tenant.py +0 -0
- {elan_cli-0.1.6 → elan_cli-0.1.8}/src/elan_cli/wallet.py +0 -0
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
Versions follow the tag that published them — `cli/v*`. A version with no date
|
|
4
4
|
has not been published yet.
|
|
5
5
|
|
|
6
|
+
## 0.1.8 — 2026-11-19
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `elan new mcp <slug>` scaffolds an MCP server in `mcp_servers/<module>/server.py`, writes `mcp_servers/pyproject.toml` the first time, and declares the server in elan.yaml with `expose: project` and no database (ADR-0250).
|
|
11
|
+
- `elan init` creates `mcp_servers/` beside `agents/` and `workflows/`.
|
|
12
|
+
- `elan validate` checks MCP servers. Each `MANIFEST` is read from `mcp_servers/<module>/server.py` without running the server, because its dependencies cannot share the agents' environment, and joined with the agents' before the same cross-check the deploy runs. A `MANIFEST` must be written out — a dict, or `McpServerManifest(...)` with plain-value arguments — for this command to read it; one computed at import time is refused here, and still accepted by the build.
|
|
13
|
+
- `elan deploy` and `elan status` show the MCP servers' image beside the agents': an MCP server that moved onto its new image is marked `<- new`, and each image's scan is printed and named.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- `elan new mcp` prints what a server needs next — its dependency file, its own `egress:` — instead of the agent's hints.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- `elan validate` no longer refuses every MCP server as "no such agent or workflow".
|
|
22
|
+
|
|
23
|
+
## 0.1.7 — 2026-11-18
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- `elan invoke --security-context FILE` (or `-` for stdin): credentials the
|
|
27
|
+
agent may act with for the run (ADR-0249). Read from a file, never argv, and
|
|
28
|
+
never printed — only the credential names are.
|
|
29
|
+
- `elan adk web|run … --security-context FILE`: the same, for a local run.
|
|
30
|
+
Validated before ADK starts and handed to it by path.
|
|
31
|
+
|
|
6
32
|
## 0.1.6 — 2026-11-15
|
|
7
33
|
|
|
8
34
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: elan-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: The command line a developer deploys an agent with
|
|
5
5
|
Project-URL: Homepage, https://openelan.ai
|
|
6
6
|
Project-URL: Documentation, https://openelan.ai/app/docs
|
|
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
16
16
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
17
|
Requires-Python: >=3.12
|
|
18
18
|
Requires-Dist: certifi>=2024.2.2
|
|
19
|
-
Requires-Dist: elan-agentkit-contracts>=0.
|
|
19
|
+
Requires-Dist: elan-agentkit-contracts>=0.3.0
|
|
20
20
|
Requires-Dist: elan-sdk
|
|
21
21
|
Requires-Dist: httpx>=0.27
|
|
22
22
|
Requires-Dist: keyring>=25.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "elan-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "The command line a developer deploys an agent with"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -29,7 +29,7 @@ dependencies = [
|
|
|
29
29
|
# so `uv tool install elan-cli` no longer pulls a token verifier, a
|
|
30
30
|
# database layer and a Pub/Sub broker onto a developer's laptop to read one
|
|
31
31
|
# YAML file.
|
|
32
|
-
"elan-agentkit-contracts>=0.
|
|
32
|
+
"elan-agentkit-contracts>=0.3.0",
|
|
33
33
|
# THE SHARED CLIENT CODE, ONE WAY (ADR-0104). `text_of` and the certifi
|
|
34
34
|
# context live there now; this re-exports them. The dependency runs
|
|
35
35
|
# elan-cli -> elan-sdk and never back: the SDK must not import `elan_cli`,
|
|
@@ -136,8 +136,48 @@ def argv_for(args: list[str], root: Path, slugs: list[str]) -> list[str]:
|
|
|
136
136
|
return list(args)
|
|
137
137
|
|
|
138
138
|
|
|
139
|
+
#: The one flag `elan adk` takes for itself; everything else is ADK's.
|
|
140
|
+
SECURITY_CONTEXT_FLAG = "--security-context"
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def take_security_context(args: list[str]) -> tuple[str | None, list[str]]:
|
|
144
|
+
"""Split `--security-context FILE` (or `=FILE`) out of ADK's arguments.
|
|
145
|
+
|
|
146
|
+
OURS AND NOT ADK'S, so it is removed before ADK sees the command line —
|
|
147
|
+
ADK would refuse an option it does not know, naming a flag the developer
|
|
148
|
+
typed correctly.
|
|
149
|
+
"""
|
|
150
|
+
rest: list[str] = []
|
|
151
|
+
path: str | None = None
|
|
152
|
+
items = iter(args)
|
|
153
|
+
for item in items:
|
|
154
|
+
if item == SECURITY_CONTEXT_FLAG:
|
|
155
|
+
path = next(items, None)
|
|
156
|
+
if path is None:
|
|
157
|
+
raise ValueError(f"{SECURITY_CONTEXT_FLAG} needs a file")
|
|
158
|
+
elif item.startswith(SECURITY_CONTEXT_FLAG + "="):
|
|
159
|
+
path = item.split("=", 1)[1]
|
|
160
|
+
else:
|
|
161
|
+
rest.append(item)
|
|
162
|
+
return path, rest
|
|
163
|
+
|
|
164
|
+
|
|
139
165
|
def run(args: list[str], start: Path | None = None,
|
|
140
166
|
python: str | None = None) -> int:
|
|
167
|
+
# THE CREDENTIALS A LOCAL RUN ACTS WITH (ADR-0249), validated here so a bad
|
|
168
|
+
# file is refused naming the field before ADK starts — then handed to the
|
|
169
|
+
# child by PATH, never by value, so they are in no process listing.
|
|
170
|
+
try:
|
|
171
|
+
context_file, args = take_security_context(args)
|
|
172
|
+
if context_file is not None:
|
|
173
|
+
from elan_cli.invoke import load_security_context # noqa: PLC0415
|
|
174
|
+
|
|
175
|
+
load_security_context(context_file)
|
|
176
|
+
context_file = str(Path(context_file).resolve())
|
|
177
|
+
except (OSError, ValueError) as exc:
|
|
178
|
+
print(f"error: {SECURITY_CONTEXT_FLAG}: {exc}")
|
|
179
|
+
return 2
|
|
180
|
+
|
|
141
181
|
if not args:
|
|
142
182
|
print("error: `elan adk` passes its arguments to ADK's own CLI.\n\n"
|
|
143
183
|
" elan adk web the dev UI, every target in this repo\n"
|
|
@@ -183,10 +223,12 @@ def run(args: list[str], start: Path | None = None,
|
|
|
183
223
|
print(flush=True)
|
|
184
224
|
# SUPERVISED RATHER THAN `subprocess.run`, because `adk web` is the one
|
|
185
225
|
# child here with a graceful shutdown worth protecting — see `child.py`.
|
|
186
|
-
|
|
226
|
+
if context_file is not None:
|
|
227
|
+
print(f"credentials from {context_file} (local only)")
|
|
228
|
+
return supervise(argv, cwd=project.root, env=_environment(context_file))
|
|
187
229
|
|
|
188
230
|
|
|
189
|
-
def _environment() -> dict[str, str]:
|
|
231
|
+
def _environment(context_file: str | None = None) -> dict[str, str]:
|
|
190
232
|
"""ADK's own environment, plus the one thing it must not inherit.
|
|
191
233
|
|
|
192
234
|
`TARGET_SLUG` NAMES WHICH AGENT A POD RUNS, and a developer who has it set
|
|
@@ -194,6 +236,13 @@ def _environment() -> dict[str, str]:
|
|
|
194
236
|
one target for every shim, because `Settings` reads it. The shim passes
|
|
195
237
|
its slug explicitly; removing this makes sure nothing overrides it.
|
|
196
238
|
"""
|
|
239
|
+
from elan_agentkit_contracts.security_context import LOCAL_CONTEXT_ENV # noqa: PLC0415
|
|
240
|
+
|
|
197
241
|
env = dict(os.environ)
|
|
198
242
|
env.pop("TARGET_SLUG", None)
|
|
243
|
+
# AN INHERITED ONE IS DROPPED TOO, so a run started without the flag acts
|
|
244
|
+
# with no credentials rather than with whatever a previous shell exported.
|
|
245
|
+
env.pop(LOCAL_CONTEXT_ENV, None)
|
|
246
|
+
if context_file:
|
|
247
|
+
env[LOCAL_CONTEXT_ENV] = context_file
|
|
199
248
|
return env
|
|
@@ -219,7 +219,8 @@ def report(status: dict, *, after_deploy: bool = False) -> int:
|
|
|
219
219
|
print()
|
|
220
220
|
# A SCAN REFUSAL NAMES ITS FIXES ABOVE; the whole report is a link
|
|
221
221
|
# away, for whatever else the image carries.
|
|
222
|
-
if
|
|
222
|
+
if ((status.get("scan") or status.get("mcp_scan"))
|
|
223
|
+
and (link := (status.get("links") or {}).get("scan"))):
|
|
223
224
|
print(f" full scan report: {link}")
|
|
224
225
|
return 1
|
|
225
226
|
|
|
@@ -238,8 +239,16 @@ def report(status: dict, *, after_deploy: bool = False) -> int:
|
|
|
238
239
|
# they could use; the table below shows which targets moved to the new
|
|
239
240
|
# digest, which is the part that answers a question.
|
|
240
241
|
digest = status.get("digest") or ""
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
# TWO IMAGES WHEN THE REPO HAS MCP SERVERS (ADR-0250): the agents' and the
|
|
243
|
+
# servers'. Each target moved if it landed on EITHER, and each image has its
|
|
244
|
+
# own verdict — so both are shown, each named, with one link to the report.
|
|
245
|
+
mcp_digest = status.get("mcp_digest") or ""
|
|
246
|
+
_rollout(status.get("rollout") or {}, {d for d in (digest, mcp_digest) if d})
|
|
247
|
+
link = (status.get("links") or {}).get("scan", "")
|
|
248
|
+
mcp_scan = status.get("mcp_scan") or {}
|
|
249
|
+
_scan(status.get("scan") or {}, "" if mcp_scan else link,
|
|
250
|
+
image="agents' image" if mcp_scan else "")
|
|
251
|
+
_scan(mcp_scan, link, image="MCP servers' image")
|
|
243
252
|
if after_deploy and state == "succeeded":
|
|
244
253
|
_next_steps(status.get("links") or {})
|
|
245
254
|
return 0
|
|
@@ -274,19 +283,23 @@ def _next_steps(links: dict) -> None:
|
|
|
274
283
|
print(f" {label:<{width}} {link}")
|
|
275
284
|
|
|
276
285
|
|
|
277
|
-
def _rollout(rollout: dict,
|
|
286
|
+
def _rollout(rollout: dict, built: set[str]) -> None:
|
|
278
287
|
"""Which targets moved, and which kept what they were running.
|
|
279
288
|
|
|
280
289
|
THE SECOND COLUMN IS THE POINT. Every target in the project is listed,
|
|
281
290
|
including the ones that did not move — because "what is my agent running"
|
|
282
291
|
is the question, and a list of only the changed ones cannot answer it.
|
|
292
|
+
|
|
293
|
+
`built` IS EVERY IMAGE THIS DEPLOY BUILT, not only the agents'. Compared
|
|
294
|
+
against the agents' digest alone, an MCP server on its own new image read
|
|
295
|
+
as unchanged on every deploy that moved it.
|
|
283
296
|
"""
|
|
284
297
|
if not rollout:
|
|
285
298
|
return
|
|
286
299
|
print(" target digest")
|
|
287
300
|
for slug, target_digest in sorted(rollout.items()):
|
|
288
301
|
shown = str(target_digest).rsplit("@", 1)[-1][:19] or "-"
|
|
289
|
-
moved = " <- new" if
|
|
302
|
+
moved = " <- new" if target_digest in built else ""
|
|
290
303
|
print(f" {slug:<26} {shown}{moved}")
|
|
291
304
|
|
|
292
305
|
|
|
@@ -299,7 +312,7 @@ SEVERITIES = {"CRITICAL": "critical", "HIGH": "high", "MEDIUM": "medium",
|
|
|
299
312
|
SHOWN = 10
|
|
300
313
|
|
|
301
314
|
|
|
302
|
-
def _scan(scan: dict,
|
|
315
|
+
def _scan(scan: dict, link: str, *, image: str = "") -> None:
|
|
303
316
|
"""A SUMMARY, THE CRITICAL FINDINGS, AND A LINK — never the whole list.
|
|
304
317
|
|
|
305
318
|
A real image carries hundreds of findings, nearly all of them unfixable
|
|
@@ -313,13 +326,16 @@ def _scan(scan: dict, links: dict) -> None:
|
|
|
313
326
|
cannot tell a clean image from one nobody looked at. This read `skipped`
|
|
314
327
|
and `reason`, which the API never sent — it sends `completed: false` and
|
|
315
328
|
`incomplete_reason` — so an unscanned image printed nothing at all.
|
|
329
|
+
|
|
330
|
+
`image` NAMES WHICH ONE when a deploy built two; empty, the lines read as
|
|
331
|
+
they always have.
|
|
316
332
|
"""
|
|
317
333
|
if not scan:
|
|
318
334
|
return
|
|
319
|
-
|
|
335
|
+
of = f" ({image})" if image else ""
|
|
320
336
|
if not scan.get("completed"):
|
|
321
337
|
reason = scan.get("incomplete_reason") or "no reason recorded"
|
|
322
|
-
print(f"\n not scanned: {reason}")
|
|
338
|
+
print(f"\n not scanned{of}: {reason}")
|
|
323
339
|
print(" this image was deployed without a vulnerability check, "
|
|
324
340
|
"which is not the same as clean")
|
|
325
341
|
if link:
|
|
@@ -328,12 +344,12 @@ def _scan(scan: dict, links: dict) -> None:
|
|
|
328
344
|
|
|
329
345
|
findings = scan.get("findings") or []
|
|
330
346
|
if not findings:
|
|
331
|
-
print("\n scan: nothing found")
|
|
347
|
+
print(f"\n scan{of}: nothing found")
|
|
332
348
|
else:
|
|
333
349
|
counts = scan.get("counts") or {}
|
|
334
350
|
tally = ", ".join(f"{counts[name]} {label}"
|
|
335
351
|
for name, label in SEVERITIES.items() if counts.get(name))
|
|
336
|
-
print(f"\n scan: {len(findings)} findings — {tally}")
|
|
352
|
+
print(f"\n scan{of}: {len(findings)} findings — {tally}")
|
|
337
353
|
# FIXABLE FIRST: those are the ones somebody can act on today.
|
|
338
354
|
critical = sorted((f for f in findings if f.get("severity") == "CRITICAL"),
|
|
339
355
|
key=lambda f: not f.get("fixable"))
|
|
@@ -23,9 +23,11 @@ minutes reads as a failure.
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
+
import json
|
|
26
27
|
import sys
|
|
27
28
|
import time
|
|
28
29
|
import uuid
|
|
30
|
+
from typing import Any
|
|
29
31
|
|
|
30
32
|
from elan_cli.client import Api, ApiError
|
|
31
33
|
from elan_cli.stream import (
|
|
@@ -58,9 +60,36 @@ ANSWERED_BY = {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
|
|
63
|
+
def load_security_context(path: str, *, stdin=None) -> dict[str, Any]:
|
|
64
|
+
"""A security context from a JSON file, or `-` for stdin (ADR-0249).
|
|
65
|
+
|
|
66
|
+
A FILE AND NEVER AN ARGUMENT, because argv lands in shell history, in `ps`
|
|
67
|
+
for every user on the machine, and in CI logs — and these are another
|
|
68
|
+
service's credentials for somebody. Validated here so a refusal names the
|
|
69
|
+
field before anything is sent; the value is returned revealed only because
|
|
70
|
+
the request body is the one place it has to be.
|
|
71
|
+
"""
|
|
72
|
+
from elan_agentkit_contracts.security_context import ( # noqa: PLC0415
|
|
73
|
+
parse_security_context,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if path == "-":
|
|
77
|
+
raw = (stdin or sys.stdin).read()
|
|
78
|
+
else:
|
|
79
|
+
with open(path, encoding="utf-8") as handle:
|
|
80
|
+
raw = handle.read()
|
|
81
|
+
try:
|
|
82
|
+
data = json.loads(raw)
|
|
83
|
+
except json.JSONDecodeError as exc:
|
|
84
|
+
# NOT `exc.doc`, which is the file — and the file is credentials.
|
|
85
|
+
raise ValueError(f"{path}: not JSON (line {exc.lineno}, column {exc.colno})") from None
|
|
86
|
+
return parse_security_context(data).to_wire()
|
|
87
|
+
|
|
88
|
+
|
|
61
89
|
def run(api: Api, target: str, text: str, *, session: str = "",
|
|
62
90
|
project: str = "", timeout: float = DEFAULT_TIMEOUT,
|
|
63
|
-
now=time.monotonic, open_socket=None
|
|
91
|
+
now=time.monotonic, open_socket=None,
|
|
92
|
+
security_context: dict[str, Any] | None = None) -> int:
|
|
64
93
|
"""Send one message and print what comes back. Returns the exit code.
|
|
65
94
|
|
|
66
95
|
THE CLOCK IS INJECTED so a timeout can be reached without waiting for one.
|
|
@@ -85,9 +114,12 @@ def run(api: Api, target: str, text: str, *, session: str = "",
|
|
|
85
114
|
with watching(api.config.api, api.token(), session_id,
|
|
86
115
|
open_socket=open_socket) as socket:
|
|
87
116
|
try:
|
|
88
|
-
|
|
117
|
+
body: dict[str, Any] = {
|
|
89
118
|
"target_slug": target, "text": text,
|
|
90
|
-
"session_id": session_id, "project": project}
|
|
119
|
+
"session_id": session_id, "project": project}
|
|
120
|
+
if security_context is not None:
|
|
121
|
+
body["security_context"] = security_context
|
|
122
|
+
started = api.request("POST", "/v1/invocations", json=body)
|
|
91
123
|
except ApiError as exc:
|
|
92
124
|
print(f"{exc}", file=sys.stderr)
|
|
93
125
|
return 1
|
|
@@ -95,6 +127,10 @@ def run(api: Api, target: str, text: str, *, session: str = "",
|
|
|
95
127
|
invocation = started.get("invocation_id", "")
|
|
96
128
|
print(f"invocation {invocation}")
|
|
97
129
|
print(f"session {session_id}")
|
|
130
|
+
if security_context:
|
|
131
|
+
# NAMES ONLY. The values were sent and are never printed.
|
|
132
|
+
names = ", ".join(c["name"] for c in security_context["credentials"])
|
|
133
|
+
print(f"credentials {names or '(none)'}")
|
|
98
134
|
print()
|
|
99
135
|
try:
|
|
100
136
|
return _follow(socket, invocation, target, session_id,
|
|
@@ -144,8 +144,11 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
144
144
|
# documents.
|
|
145
145
|
passthrough = sub.add_parser(
|
|
146
146
|
"adk", help="run ADK's own tools against this repo (web, run, eval)")
|
|
147
|
-
passthrough.add_argument(
|
|
148
|
-
|
|
147
|
+
passthrough.add_argument(
|
|
148
|
+
"args", nargs=argparse.REMAINDER,
|
|
149
|
+
help="Passed to ADK unchanged, except --security-context FILE: the "
|
|
150
|
+
"credentials a local run acts with, as JSON (ADR-0249), e.g. "
|
|
151
|
+
"`elan adk web --security-context ctx.json`.")
|
|
149
152
|
|
|
150
153
|
# `env` TAKES NOTHING, for the same reason `init` lost its flag: the
|
|
151
154
|
# runtime resolves from the index by name.
|
|
@@ -194,6 +197,10 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
194
197
|
help="seconds to wait for a reply (default 300; a "
|
|
195
198
|
"sleeping agent has to be scheduled and started "
|
|
196
199
|
"before it reads its queue)")
|
|
200
|
+
send.add_argument("--security-context", metavar="FILE", default=None,
|
|
201
|
+
help="credentials the agent may act with for this run, "
|
|
202
|
+
"as JSON — a file, or - for stdin. Never on the "
|
|
203
|
+
"command line, which shell history and ps can read")
|
|
197
204
|
|
|
198
205
|
log = sub.add_parser("logs", help="a build's output, or a workload's")
|
|
199
206
|
# OPTIONAL, BECAUSE `--workload` REPLACES IT. argparse cannot express "one of
|
|
@@ -575,10 +582,19 @@ def _dispatch(args, parser) -> int:
|
|
|
575
582
|
# FROM elan.yaml, WHICH IS THE ONLY PLACE THAT KNOWS. `invoke` is
|
|
576
583
|
# run inside a project, and the deploy file names it — so this is
|
|
577
584
|
# read rather than asked for, the same way `deploy` reads it.
|
|
585
|
+
security_context = None
|
|
586
|
+
if args.security_context:
|
|
587
|
+
try:
|
|
588
|
+
security_context = invoke_cmd.load_security_context(
|
|
589
|
+
args.security_context)
|
|
590
|
+
except (OSError, ValueError) as exc:
|
|
591
|
+
print(f"--security-context: {exc}", file=sys.stderr)
|
|
592
|
+
return 2
|
|
578
593
|
return invoke_cmd.run(api, args.target, args.text,
|
|
579
594
|
session=args.session,
|
|
580
595
|
project=_project_here(),
|
|
581
|
-
timeout=args.timeout
|
|
596
|
+
timeout=args.timeout,
|
|
597
|
+
security_context=security_context)
|
|
582
598
|
finally:
|
|
583
599
|
api.close()
|
|
584
600
|
|
|
@@ -9,16 +9,32 @@ trust boundary there has to be a process rather than a parser.
|
|
|
9
9
|
The asymmetry is the design. Here there is no boundary to cross: a developer
|
|
10
10
|
running `elan validate` on their own repo is already running their own code
|
|
11
11
|
every time they run their own tests.
|
|
12
|
+
|
|
13
|
+
MCP SERVERS ARE READ AND NOT RUN, and that is a dependency fact rather than a
|
|
14
|
+
trust one (ADR-0250). A server's code needs `mcp_servers/pyproject.toml` — a
|
|
15
|
+
FastMCP that may need `mcp>=2.3` — and the agents' environment pins ADK, which
|
|
16
|
+
pins `mcp<2`, so no one interpreter holds both. `read_servers` parses each
|
|
17
|
+
`server.py` and takes its MANIFEST as written. Running it would mean a second
|
|
18
|
+
environment per repo and an eighth published package for its exporter; the
|
|
19
|
+
build's own export, which does run it, stays the authority.
|
|
12
20
|
"""
|
|
13
21
|
|
|
14
22
|
from __future__ import annotations
|
|
15
23
|
|
|
24
|
+
import ast
|
|
16
25
|
import json
|
|
17
26
|
import os
|
|
18
27
|
import subprocess
|
|
19
28
|
import sys
|
|
20
29
|
from pathlib import Path
|
|
21
30
|
|
|
31
|
+
from elan_agentkit_contracts.manifest import McpServerManifest
|
|
32
|
+
|
|
33
|
+
#: Where the build looks for MCP servers, and the file inside each one —
|
|
34
|
+
#: `agentkit_mcp.discovery`'s two names, which a test holds this to.
|
|
35
|
+
SERVERS_DIR = "mcp_servers"
|
|
36
|
+
SERVER_FILE = "server.py"
|
|
37
|
+
|
|
22
38
|
|
|
23
39
|
class ManifestError(Exception):
|
|
24
40
|
"""The repo's targets could not be read, with the reason the developer needs."""
|
|
@@ -122,3 +138,90 @@ def read(targets_root: Path, *, python: str | None = None) -> list[dict]:
|
|
|
122
138
|
f"the exporter did not produce JSON: {exc}. "
|
|
123
139
|
f"First 200 characters: {out.stdout[:200]!r}"
|
|
124
140
|
) from exc
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def read_servers(targets_root: Path) -> list[dict]:
|
|
144
|
+
"""Every MCP server's MANIFEST, read from its source without running it.
|
|
145
|
+
|
|
146
|
+
THE BUILD'S RULES FOR WHAT COUNTS AS A SERVER, so validate and the build see
|
|
147
|
+
the same set: `mcp_servers/<module>/server.py`, sorted, skipping a directory
|
|
148
|
+
with no `server.py` or whose name starts with `_`, and refusing a slug two
|
|
149
|
+
servers declare.
|
|
150
|
+
|
|
151
|
+
A MANIFEST HAS TO BE WRITTEN OUT: a dict, which is what `elan new mcp`
|
|
152
|
+
scaffolds, or `McpServerManifest(...)` with literal arguments. One computed
|
|
153
|
+
at import time is refused here with the reason, and still accepted by the
|
|
154
|
+
build, which runs the code — the refusal is about this command's reach, not
|
|
155
|
+
about the server.
|
|
156
|
+
"""
|
|
157
|
+
base = targets_root / SERVERS_DIR
|
|
158
|
+
if not base.is_dir():
|
|
159
|
+
return []
|
|
160
|
+
found: dict[str, dict] = {}
|
|
161
|
+
for directory in sorted(p for p in base.iterdir() if p.is_dir()):
|
|
162
|
+
path = directory / SERVER_FILE
|
|
163
|
+
if not path.is_file() or directory.name.startswith("_"):
|
|
164
|
+
continue
|
|
165
|
+
where = path.relative_to(targets_root)
|
|
166
|
+
try:
|
|
167
|
+
manifest = McpServerManifest.model_validate(_written_manifest(path, where))
|
|
168
|
+
# pydantic's ValidationError IS a ValueError, and this package declares
|
|
169
|
+
# contracts rather than pydantic — so it is caught by its base.
|
|
170
|
+
except ValueError as exc:
|
|
171
|
+
raise ManifestError(f"{where}: MANIFEST is invalid.\n\n{exc}") from exc
|
|
172
|
+
if manifest.slug in found:
|
|
173
|
+
raise ManifestError(
|
|
174
|
+
f"slug {manifest.slug!r} is declared by both "
|
|
175
|
+
f"{found[manifest.slug]['module']} and {where}. Each MCP server "
|
|
176
|
+
"needs its own.")
|
|
177
|
+
found[manifest.slug] = {"module": str(where),
|
|
178
|
+
**manifest.model_dump(mode="json")}
|
|
179
|
+
return [found[slug] for slug in sorted(found)]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _written_manifest(path: Path, where: Path) -> dict:
|
|
183
|
+
"""The value of the module-level `MANIFEST = ...`, as plain data."""
|
|
184
|
+
try:
|
|
185
|
+
tree = ast.parse(path.read_text(), filename=str(where))
|
|
186
|
+
except SyntaxError as exc:
|
|
187
|
+
raise ManifestError(f"{where} does not parse: {exc}") from exc
|
|
188
|
+
|
|
189
|
+
# THE LAST ASSIGNMENT WINS, as it would when the module runs.
|
|
190
|
+
value: ast.expr | None = None
|
|
191
|
+
for node in tree.body:
|
|
192
|
+
if isinstance(node, ast.Assign) and any(
|
|
193
|
+
isinstance(t, ast.Name) and t.id == "MANIFEST" for t in node.targets):
|
|
194
|
+
value = node.value
|
|
195
|
+
elif (isinstance(node, ast.AnnAssign) and node.value is not None
|
|
196
|
+
and isinstance(node.target, ast.Name) and node.target.id == "MANIFEST"):
|
|
197
|
+
value = node.value
|
|
198
|
+
if value is None:
|
|
199
|
+
raise ManifestError(
|
|
200
|
+
f"{where} has no MANIFEST. An MCP server's module exports MANIFEST "
|
|
201
|
+
"and a callable build(); `elan new mcp` writes both.")
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
if isinstance(value, ast.Call) and _names_the_model(value.func):
|
|
205
|
+
if value.args or any(kw.arg is None for kw in value.keywords):
|
|
206
|
+
raise ValueError("positional or ** arguments")
|
|
207
|
+
return {kw.arg: ast.literal_eval(kw.value) for kw in value.keywords}
|
|
208
|
+
written = ast.literal_eval(value)
|
|
209
|
+
except ValueError:
|
|
210
|
+
written = None
|
|
211
|
+
if not isinstance(written, dict):
|
|
212
|
+
raise ManifestError(
|
|
213
|
+
f"{where}: MANIFEST is computed rather than written out, so "
|
|
214
|
+
"`elan validate` cannot read it without running the server — and "
|
|
215
|
+
"running it needs mcp_servers/pyproject.toml's dependencies, which "
|
|
216
|
+
"the agents' environment cannot hold beside ADK.\n\n"
|
|
217
|
+
"Write it as a dict of plain values (what `elan new mcp` scaffolds) "
|
|
218
|
+
"or as McpServerManifest(...) with plain-value arguments. The build "
|
|
219
|
+
"runs the server and accepts either way; this is only about what "
|
|
220
|
+
"can be checked here.")
|
|
221
|
+
return written
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _names_the_model(func: ast.expr) -> bool:
|
|
225
|
+
"""`McpServerManifest(...)` or `<module>.McpServerManifest(...)`."""
|
|
226
|
+
return ((isinstance(func, ast.Name) and func.id == "McpServerManifest")
|
|
227
|
+
or (isinstance(func, ast.Attribute) and func.attr == "McpServerManifest"))
|
|
@@ -83,7 +83,7 @@ def load(spec_path: Path) -> Project:
|
|
|
83
83
|
return Project(root=spec_path.parent.resolve(), spec_path=spec_path, spec=spec)
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def add_target(spec_path: Path, slug: str) -> None:
|
|
86
|
+
def add_target(spec_path: Path, slug: str, *, kind: str = "agent") -> None:
|
|
87
87
|
"""Append a `targets:` entry, preserving everything already in the file.
|
|
88
88
|
|
|
89
89
|
A TEXT EDIT, NOT A PARSE-AND-DUMP, and the reason is the file itself. This
|
|
@@ -119,6 +119,15 @@ def add_target(spec_path: Path, slug: str) -> None:
|
|
|
119
119
|
f" # merging field by field, so state all of it or none of it.\n"
|
|
120
120
|
f" database: {{enabled: true}}\n"
|
|
121
121
|
)
|
|
122
|
+
if kind == "mcp":
|
|
123
|
+
# AN MCP SERVER (ADR-0250): no database unless it asks, and reachable
|
|
124
|
+
# by this project's own agents until it says `expose: public`.
|
|
125
|
+
entry = (
|
|
126
|
+
f"\n {slug}:\n"
|
|
127
|
+
f" # An MCP server. `public` also lets callers outside this\n"
|
|
128
|
+
f" # project reach it at /mcp/<tenant>/<project>/{slug}.\n"
|
|
129
|
+
f" expose: project\n"
|
|
130
|
+
)
|
|
122
131
|
|
|
123
132
|
# AFTER THE LAST TARGET, NOT IMMEDIATELY AFTER THE KEY. Inserting at the top
|
|
124
133
|
# would put the new entry above targets that were there first, so every
|
|
@@ -29,7 +29,9 @@ from elan_cli.project import SPEC_FILENAME, ProjectError, add_target, find
|
|
|
29
29
|
|
|
30
30
|
#: `agent` and `workflow` differ by the file the registry scans for, and by
|
|
31
31
|
#: nothing else the scaffolder needs to know.
|
|
32
|
-
KINDS = {"agent": ("agents", "agent.py"), "workflow": ("workflows", "workflow.py")
|
|
32
|
+
KINDS = {"agent": ("agents", "agent.py"), "workflow": ("workflows", "workflow.py"),
|
|
33
|
+
# An MCP server (ADR-0250), served from an image of its own.
|
|
34
|
+
"mcp": ("mcp_servers", "server.py")}
|
|
33
35
|
|
|
34
36
|
#: A SHA THAT IS OBVIOUSLY A PLACEHOLDER. `source.ref` must match a 40-character
|
|
35
37
|
#: hex pattern, so it cannot be left blank — and a plausible-looking sha would
|
|
@@ -436,6 +438,7 @@ def init(directory: Path, *, tenant: str, project: str, repo: str,
|
|
|
436
438
|
directory.mkdir(parents=True, exist_ok=True)
|
|
437
439
|
(directory / "agents").mkdir(exist_ok=True)
|
|
438
440
|
(directory / "workflows").mkdir(exist_ok=True)
|
|
441
|
+
(directory / "mcp_servers").mkdir(exist_ok=True)
|
|
439
442
|
# WRITTEN HERE RATHER THAN LEFT TO THE DEVELOPER because `elan env` puts a
|
|
440
443
|
# virtualenv in this directory, and a committed one is both enormous and
|
|
441
444
|
# full of absolute paths from somebody else's machine. NOT OVERWRITTEN: a
|
|
@@ -557,6 +560,13 @@ def _write_target(kind: str, slug: str, root: Path) -> Path:
|
|
|
557
560
|
path = directory / filename
|
|
558
561
|
path.write_text(templates.read(kind).format(
|
|
559
562
|
slug=slug, module=module, display_name=slug.replace("-", " ").title()))
|
|
563
|
+
# THE SERVERS' OWN DEPENDENCY FILE (ADR-0250), written once and never
|
|
564
|
+
# overwritten. The MCP image installs from it, never from the root
|
|
565
|
+
# pyproject, which is the agents'.
|
|
566
|
+
if kind == "mcp":
|
|
567
|
+
dependencies = root / package / "pyproject.toml"
|
|
568
|
+
if not dependencies.exists():
|
|
569
|
+
dependencies.write_text(templates.mcp_pyproject())
|
|
560
570
|
return path
|
|
561
571
|
|
|
562
572
|
|
|
@@ -578,12 +588,27 @@ def new(kind: str, slug: str, *, start: Path | None = None) -> int:
|
|
|
578
588
|
# THE YAML SECOND, so a failure to write the module leaves the deploy file
|
|
579
589
|
# untouched rather than declaring a target that does not exist.
|
|
580
590
|
path = _write_target(kind, slug, project.targets_root)
|
|
581
|
-
add_target(project.spec_path, slug)
|
|
591
|
+
add_target(project.spec_path, slug, kind=kind)
|
|
582
592
|
|
|
583
593
|
print(f"created {path}")
|
|
584
594
|
print(f"updated {project.spec_path}")
|
|
585
595
|
print()
|
|
586
596
|
print("Next:")
|
|
597
|
+
if kind == "mcp":
|
|
598
|
+
# A SERVER HAS NO INSTRUCTION AND NO LIMITS, so the agent's hints sent
|
|
599
|
+
# its reader to edit things the file does not contain — and said
|
|
600
|
+
# nothing of the two places an MCP server differs: its own dependency
|
|
601
|
+
# file, and an egress list that is its alone (ADR-0250).
|
|
602
|
+
print(f" 1. Edit {path} — its tools, and MANIFEST.version whenever "
|
|
603
|
+
"you change it.")
|
|
604
|
+
print(f" 2. Put its dependencies in {path.parent.parent.name}/"
|
|
605
|
+
"pyproject.toml, not the root one.")
|
|
606
|
+
print(f" 3. Declare every host it calls under egress: for {slug} in "
|
|
607
|
+
f"{project.spec_path.name}. Only this server can reach them.")
|
|
608
|
+
print(f" 4. Set owner.team and owner.contacts for {slug} in "
|
|
609
|
+
f"{project.spec_path.name}.")
|
|
610
|
+
print(" 5. elan validate")
|
|
611
|
+
return 0
|
|
587
612
|
print(f" 1. Edit {path} — instruction, description, limits.")
|
|
588
613
|
print(f" 2. Set owner.team and owner.contacts for {slug} in "
|
|
589
614
|
f"{project.spec_path.name}.")
|
|
@@ -20,7 +20,7 @@ from pathlib import Path
|
|
|
20
20
|
|
|
21
21
|
from elan_agentkit_contracts.deploy_spec import Problem, cross_check
|
|
22
22
|
|
|
23
|
-
from elan_cli.manifests import ManifestError, read
|
|
23
|
+
from elan_cli.manifests import ManifestError, read, read_servers
|
|
24
24
|
from elan_cli.project import Project, ProjectError, find
|
|
25
25
|
|
|
26
26
|
|
|
@@ -38,13 +38,21 @@ def run(start: Path | None = None, *, python: str | None = None) -> int:
|
|
|
38
38
|
|
|
39
39
|
try:
|
|
40
40
|
manifests = read(project.targets_root, python=python)
|
|
41
|
+
# THE MCP SERVERS, READ AND NOT RUN (ADR-0250): their dependencies
|
|
42
|
+
# cannot share the agents' environment, so `read_servers` takes each
|
|
43
|
+
# MANIFEST as written. Joined into one list exactly as the build joins
|
|
44
|
+
# its two exports, so `cross_check` sees what the deploy will.
|
|
45
|
+
servers = read_servers(project.targets_root)
|
|
41
46
|
except ManifestError as exc:
|
|
42
47
|
print(f"\nerror: {exc}")
|
|
43
48
|
return 2
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
found = f" found {len(manifests) + len(servers)} in {project.targets_root}"
|
|
51
|
+
if servers:
|
|
52
|
+
found += f" ({len(servers)} MCP server{'' if len(servers) == 1 else 's'})"
|
|
53
|
+
print(found)
|
|
46
54
|
|
|
47
|
-
problems = cross_check(project.spec, manifests)
|
|
55
|
+
problems = cross_check(project.spec, [*manifests, *servers])
|
|
48
56
|
if not problems:
|
|
49
57
|
print("\nok — this would be accepted.")
|
|
50
58
|
_warn_unenforced(project)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|