ekl-cli 0.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ekl_cli/__init__.py +2 -0
- ekl_cli/bridge.py +160 -0
- ekl_cli/client.py +232 -0
- ekl_cli/clients/.agents/plugins/marketplace.json +20 -0
- ekl_cli/clients/.claude-plugin/marketplace.json +16 -0
- ekl_cli/clients/README.md +3 -0
- ekl_cli/clients/claude-code/.claude-plugin/plugin.json +14 -0
- ekl_cli/clients/claude-code/.mcp.json +10 -0
- ekl_cli/clients/claude-code/commands/check.md +11 -0
- ekl_cli/clients/claude-code/commands/deploy.md +49 -0
- ekl_cli/clients/claude-code/commands/status.md +10 -0
- ekl_cli/clients/claude-code/skills/agent-behaviour/SKILL.md +112 -0
- ekl_cli/clients/claude-code/skills/agent-config-in-repo/SKILL.md +92 -0
- ekl_cli/clients/claude-code/skills/connect-mcp-server/SKILL.md +296 -0
- ekl_cli/clients/claude-code/skills/operate-agent/SKILL.md +54 -0
- ekl_cli/clients/claude-code/skills/plan-with-the-network/SKILL.md +60 -0
- ekl_cli/clients/codex/mcp.json +11 -0
- ekl_cli/clients/codex/plugin.json +8 -0
- ekl_cli/clients/codex/skills/agent-behaviour/SKILL.md +112 -0
- ekl_cli/clients/codex/skills/agent-config-in-repo/SKILL.md +92 -0
- ekl_cli/clients/codex/skills/connect-mcp-server/SKILL.md +296 -0
- ekl_cli/clients/codex/skills/operate-agent/SKILL.md +54 -0
- ekl_cli/clients/codex/skills/plan-with-the-network/SKILL.md +60 -0
- ekl_cli/clients/cursor/.cursor-plugin/plugin.json +8 -0
- ekl_cli/clients/cursor/commands/check.md +11 -0
- ekl_cli/clients/cursor/commands/deploy.md +49 -0
- ekl_cli/clients/cursor/commands/status.md +10 -0
- ekl_cli/clients/cursor/mcp.json +10 -0
- ekl_cli/clients/cursor/rules/eukollab.mdc +81 -0
- ekl_cli/clients/cursor/skills/agent-behaviour/SKILL.md +112 -0
- ekl_cli/clients/cursor/skills/agent-config-in-repo/SKILL.md +92 -0
- ekl_cli/clients/cursor/skills/connect-mcp-server/SKILL.md +296 -0
- ekl_cli/clients/cursor/skills/operate-agent/SKILL.md +54 -0
- ekl_cli/clients/cursor/skills/plan-with-the-network/SKILL.md +60 -0
- ekl_cli/clients/gemini/GEMINI.md +76 -0
- ekl_cli/clients/gemini/gemini-extension.json +14 -0
- ekl_cli/clients/generic/AGENTS.md +76 -0
- ekl_cli/clients/generic/mcp.json +10 -0
- ekl_cli/clients/vscode/instructions/eukollab.instructions.md +80 -0
- ekl_cli/clients/vscode/mcp.json +11 -0
- ekl_cli/command_help.py +223 -0
- ekl_cli/declarations.py +492 -0
- ekl_cli/deploy.py +432 -0
- ekl_cli/deploy_command.py +556 -0
- ekl_cli/derive.py +217 -0
- ekl_cli/design.py +339 -0
- ekl_cli/finder.py +695 -0
- ekl_cli/icon.py +102 -0
- ekl_cli/install.py +185 -0
- ekl_cli/lifecycle.py +357 -0
- ekl_cli/main.py +643 -0
- ekl_cli/mcp.py +279 -0
- ekl_cli/messages.py +245 -0
- ekl_cli/onboard.py +1040 -0
- ekl_cli/participation.py +247 -0
- ekl_cli/project.py +211 -0
- ekl_cli/prompt.py +176 -0
- ekl_cli/py.typed +0 -0
- ekl_cli/release_root.json +9 -0
- ekl_cli/release_trust.py +376 -0
- ekl_cli/repair.py +266 -0
- ekl_cli/schema.py +117 -0
- ekl_cli/setup.py +326 -0
- ekl_cli/supervise.py +162 -0
- ekl_cli/templates/python/eukollab-agent.md.tmpl +202 -0
- ekl_cli/templates/python/eukollab_callbacks.py.tmpl +509 -0
- ekl_cli/templates/versions.json +3 -0
- ekl_cli/ui.py +158 -0
- ekl_cli/versions.py +402 -0
- ekl_cli-0.10.0.dist-info/METADATA +72 -0
- ekl_cli-0.10.0.dist-info/RECORD +75 -0
- ekl_cli-0.10.0.dist-info/WHEEL +5 -0
- ekl_cli-0.10.0.dist-info/entry_points.txt +2 -0
- ekl_cli-0.10.0.dist-info/licenses/LICENSE +10 -0
- ekl_cli-0.10.0.dist-info/top_level.txt +1 -0
ekl_cli/declarations.py
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
# Copyright © 2026 EuKreate, Inc. All rights reserved.
|
|
2
|
+
"""What MCP can't say about an existing server, kept beside its connector so the server itself never changes
|
|
3
|
+
(spec C.14.5). eukollab.json is the only place the agent's settings are declared:
|
|
4
|
+
|
|
5
|
+
{"agent": {"data": {...}, "plans": [...], "terms": {...}},
|
|
6
|
+
"tools": {"get_document_fields": {"class": "read_only", "plans": [...]}},
|
|
7
|
+
"uses": [{"need": "Is a given day a public holiday, by country", "prefer": "@holidays/is_holiday"}]}
|
|
8
|
+
|
|
9
|
+
`agent` holds the agent-wide settings, each `tools` entry one service's, and `uses` the services the agent plans to
|
|
10
|
+
use. `ekl add` writes the file from the publisher's answers; `ekl sync` and `ekl check` read it. Declarations in a
|
|
11
|
+
server's own code are never read."""
|
|
12
|
+
|
|
13
|
+
import copy
|
|
14
|
+
import json
|
|
15
|
+
import shutil
|
|
16
|
+
from decimal import Decimal, InvalidOperation
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
from ekl_cli import icon as icon_file
|
|
21
|
+
from ekl_cli import prompt
|
|
22
|
+
from ekl_cli.client import CliError
|
|
23
|
+
from ekl_cli.derive import DECLARED, capability, class_of, profile, service_declaration
|
|
24
|
+
|
|
25
|
+
FILE = "eukollab.json"
|
|
26
|
+
# A server that keeps nothing it receives or returns, trains on nothing, and passes nothing on.
|
|
27
|
+
KEEPS_NOTHING = {
|
|
28
|
+
"inputs": {"retention": "none"},
|
|
29
|
+
"results": {"retention": "none"},
|
|
30
|
+
"downstream": {"retention": "none", "subprocessors": []},
|
|
31
|
+
"used_for_training": False,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _obj(value: Any) -> dict[str, Any]:
|
|
36
|
+
return value if isinstance(value, dict) else {}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def load(directory: Path) -> dict[str, Any]:
|
|
40
|
+
"""The declarations beside the connector, or none."""
|
|
41
|
+
path = directory / FILE
|
|
42
|
+
if not path.exists():
|
|
43
|
+
return {}
|
|
44
|
+
try:
|
|
45
|
+
declared = json.loads(path.read_text())
|
|
46
|
+
except json.JSONDecodeError as exc:
|
|
47
|
+
raise CliError("EKL-202", str(exc), path=path) from exc
|
|
48
|
+
if not isinstance(declared, dict):
|
|
49
|
+
raise CliError("EKL-211", path=path)
|
|
50
|
+
found: dict[str, Any] = declared_only(declared)
|
|
51
|
+
return found
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def declared_only(value: Any) -> Any:
|
|
55
|
+
"""What the file declares: a null is a field left to fill in, so it declares nothing, and an example with no
|
|
56
|
+
value filled in is no example."""
|
|
57
|
+
if isinstance(value, dict):
|
|
58
|
+
kept = {k: declared_only(v) for k, v in value.items() if v is not None}
|
|
59
|
+
if isinstance(kept.get("example"), dict) and not kept["example"].get("input"):
|
|
60
|
+
del kept["example"]
|
|
61
|
+
return {k: v for k, v in kept.items() if v != {} or k == "input"}
|
|
62
|
+
return value
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# What the file holds for each setting that wasn't answered, so it's filled in place (spec C.14.5).
|
|
66
|
+
AGENT_FIELDS = ("display_name", "purpose", "logo", "website", "interests", "data", "plans", "terms")
|
|
67
|
+
TOOL_FIELDS = ("class", "offered", "category", "limitations", "plans", "example")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def skeleton(declared: dict[str, Any], tools: list[dict[str, Any]]) -> dict[str, Any]:
|
|
71
|
+
"""eukollab.json as written by init: what was declared, and null for every other field, so the publisher edits
|
|
72
|
+
values in place. A tool's example lists its input fields: the required ones, or with none required all of them."""
|
|
73
|
+
agent = dict.fromkeys(AGENT_FIELDS) | _obj(declared.get("agent"))
|
|
74
|
+
per_tool: dict[str, Any] = {}
|
|
75
|
+
for tool in tools:
|
|
76
|
+
name = str(tool.get("name") or "")
|
|
77
|
+
if not name:
|
|
78
|
+
continue
|
|
79
|
+
schema = tool.get("inputSchema") or {}
|
|
80
|
+
fields = list(schema.get("required") or []) or list(schema.get("properties") or {})
|
|
81
|
+
entry = dict.fromkeys(TOOL_FIELDS) | {"example": {"input": dict.fromkeys(fields)}}
|
|
82
|
+
per_tool[name] = entry | _obj(_obj(declared.get("tools")).get(name))
|
|
83
|
+
return {"agent": agent, "tools": per_tool}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def write(directory: Path, declared: dict[str, Any], files: dict[str, Path] | None = None) -> None:
|
|
87
|
+
"""eukollab.json, and the files it names copied beside it."""
|
|
88
|
+
(directory / FILE).write_text(json.dumps(declared, indent=2, ensure_ascii=False) + "\n")
|
|
89
|
+
for name, source in (files or {}).items():
|
|
90
|
+
if source.resolve() != (directory / name).resolve():
|
|
91
|
+
shutil.copyfile(source, directory / name)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def merged(
|
|
95
|
+
server: dict[str, Any], tools: list[dict[str, Any]], declared: dict[str, Any]
|
|
96
|
+
) -> tuple[dict[str, Any], list[dict[str, Any]]]:
|
|
97
|
+
"""The server and its tools with what eukollab.json declares beside them, for derive."""
|
|
98
|
+
if not declared:
|
|
99
|
+
return server, tools
|
|
100
|
+
server = copy.deepcopy(server)
|
|
101
|
+
agent = _as_defaults(_obj(declared.get("agent")))
|
|
102
|
+
if agent:
|
|
103
|
+
server[DECLARED] = agent
|
|
104
|
+
per_tool = _obj(declared.get("tools"))
|
|
105
|
+
out = []
|
|
106
|
+
for tool in tools:
|
|
107
|
+
extra = _obj(per_tool.get(str(tool.get("name"))))
|
|
108
|
+
if not extra:
|
|
109
|
+
out.append(tool)
|
|
110
|
+
continue
|
|
111
|
+
declaring = copy.deepcopy(tool)
|
|
112
|
+
declaring[DECLARED] = extra
|
|
113
|
+
out.append(declaring)
|
|
114
|
+
return server, out
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def uses(directory: Path) -> list[dict[str, Any]]:
|
|
118
|
+
"""The services the agent plans to use, as eukollab.json declares them: each a need in words and, optionally, the
|
|
119
|
+
service it prefers (@handle/service). At most 30."""
|
|
120
|
+
found = load(directory).get("uses")
|
|
121
|
+
if found is None:
|
|
122
|
+
return []
|
|
123
|
+
if not isinstance(found, list):
|
|
124
|
+
raise CliError("EKL-212", "It must be a list.")
|
|
125
|
+
out = []
|
|
126
|
+
for n, item in enumerate(found, 1):
|
|
127
|
+
if not isinstance(item, dict) or not str(item.get("need") or "").strip():
|
|
128
|
+
raise CliError("EKL-212", f"Item {n} needs a need, in words.")
|
|
129
|
+
use: dict[str, Any] = {"need": str(item["need"]).strip()[:200]}
|
|
130
|
+
prefer = str(item.get("prefer") or "").strip()
|
|
131
|
+
if prefer:
|
|
132
|
+
handle, _, name = prefer.partition("/")
|
|
133
|
+
if not handle.startswith("@") or not name:
|
|
134
|
+
raise CliError("EKL-212", f"Item {n} prefers {prefer}: name a service as @handle/service.")
|
|
135
|
+
use["prefer"] = prefer
|
|
136
|
+
out.append(use)
|
|
137
|
+
if len(out) > MAX_USES:
|
|
138
|
+
raise CliError("EKL-212", f"It lists {len(out)} services; at most {MAX_USES}.")
|
|
139
|
+
return out
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
MAX_USES = 30
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _as_defaults(agent: dict[str, Any]) -> dict[str, Any]:
|
|
146
|
+
"""The file's agent-wide part as derive reads it: data and plans are the services' defaults, and giving data
|
|
147
|
+
declares how the agent handles it."""
|
|
148
|
+
out = {k: v for k, v in agent.items() if k not in ("data", "plans")}
|
|
149
|
+
defaults = {k: agent[k] for k in ("data", "plans") if k in agent}
|
|
150
|
+
if defaults:
|
|
151
|
+
out["defaults"] = (out.get("defaults") or {}) | defaults
|
|
152
|
+
if "data" in agent and "data_declared" not in out:
|
|
153
|
+
out["data_declared"] = True
|
|
154
|
+
return out
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
CLASS_CHOICES = [
|
|
158
|
+
prompt.Option("r", "read", "looks things up and changes nothing"),
|
|
159
|
+
prompt.Option("c", "change", "changes something in the world: sends, buys, books, deletes"),
|
|
160
|
+
prompt.Option("t", "transform", "turns what it is given into a result, and keeps nothing (convert, extract)"),
|
|
161
|
+
]
|
|
162
|
+
CLASS_OF = {"r": "read_only", "c": "external_action", "t": "transformation"}
|
|
163
|
+
DATA_CHOICES = [
|
|
164
|
+
prompt.Option("1", "keeps nothing", "nothing it receives or returns is stored, and no model is trained on it"),
|
|
165
|
+
prompt.Option("2", "keeps or trains", "it stores some of it, or trains models on it: you declare how afterwards"),
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _unsettled(server_tools: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|
170
|
+
"""The tools nothing settles: no annotations say whether they act, and eukollab.json declares no class."""
|
|
171
|
+
out = []
|
|
172
|
+
for tool in server_tools:
|
|
173
|
+
_, unsettled = class_of(tool.get("annotations") or {})
|
|
174
|
+
if tool.get("name") and unsettled and "class" not in service_declaration(tool):
|
|
175
|
+
out.append(tool)
|
|
176
|
+
return out
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
FREE = "free"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _answer(question: str, default: str, *details: str, shown: str = "") -> str:
|
|
183
|
+
"""The person's answer, else the default when nobody is asked."""
|
|
184
|
+
if not prompt.interactive():
|
|
185
|
+
return default
|
|
186
|
+
return prompt.text(question, default, *details, shown=shown)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _price(text: str) -> str | None:
|
|
190
|
+
"""A pack's price in USD as a decimal string, or None for free."""
|
|
191
|
+
text = text.strip().removeprefix("$").strip()
|
|
192
|
+
if text.lower() in {"", FREE, "0"}:
|
|
193
|
+
return None
|
|
194
|
+
try:
|
|
195
|
+
value = Decimal(text)
|
|
196
|
+
except InvalidOperation as exc:
|
|
197
|
+
raise CliError("EKL-213", f"Price {text}: give a USD amount such as 0.05, or free.") from exc
|
|
198
|
+
if value <= 0 or value != value.quantize(Decimal("0.000001")):
|
|
199
|
+
raise CliError("EKL-213", f"Price {text}: above 0, with at most 6 decimal places.")
|
|
200
|
+
return f"{value:f}"
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _calls(text: str) -> int:
|
|
204
|
+
"""The calls a pack's price buys: a whole number from 1."""
|
|
205
|
+
text = text.strip()
|
|
206
|
+
if not text.isdigit() or int(text) < 1:
|
|
207
|
+
raise CliError("EKL-213", f"Calls {text}: a whole number of calls, 1 or more.")
|
|
208
|
+
return int(text)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _profile_questions(
|
|
212
|
+
server: dict[str, Any], tools: list[dict[str, Any]], files: dict[str, Path], drafted: str = ""
|
|
213
|
+
) -> dict[str, Any]:
|
|
214
|
+
"""Name, description and icon: how the agent appears on its card, on Explore and wherever it is listed. A
|
|
215
|
+
description EuKollab drafted is the default, shown beside what the server says (Appendix C.8.1)."""
|
|
216
|
+
derived = profile(server, tools)
|
|
217
|
+
if prompt.interactive():
|
|
218
|
+
prompt.section(
|
|
219
|
+
"How the agent appears",
|
|
220
|
+
"Its name, description and icon show on its card, on Explore and wherever other agents find it. Enter "
|
|
221
|
+
"keeps what your server says.",
|
|
222
|
+
)
|
|
223
|
+
agent: dict[str, Any] = {}
|
|
224
|
+
name = _answer("Name", derived["display_name"]).strip()[:80]
|
|
225
|
+
if name and name != derived["display_name"]:
|
|
226
|
+
agent["display_name"] = name
|
|
227
|
+
purpose = drafted or derived["purpose"]
|
|
228
|
+
described = _answer(
|
|
229
|
+
"Description",
|
|
230
|
+
purpose,
|
|
231
|
+
"One to three sentences on what the agent does and for whom, at most 500 characters.",
|
|
232
|
+
*([f"Drafted by EuKollab from your tools. Your server says: {derived['purpose']}"] if drafted else []),
|
|
233
|
+
shown=purpose if len(purpose) <= 60 else purpose[:57] + "…",
|
|
234
|
+
).strip()
|
|
235
|
+
if len(described) > 500:
|
|
236
|
+
raise CliError("EKL-213", f"The description is {len(described)} characters; at most 500.")
|
|
237
|
+
if described and described != derived["purpose"]:
|
|
238
|
+
agent["purpose"] = described
|
|
239
|
+
icon = _answer(
|
|
240
|
+
"Icon",
|
|
241
|
+
derived["logo"] or "",
|
|
242
|
+
"A square PNG, JPEG or WebP, 128 to 1024 pixels and at most 256 KB: a file here, or an https address. "
|
|
243
|
+
"EuKollab keeps its own copy.",
|
|
244
|
+
shown="your server's icon" if derived["logo"] else "its initials",
|
|
245
|
+
).strip()
|
|
246
|
+
if icon and icon != derived["logo"]:
|
|
247
|
+
agent["logo"], source = icon_file.adopt(icon)
|
|
248
|
+
if source:
|
|
249
|
+
files[agent["logo"]] = source
|
|
250
|
+
return agent
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# What an app that only uses services takes from eukollab.json: its profile. It has no server to read, and agent.json
|
|
254
|
+
# is never edited by hand.
|
|
255
|
+
APP_FIELDS = ("display_name", "purpose", "website", "interests")
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def app_profile(name: str) -> dict[str, Any]:
|
|
259
|
+
"""Name and description of an app that only uses services, asked once with defaults Enter keeps: the profile
|
|
260
|
+
agents read when it posts a need, connects or offers to pay. Kept in eukollab.json, which ekl sync applies."""
|
|
261
|
+
title = " ".join(part.capitalize() for part in name.replace("_", "-").split("-") if part) or name
|
|
262
|
+
if prompt.interactive():
|
|
263
|
+
prompt.section(
|
|
264
|
+
"How the agent appears",
|
|
265
|
+
"Agents see its name and description when it posts a need, asks to connect or offers to pay.",
|
|
266
|
+
)
|
|
267
|
+
display = _answer("Name", title).strip()[:80] or title
|
|
268
|
+
default = f"{display} uses services other agents offer on EuKollab."
|
|
269
|
+
described = _answer(
|
|
270
|
+
"Description", default, "One to three sentences on what the agent does and for whom, at most 500 characters."
|
|
271
|
+
).strip()
|
|
272
|
+
if len(described) > 500:
|
|
273
|
+
raise CliError("EKL-213", f"The description is {len(described)} characters; at most 500.")
|
|
274
|
+
return {"display_name": display, "purpose": described or default}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def keep_app_profile(directory: Path, profile: dict[str, Any]) -> None:
|
|
278
|
+
"""The answers in eukollab.json, so ekl sync keeps them; a file already there keeps what it declares."""
|
|
279
|
+
path = directory / FILE
|
|
280
|
+
held: dict[str, Any] = json.loads(path.read_text()) if path.exists() else {}
|
|
281
|
+
agent = held.setdefault("agent", {})
|
|
282
|
+
for field in APP_FIELDS:
|
|
283
|
+
if agent.get(field) in (None, "", []):
|
|
284
|
+
agent[field] = profile.get(field)
|
|
285
|
+
path.write_text(json.dumps(held, indent=2, ensure_ascii=False) + "\n")
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def apply_app_profile(content: dict[str, Any], directory: Path) -> None:
|
|
289
|
+
"""The profile eukollab.json declares for an app that only uses services, onto agent.json."""
|
|
290
|
+
declared = load(directory).get("agent") or {}
|
|
291
|
+
for field in APP_FIELDS:
|
|
292
|
+
if declared.get(field) not in (None, "", []):
|
|
293
|
+
content.setdefault("agent", {})[field] = declared[field]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _terms(answer: str, files: dict[str, Path]) -> dict[str, Any] | None:
|
|
297
|
+
"""Terms from an https address or a text file, to copy beside eukollab.json as the file the network publishes."""
|
|
298
|
+
if not answer:
|
|
299
|
+
return None
|
|
300
|
+
if answer.startswith("https://"):
|
|
301
|
+
return {"url": answer, "version": "1"}
|
|
302
|
+
path = Path(answer).expanduser()
|
|
303
|
+
if not path.is_file():
|
|
304
|
+
raise CliError("EKL-213", f"Terms {answer}: an https address or a text file.")
|
|
305
|
+
name = f"terms{path.suffix or '.md'}"
|
|
306
|
+
files[name] = path
|
|
307
|
+
return {"text_file": name, "version": "1"}
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _price_questions(server: dict[str, Any], tools: list[dict[str, Any]], files: dict[str, Path]) -> dict[str, Any]:
|
|
311
|
+
"""The price of every service, as a pack of calls, and terms. The answers go into the agent-wide part of
|
|
312
|
+
eukollab.json, and the acceptance of storage-free losses into each tool."""
|
|
313
|
+
declared = _obj(server.get(DECLARED))
|
|
314
|
+
priced = "plans" in _obj(declared.get("defaults")) or any("plans" in service_declaration(t) for t in tools)
|
|
315
|
+
agent: dict[str, Any] = {}
|
|
316
|
+
per_tool: dict[str, Any] = {}
|
|
317
|
+
if prompt.interactive() and not priced:
|
|
318
|
+
prompt.section(
|
|
319
|
+
"Price and terms",
|
|
320
|
+
"What other agents and people pay for its services: a price for a pack of calls, paid from their prepaid "
|
|
321
|
+
"EuKollab wallet; EuKollab pays you out monthly. You can set plans per service in eukollab.json later.",
|
|
322
|
+
)
|
|
323
|
+
if not priced:
|
|
324
|
+
price = _price(_answer("Price, in USD", FREE, shown="free, 200 calls a day per consumer"))
|
|
325
|
+
if price:
|
|
326
|
+
calls = _calls(_answer("For how many calls", "1", "The calls the price buys; 1 is a price per call."))
|
|
327
|
+
agent["plans"] = [{"type": "pack", "price": price, "currency": "USD", "calls": calls}]
|
|
328
|
+
accepted = not prompt.interactive() or prompt.confirm(
|
|
329
|
+
"Accept that a lost answer to a paid call can't be sent again?",
|
|
330
|
+
True,
|
|
331
|
+
"The connector keeps nothing it returns, so a consumer whose answer is lost pays for the call and runs "
|
|
332
|
+
"it again. Yes accepts that for every service. No: the services aren't offered paid until you accept "
|
|
333
|
+
f"it in {FILE} or keep results (durable mode).",
|
|
334
|
+
)
|
|
335
|
+
if accepted:
|
|
336
|
+
per_tool = {str(t["name"]): {"storage_free_accepted": True} for t in tools if t.get("name")}
|
|
337
|
+
if "terms" not in declared:
|
|
338
|
+
terms = _terms(
|
|
339
|
+
_answer(
|
|
340
|
+
"Terms",
|
|
341
|
+
"",
|
|
342
|
+
"Terms for using its services: an https address, or a text file that EuKollab publishes. Enter for "
|
|
343
|
+
"none: the services then show their data handling only.",
|
|
344
|
+
shown="none",
|
|
345
|
+
).strip(),
|
|
346
|
+
files,
|
|
347
|
+
)
|
|
348
|
+
if terms:
|
|
349
|
+
agent["terms"] = terms
|
|
350
|
+
return {"agent": agent, "tools": per_tool}
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def gather(
|
|
354
|
+
server: dict[str, Any], tools: list[dict[str, Any]], drafts: dict[str, Any] | None = None
|
|
355
|
+
) -> tuple[dict[str, Any], dict[str, Path]]:
|
|
356
|
+
"""Ask what MCP can't say and eukollab.json doesn't declare yet: how the agent appears, whether each unannotated
|
|
357
|
+
tool only reads or acts, how the server handles data, its price and terms. Each question has a default; with
|
|
358
|
+
nobody at a terminal, or --keep-defaults, the defaults are taken and the tools stay unsettled. The declarations,
|
|
359
|
+
and the files they name (icon, terms) with where each comes from, for write to copy."""
|
|
360
|
+
files: dict[str, Path] = {}
|
|
361
|
+
drafts = drafts or {}
|
|
362
|
+
agent = _profile_questions(server, tools, files, str(drafts.get("purpose") or ""))
|
|
363
|
+
declared: dict[str, Any] = {}
|
|
364
|
+
per_tool: dict[str, Any] = descriptions(tools, drafts)
|
|
365
|
+
unsettled = _unsettled(tools) if prompt.interactive() else []
|
|
366
|
+
if unsettled:
|
|
367
|
+
prompt.section(
|
|
368
|
+
"What each tool does",
|
|
369
|
+
(
|
|
370
|
+
"1 tool doesn't say whether it only reads or changes something. "
|
|
371
|
+
if len(unsettled) == 1
|
|
372
|
+
else f"{len(unsettled)} tools don't say whether they only read or change something. "
|
|
373
|
+
)
|
|
374
|
+
+ "EuKollab never offers a tool that acts as one that only reads, so a tool you skip isn't offered "
|
|
375
|
+
f"until you declare it in {FILE}.",
|
|
376
|
+
)
|
|
377
|
+
prompt.options(CLASS_CHOICES)
|
|
378
|
+
for n, tool in enumerate(unsettled, 1):
|
|
379
|
+
name = str(tool["name"])
|
|
380
|
+
about = str(tool.get("description") or "").strip()
|
|
381
|
+
key = prompt.choose(name, about, CLASS_CHOICES, step=f"{n}/{len(unsettled)}")
|
|
382
|
+
if key is None:
|
|
383
|
+
continue
|
|
384
|
+
entry: dict[str, Any] = {"class": CLASS_OF[key]}
|
|
385
|
+
if key == "c" and not prompt.confirm(
|
|
386
|
+
f"Offer {name} to other agents now?",
|
|
387
|
+
False,
|
|
388
|
+
f"No keeps it off the network until you set offered to true for it in {FILE} and run ekl sync.",
|
|
389
|
+
):
|
|
390
|
+
entry["offered"] = False
|
|
391
|
+
per_tool[name] = per_tool.get(name, {}) | entry
|
|
392
|
+
already = _obj(server.get(DECLARED))
|
|
393
|
+
if prompt.interactive() and "data" not in already and not _obj(already.get("defaults")).get("data"):
|
|
394
|
+
prompt.section(
|
|
395
|
+
"Data handling",
|
|
396
|
+
"What does your server do with the inputs it receives and the results it returns? Agents see this "
|
|
397
|
+
"before they call it. Enter leaves it undeclared for now.",
|
|
398
|
+
)
|
|
399
|
+
prompt.options(DATA_CHOICES)
|
|
400
|
+
if prompt.choose("", "", DATA_CHOICES) == "1":
|
|
401
|
+
agent["data"] = KEEPS_NOTHING
|
|
402
|
+
priced = _price_questions(server, tools, files)
|
|
403
|
+
agent |= priced["agent"]
|
|
404
|
+
for name, extra in priced["tools"].items():
|
|
405
|
+
per_tool[name] = per_tool.get(name, {}) | extra
|
|
406
|
+
if agent:
|
|
407
|
+
declared["agent"] = agent
|
|
408
|
+
if per_tool:
|
|
409
|
+
declared["tools"] = per_tool
|
|
410
|
+
return declared, files
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
# --- descriptions EuKollab drafts (Appendix C.8.1) --------------------------------------------------------------------
|
|
414
|
+
|
|
415
|
+
DRAFTED = ("summary", "category", "tags", "limitations")
|
|
416
|
+
KEEP_MINE = "-"
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def draft_request(server: dict[str, Any], tools: list[dict[str, Any]]) -> dict[str, Any]:
|
|
420
|
+
"""What `ekl` sends for drafts: the server's name and description and each tool as it lists itself; never the
|
|
421
|
+
server's address or headers."""
|
|
422
|
+
derived = profile(server, tools)
|
|
423
|
+
return {
|
|
424
|
+
"server": {"name": derived["display_name"], "description": derived["purpose"]},
|
|
425
|
+
"tools": [
|
|
426
|
+
{
|
|
427
|
+
"name": str(t["name"]),
|
|
428
|
+
"title": str(t.get("title") or ""),
|
|
429
|
+
"description": str(t.get("description") or "")[:4000],
|
|
430
|
+
"input_schema": t.get("inputSchema") or {},
|
|
431
|
+
"output_schema": t.get("outputSchema") or {},
|
|
432
|
+
"annotations": t.get("annotations") or {},
|
|
433
|
+
}
|
|
434
|
+
for t in tools[:50]
|
|
435
|
+
if t.get("name")
|
|
436
|
+
],
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def wanting_drafts(tools: list[dict[str, Any]], declared: dict[str, Any]) -> list[dict[str, Any]]:
|
|
441
|
+
"""The tools whose summary is still the one derived from the server, or whose category is general: what
|
|
442
|
+
`ekl sync --drafts` asks drafts for."""
|
|
443
|
+
per_tool = _obj(declared.get("tools"))
|
|
444
|
+
out = []
|
|
445
|
+
for tool in tools:
|
|
446
|
+
mine = _obj(per_tool.get(str(tool.get("name"))))
|
|
447
|
+
if tool.get("name") and (not mine.get("summary") or mine.get("category") in {None, "general"}):
|
|
448
|
+
out.append(tool)
|
|
449
|
+
return out
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def descriptions(tools: list[dict[str, Any]], drafts: dict[str, Any]) -> dict[str, Any]:
|
|
453
|
+
"""Each drafted service description shown beside what the server says, as the default: Enter keeps the draft,
|
|
454
|
+
the publisher may type their own summary or keep the server's with -. Kept drafts become the publisher's own
|
|
455
|
+
declarations in eukollab.json; a field eukollab.json already declares is never drafted over."""
|
|
456
|
+
drafted = _obj(drafts.get("services"))
|
|
457
|
+
if not drafted:
|
|
458
|
+
return {}
|
|
459
|
+
if prompt.interactive():
|
|
460
|
+
prompt.section(
|
|
461
|
+
"How each service reads to buyers",
|
|
462
|
+
"EuKollab drafted a description of each service from your tools, saying only what they say. Enter "
|
|
463
|
+
f"keeps a draft; type your own, or {KEEP_MINE} to keep what your server says.",
|
|
464
|
+
)
|
|
465
|
+
per_tool: dict[str, Any] = {}
|
|
466
|
+
for tool in tools:
|
|
467
|
+
name = str(tool.get("name") or "")
|
|
468
|
+
draft = _obj(drafted.get(name))
|
|
469
|
+
mine = service_declaration(tool)
|
|
470
|
+
offered = {k: v for k, v in draft.items() if k in DRAFTED and v and not mine.get(k)}
|
|
471
|
+
if not offered:
|
|
472
|
+
continue
|
|
473
|
+
server_says = str(capability(tool)["summary"])
|
|
474
|
+
summary = str(offered.get("summary") or "")
|
|
475
|
+
if summary:
|
|
476
|
+
kept = _answer(
|
|
477
|
+
f"{name}: summary",
|
|
478
|
+
summary,
|
|
479
|
+
f"Your server says: {server_says}",
|
|
480
|
+
"Category: "
|
|
481
|
+
+ str(offered.get("category") or "unchanged")
|
|
482
|
+
+ " · tags: "
|
|
483
|
+
+ (", ".join(offered.get("tags") or []) or "none"),
|
|
484
|
+
shown=summary if len(summary) <= 60 else summary[:57] + "…",
|
|
485
|
+
).strip()
|
|
486
|
+
if kept == KEEP_MINE:
|
|
487
|
+
continue
|
|
488
|
+
if not 10 <= len(kept) <= 300:
|
|
489
|
+
raise CliError("EKL-213", f"{name}: a summary is 10 to 300 characters; this one is {len(kept)}.")
|
|
490
|
+
offered["summary"] = kept
|
|
491
|
+
per_tool[name] = offered
|
|
492
|
+
return per_tool
|