toolbase 0.8.0__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {toolbase-0.8.0 → toolbase-0.9.0}/CHANGELOG.md +20 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/PKG-INFO +3 -3
- {toolbase-0.8.0 → toolbase-0.9.0}/pyproject.toml +18 -5
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/cli.py +190 -31
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/orchestral.py +69 -6
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/orchestrator.py +115 -16
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/validation.py +4 -2
- {toolbase-0.8.0 → toolbase-0.9.0}/LICENSE +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/MANIFEST.in +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/README.md +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/setup.cfg +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/_setup_host.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/_toolkit_host.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/astro.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/auth.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/config.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/base.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/claude_code.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/codex.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/connect/opencode.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/bundle_deps.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/cache.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/config.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/discovery.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/manifest.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/paths.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/envs/schema.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/hep.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/ingest.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/logging/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/logging/logger.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/naming.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/neutrino.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/quantum.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/bundles.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/config.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/profile_scaffold.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/profiles.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/serve/proxy_tool.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/__init__.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/_rpc.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/context.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/declarative.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/downloads.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/prompts.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/runner.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/schema.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/storage.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/setup/validate_cache.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/skills.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/Dockerfile.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/README.md.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/__init__.py.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/mcp/__init__.py.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/mcp/server_stdio.py.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/requirements.txt.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/setup.py.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/skills/example_skill.md +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/tool_example.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/templates/toolkit.yaml.template +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/toolkit.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase/versioning.py +0 -0
- {toolbase-0.8.0 → toolbase-0.9.0}/toolbase.egg-info/SOURCES.txt +0 -0
|
@@ -8,6 +8,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.9.0] — 2026-07-29
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Toolkit hosts now run on MCP SDK 2.x.** The `mcp` dependency moved from `>=1.0,<2` to `>=2` and `orchestral-ai` from `>=1.4` to `>=1.10`, in both toolbase's own dependencies and the `HOST_RUNTIME_REQUIREMENTS` installed into every toolkit venv. toolbase never imports the SDK itself — it reaches it only through `orchestral.mcp` — so the major orchestral targets is the major toolbase needs, and the two bounds only make sense as a pair. orchestral 1.10 is a clean port to the 2.x API with no 1.x compatibility path and refuses to start against an older SDK; conversely orchestral <1.10 is built on the decorator API (`Server.list_tools` / `Server.call_tool`) that 2.0 removed. Since orchestral-ai declares no `mcp` constraint of its own, pinning both ends is what keeps pip off a mismatched pair.
|
|
16
|
+
|
|
17
|
+
**Existing toolkit venvs were built against mcp 1.x and need `tb install <toolkit> --rebuild`** to pick up the new pair; until then their hosts fail at startup with `'Server' object has no attribute 'list_tools'`, surfacing as `mcp connect failed: unhandled errors in a TaskGroup`.
|
|
18
|
+
|
|
19
|
+
- Toolkit validation now names `orchestral-ai>=1.10.0` as the floor a toolkit's `requirements.txt` should declare. The check itself is unchanged (still presence-only, not a version comparison).
|
|
20
|
+
|
|
21
|
+
## [0.8.1] — 2026-07-27
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **`tb connect --abspath` no longer silently falls back to a bare command.** It resolved the binary with `shutil.which("toolbase")`, which returns `None` exactly when toolbase isn't on PATH at connect time (a venv/conda install, or toolbase invoked by absolute path) — the very case `--abspath` exists for — so it quietly wrote a bare `toolbase` that the harness then couldn't launch. It now resolves the toolbase beside the running interpreter first (`sys.executable`'s dir), falling back to `which` then bare.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **`tb connect` command default is now scope-aware.** User-scope connects (`-g`, a machine-local config that is never committed) default to the **absolute** toolbase path so the harness always finds it — important because a harness process (e.g. a GUI app, or a shell without your env activated) often doesn't have a venv/conda `bin` on PATH. Project-scope connects (git-committed, shared) stay **bare** `toolbase` for portability, and now print a note when toolbase is env-installed that a bare command may not resolve for the harness (suggesting `--abspath`, `-g`, or a login-PATH install). New `--portable` flag forces the bare command in any scope; `--abspath` still forces the absolute path.
|
|
30
|
+
|
|
11
31
|
## [0.8.0] — 2026-07-27
|
|
12
32
|
|
|
13
33
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: toolbase
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: The community registry and CLI for AI agent toolkits - discover, share, and serve tools to AI agents over MCP
|
|
5
5
|
Author-email: Alex Roman <toolbase.dev@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -27,8 +27,8 @@ Requires-Dist: ruamel.yaml>=0.18
|
|
|
27
27
|
Requires-Dist: rich>=13.0
|
|
28
28
|
Requires-Dist: pydantic>=2.0
|
|
29
29
|
Requires-Dist: email-validator>=2.0
|
|
30
|
-
Requires-Dist: orchestral-ai>=1.
|
|
31
|
-
Requires-Dist: mcp>=
|
|
30
|
+
Requires-Dist: orchestral-ai>=1.10
|
|
31
|
+
Requires-Dist: mcp>=2
|
|
32
32
|
Requires-Dist: tomlkit>=0.12
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "toolbase"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.9.0"
|
|
8
8
|
description = "The community registry and CLI for AI agent toolkits - discover, share, and serve tools to AI agents over MCP"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -36,10 +36,23 @@ dependencies = [
|
|
|
36
36
|
"pydantic>=2.0",
|
|
37
37
|
# Required by Pydantic's EmailStr at runtime; not imported directly.
|
|
38
38
|
"email-validator>=2.0",
|
|
39
|
-
# 1.4 introduced the `state=[...]` decorator argument that the
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
"
|
|
39
|
+
# 1.4 introduced the `state=[...]` decorator argument that the Phase 3C-1
|
|
40
|
+
# setup system relies on for state-field declaration; 1.10 is the first
|
|
41
|
+
# release whose orchestral.mcp is built on MCP SDK 2.x.
|
|
42
|
+
"orchestral-ai>=1.10",
|
|
43
|
+
# We never import the SDK ourselves — the host reaches it only through
|
|
44
|
+
# `orchestral.mcp` — so the major orchestral targets is the major we need,
|
|
45
|
+
# and these two bounds only make sense as a pair. orchestral >=1.10 ported
|
|
46
|
+
# to 2.x with no 1.x compatibility path and refuses to start against an
|
|
47
|
+
# older SDK; orchestral <1.10 is built on the decorator API
|
|
48
|
+
# (`Server.list_tools` / `Server.call_tool`) that 2.0 removed, and dies at
|
|
49
|
+
# startup with `'Server' object has no attribute 'list_tools'` — which
|
|
50
|
+
# reaches the user only as `mcp connect failed: unhandled errors in a
|
|
51
|
+
# TaskGroup`. orchestral-ai declares no mcp constraint of its own, so
|
|
52
|
+
# nothing but this pin keeps pip off a mismatched pair.
|
|
53
|
+
# Keep in sync with HOST_RUNTIME_REQUIREMENTS in cli.py, which applies the
|
|
54
|
+
# same pair to each toolkit's venv.
|
|
55
|
+
"mcp>=2",
|
|
43
56
|
# Round-trips ~/.codex/config.toml for `tb connect codex` while preserving
|
|
44
57
|
# the user's comments + formatting. The stdlib only reads TOML (tomllib);
|
|
45
58
|
# tomlkit is the writer (same role ruamel.yaml plays for our YAML).
|
|
@@ -25,6 +25,29 @@ from .config import _api_url
|
|
|
25
25
|
console = Console()
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
# The runtime every per-toolkit venv needs so ``toolbase._toolkit_host`` can
|
|
29
|
+
# start inside it: orchestral supplies ``@define_tool`` and the tool plumbing,
|
|
30
|
+
# mcp is the wire the host speaks to the orchestrator.
|
|
31
|
+
#
|
|
32
|
+
# Both bounds are load-bearing, not cosmetic, and they have to move as a pair.
|
|
33
|
+
# ``orchestral-ai`` declares no mcp constraint of its own, so pip is free to
|
|
34
|
+
# pick a combination neither side supports:
|
|
35
|
+
#
|
|
36
|
+
# * orchestral <1.10 is written against MCP SDK 1.x. With mcp 2.x resolved,
|
|
37
|
+
# the host dies at startup with `'Server' object has no attribute
|
|
38
|
+
# 'list_tools'` (2.0 dropped the decorator API), which the orchestrator can
|
|
39
|
+
# only report as the opaque `mcp connect failed: unhandled errors in a
|
|
40
|
+
# TaskGroup`.
|
|
41
|
+
# * orchestral >=1.10 is a clean port to 2.x with no 1.x compatibility path.
|
|
42
|
+
# Paired with mcp 1.x its ``_check_mcp_installed`` refuses to start.
|
|
43
|
+
#
|
|
44
|
+
# Either way the venv is born broken and the failure has nothing to do with
|
|
45
|
+
# what the user was doing. Pinning both ends is what keeps that from happening.
|
|
46
|
+
#
|
|
47
|
+
# Keep in sync with the ``orchestral-ai`` and ``mcp`` pins in pyproject.toml.
|
|
48
|
+
HOST_RUNTIME_REQUIREMENTS = ["orchestral-ai>=1.10", "mcp>=2"]
|
|
49
|
+
|
|
50
|
+
|
|
28
51
|
# ── Agent-friendliness: --yes / --no / --no-input across all commands ──────
|
|
29
52
|
#
|
|
30
53
|
# Per STATUS.md §"Named principles" (flag-equivalence) and the Tier-1 polish
|
|
@@ -3221,11 +3244,10 @@ def setup_venv_environment(
|
|
|
3221
3244
|
)
|
|
3222
3245
|
console.print("[green]✓ Bundle dependencies installed[/green]")
|
|
3223
3246
|
|
|
3224
|
-
# Install orchestral
|
|
3225
|
-
#
|
|
3226
|
-
# subprocess (toolbase serve's host) uses to expose tools over HTTP.
|
|
3247
|
+
# Install the host runtime (orchestral + a compatible mcp) into the venv.
|
|
3248
|
+
# See HOST_RUNTIME_REQUIREMENTS for why the mcp bound matters.
|
|
3227
3249
|
_run_pip_with_progress(
|
|
3228
|
-
[str(pip_path), 'install',
|
|
3250
|
+
[str(pip_path), 'install', *HOST_RUNTIME_REQUIREMENTS],
|
|
3229
3251
|
console,
|
|
3230
3252
|
"Installing orchestral-ai and mcp",
|
|
3231
3253
|
)
|
|
@@ -3351,7 +3373,7 @@ def setup_conda_environment(
|
|
|
3351
3373
|
try:
|
|
3352
3374
|
_run_pip_with_progress(
|
|
3353
3375
|
[conda_cmd, 'run', '-n', env_name, 'pip', 'install',
|
|
3354
|
-
|
|
3376
|
+
*HOST_RUNTIME_REQUIREMENTS],
|
|
3355
3377
|
console,
|
|
3356
3378
|
f"Installing orchestral + mcp in '{env_name}'",
|
|
3357
3379
|
)
|
|
@@ -6830,18 +6852,66 @@ def _resolve_connect_scope(global_scope: bool, local_scope: bool):
|
|
|
6830
6852
|
return "project", root
|
|
6831
6853
|
|
|
6832
6854
|
|
|
6833
|
-
def
|
|
6834
|
-
"""
|
|
6855
|
+
def _toolbase_abspath() -> str:
|
|
6856
|
+
"""Absolute path of the *running* toolbase binary.
|
|
6835
6857
|
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6858
|
+
A harness launches the MCP server by exec'ing this command against its
|
|
6859
|
+
own process PATH — which for a venv/conda install often does not include
|
|
6860
|
+
the env's ``bin``, so a bare ``toolbase`` fails to launch. The absolute
|
|
6861
|
+
path is PATH-independent.
|
|
6862
|
+
|
|
6863
|
+
Resolution prefers the ``toolbase`` beside the running interpreter
|
|
6864
|
+
(``sys.executable``'s ``bin/`` — where a console-script entry point
|
|
6865
|
+
lives, i.e. *this* toolbase), because ``shutil.which`` returns ``None``
|
|
6866
|
+
when toolbase isn't on the PATH at connect time (exactly the case that
|
|
6867
|
+
needs an absolute path). Falls back to ``which`` then bare.
|
|
6839
6868
|
"""
|
|
6840
|
-
if not abspath:
|
|
6841
|
-
return "toolbase"
|
|
6842
6869
|
import shutil
|
|
6843
|
-
|
|
6844
|
-
|
|
6870
|
+
bindir = Path(sys.executable).parent
|
|
6871
|
+
for cand in (bindir / "toolbase", bindir / "toolbase.exe"):
|
|
6872
|
+
if cand.exists():
|
|
6873
|
+
return str(cand)
|
|
6874
|
+
return shutil.which("toolbase") or "toolbase"
|
|
6875
|
+
|
|
6876
|
+
|
|
6877
|
+
def _toolbase_is_env_installed() -> bool:
|
|
6878
|
+
"""True when toolbase runs from an isolated env whose ``bin`` a harness
|
|
6879
|
+
process likely won't have on PATH — a venv/virtualenv, or a *named*
|
|
6880
|
+
(non-base) conda env. Used to warn before writing a bare command that
|
|
6881
|
+
may not resolve for the harness."""
|
|
6882
|
+
if sys.prefix != getattr(sys, "base_prefix", sys.prefix):
|
|
6883
|
+
return True # venv / virtualenv
|
|
6884
|
+
conda_env = os.environ.get("CONDA_DEFAULT_ENV")
|
|
6885
|
+
return bool(conda_env) and conda_env != "base" # named conda env
|
|
6886
|
+
|
|
6887
|
+
|
|
6888
|
+
def _resolve_connect_command(*, abspath: bool, portable: bool, scope: str) -> str:
|
|
6889
|
+
"""The command string to write into the harness's config, scope-aware.
|
|
6890
|
+
|
|
6891
|
+
Default optimizes for the config's shareability: ``user`` scope (``-g``,
|
|
6892
|
+
a machine-local config that is never committed) writes the absolute path
|
|
6893
|
+
so the harness always finds it; ``project`` scope (git-committed, shared)
|
|
6894
|
+
stays bare ``toolbase`` for portability across machines. ``--abspath``
|
|
6895
|
+
forces the absolute path in any scope; ``--portable`` forces bare. On a
|
|
6896
|
+
project-scope bare write from an isolated env, warn that the harness may
|
|
6897
|
+
not resolve a bare command."""
|
|
6898
|
+
if abspath and portable:
|
|
6899
|
+
raise click.UsageError("--abspath and --portable are mutually exclusive.")
|
|
6900
|
+
use_abspath = abspath or (not portable and scope == "user")
|
|
6901
|
+
if use_abspath:
|
|
6902
|
+
return _toolbase_abspath()
|
|
6903
|
+
if scope != "user" and _toolbase_is_env_installed():
|
|
6904
|
+
console.print(
|
|
6905
|
+
"[yellow]Note:[/yellow] wrote a bare [cyan]toolbase[/cyan] (portable). "
|
|
6906
|
+
"The harness resolves it against its own PATH, and toolbase lives in "
|
|
6907
|
+
"an isolated env — so a harness launched outside that env (a desktop "
|
|
6908
|
+
"app, or a terminal without the env active) won't find it and the MCP "
|
|
6909
|
+
"server will show as failed. Fixes: reconnect with [cyan]--abspath[/cyan] "
|
|
6910
|
+
"(machine-specific path), use [cyan]-g[/cyan] (user scope uses the "
|
|
6911
|
+
"absolute path by default), or put toolbase on your login PATH "
|
|
6912
|
+
"(e.g. [cyan]pipx install toolbase[/cyan]) to keep it bare and portable."
|
|
6913
|
+
)
|
|
6914
|
+
return "toolbase"
|
|
6845
6915
|
|
|
6846
6916
|
|
|
6847
6917
|
def _activated_toolkit_dirs() -> "dict[str, Path]":
|
|
@@ -6956,21 +7026,25 @@ def _unsurface_skills_for_connect(adapter) -> None:
|
|
|
6956
7026
|
@click.option('--dry-run', 'dry_run', is_flag=True, default=False,
|
|
6957
7027
|
help='Print the intended write without changing anything.')
|
|
6958
7028
|
@click.option('--abspath', 'abspath', is_flag=True, default=False,
|
|
6959
|
-
help='
|
|
7029
|
+
help='Force the absolute toolbase binary path (PATH-independent). '
|
|
7030
|
+
'Default for user scope (-g); project scope stays bare.')
|
|
7031
|
+
@click.option('--portable', 'portable', is_flag=True, default=False,
|
|
7032
|
+
help='Force the bare `toolbase` command (portable across machines) '
|
|
7033
|
+
'even for user scope.')
|
|
6960
7034
|
@click.option('--list', 'do_list', is_flag=True, default=False,
|
|
6961
7035
|
help='Show where toolbase is wired across harnesses, then exit.')
|
|
6962
7036
|
@click.option('--harnesses', 'do_harnesses', is_flag=True, default=False,
|
|
6963
7037
|
help='List supported harnesses and detection status, then exit.')
|
|
6964
7038
|
@click.option('--out', 'out_path', default=None, metavar='PATH',
|
|
6965
7039
|
help='(orchestral) Path for the generated agent script '
|
|
6966
|
-
'(default: .toolbase/
|
|
7040
|
+
'(default: .toolbase/agent.py).')
|
|
6967
7041
|
@click.option('--force', 'force', is_flag=True, default=False,
|
|
6968
7042
|
help='(orchestral) Overwrite an existing generated script.')
|
|
6969
7043
|
@click.option('--no-skills', 'no_skills', is_flag=True, default=False,
|
|
6970
7044
|
help="Don't surface the activated toolkits' skills into the "
|
|
6971
7045
|
"harness (wire the MCP server only).")
|
|
6972
7046
|
def connect(harness, global_scope, local_scope, profile_name, remove, dry_run,
|
|
6973
|
-
abspath, do_list, do_harnesses, out_path, force, no_skills):
|
|
7047
|
+
abspath, portable, do_list, do_harnesses, out_path, force, no_skills):
|
|
6974
7048
|
"""Wire toolbase into an agent harness.
|
|
6975
7049
|
|
|
6976
7050
|
\b
|
|
@@ -6984,8 +7058,8 @@ def connect(harness, global_scope, local_scope, profile_name, remove, dry_run,
|
|
|
6984
7058
|
tb connect claude-code -g # user: ~/.claude.json (every session)
|
|
6985
7059
|
tb connect claude-code --profile paper
|
|
6986
7060
|
tb connect claude-code --remove
|
|
6987
|
-
tb connect orchestral # write .toolbase/
|
|
6988
|
-
tb connect orchestral --profile paper --out
|
|
7061
|
+
tb connect orchestral # write .toolbase/agent.py
|
|
7062
|
+
tb connect orchestral --profile paper --out my_agent.py
|
|
6989
7063
|
tb connect --list # where is toolbase wired?
|
|
6990
7064
|
tb connect --harnesses # which harnesses are supported?
|
|
6991
7065
|
"""
|
|
@@ -7063,7 +7137,7 @@ def connect(harness, global_scope, local_scope, profile_name, remove, dry_run,
|
|
|
7063
7137
|
_unsurface_skills_for_connect(adapter)
|
|
7064
7138
|
return
|
|
7065
7139
|
|
|
7066
|
-
command =
|
|
7140
|
+
command = _resolve_connect_command(abspath=abspath, portable=portable, scope=scope)
|
|
7067
7141
|
try:
|
|
7068
7142
|
path = adapter.install(
|
|
7069
7143
|
scope=scope, project_root=project_root, server_name="toolbase",
|
|
@@ -7166,32 +7240,75 @@ def _connect_print_status(adapters, project_root) -> None:
|
|
|
7166
7240
|
)
|
|
7167
7241
|
|
|
7168
7242
|
|
|
7169
|
-
def _orchestral_script_path(out=None):
|
|
7243
|
+
def _orchestral_script_path(out=None, *, accept_legacy=False):
|
|
7170
7244
|
"""Resolve the orchestral launcher path: ``--out`` if given, else
|
|
7171
|
-
``<project-root>/.toolbase/
|
|
7172
|
-
up from the cwd; falls back to the cwd when not in a project).
|
|
7245
|
+
``<project-root>/.toolbase/agent.py`` (project discovered by walking
|
|
7246
|
+
up from the cwd; falls back to the cwd when not in a project).
|
|
7247
|
+
|
|
7248
|
+
``accept_legacy`` is for the read side (``tb orchestral``, ``--remove``):
|
|
7249
|
+
when the current default doesn't exist but an older
|
|
7250
|
+
``.toolbase/orchestral.py`` does, return that instead so an existing
|
|
7251
|
+
checkout keeps working. The write side never uses it -- new scaffolds
|
|
7252
|
+
always take the current name (the legacy one shadows the ``orchestral``
|
|
7253
|
+
package; see ``connect/orchestral.py``).
|
|
7254
|
+
"""
|
|
7173
7255
|
from pathlib import Path as _Path
|
|
7174
|
-
from .connect.orchestral import DEFAULT_SCRIPT_NAME
|
|
7256
|
+
from .connect.orchestral import DEFAULT_SCRIPT_NAME, LEGACY_SCRIPT_NAME
|
|
7175
7257
|
from .envs import find_project_root
|
|
7176
7258
|
|
|
7177
7259
|
if out:
|
|
7178
7260
|
return _Path(out)
|
|
7179
7261
|
root = find_project_root() or _Path.cwd()
|
|
7180
|
-
|
|
7262
|
+
path = root / ".toolbase" / DEFAULT_SCRIPT_NAME
|
|
7263
|
+
if accept_legacy and not path.exists():
|
|
7264
|
+
legacy = root / ".toolbase" / LEGACY_SCRIPT_NAME
|
|
7265
|
+
if legacy.exists():
|
|
7266
|
+
return legacy
|
|
7267
|
+
return path
|
|
7268
|
+
|
|
7269
|
+
|
|
7270
|
+
def _warn_if_profile_selects_nothing(profile_name) -> None:
|
|
7271
|
+
"""Warn at connect time if the profile the scaffold will serve is empty.
|
|
7272
|
+
|
|
7273
|
+
Without this the user only finds out at launch, as a bare
|
|
7274
|
+
``RuntimeError: no toolkits could be started`` from deep inside the
|
|
7275
|
+
orchestrator. Best-effort: an unresolvable profile is not a reason to
|
|
7276
|
+
refuse to write the scaffold, so any failure here is silent.
|
|
7277
|
+
"""
|
|
7278
|
+
from pathlib import Path as _Path
|
|
7279
|
+
from .envs import find_project_root
|
|
7280
|
+
from .serve.profiles import resolve_profile
|
|
7281
|
+
|
|
7282
|
+
try:
|
|
7283
|
+
root = find_project_root() or _Path.cwd()
|
|
7284
|
+
profile = resolve_profile(root, cli_profile=profile_name)
|
|
7285
|
+
except Exception:
|
|
7286
|
+
return
|
|
7287
|
+
if profile.toolkits:
|
|
7288
|
+
return
|
|
7289
|
+
console.print(
|
|
7290
|
+
f"[yellow]Note: profile '{profile.name}' currently serves no "
|
|
7291
|
+
"toolkits[/yellow] — the agent would start with zero tools."
|
|
7292
|
+
)
|
|
7293
|
+
console.print(
|
|
7294
|
+
" [dim]Activate one with[/dim] [cyan]tb activate <toolkit>[/cyan]"
|
|
7295
|
+
"[dim], then check with[/dim] [cyan]tb serve --dry-run[/cyan][dim].[/dim]"
|
|
7296
|
+
)
|
|
7181
7297
|
|
|
7182
7298
|
|
|
7183
7299
|
def _connect_orchestral(*, profile_name, out, force, dry_run, remove) -> None:
|
|
7184
7300
|
"""Handle `tb connect orchestral`: write (or remove) a runnable agent
|
|
7185
|
-
script at ``<project>/.toolbase/
|
|
7301
|
+
script at ``<project>/.toolbase/agent.py``. Orchestral is a library
|
|
7186
7302
|
harness, not a config-file one, so "connecting" means scaffolding the code
|
|
7187
7303
|
that hands toolbase's tools to an orchestral Agent -- the user owns the
|
|
7188
7304
|
agent (LLM, prompt, launch modality). Launch it with `tb orchestral`.
|
|
7189
7305
|
"""
|
|
7190
7306
|
from .connect.orchestral import (
|
|
7191
7307
|
agent_script, is_orchestral_available, GENERATED_MARKER,
|
|
7308
|
+
LEGACY_SCRIPT_NAME,
|
|
7192
7309
|
)
|
|
7193
7310
|
|
|
7194
|
-
path = _orchestral_script_path(out)
|
|
7311
|
+
path = _orchestral_script_path(out, accept_legacy=remove)
|
|
7195
7312
|
|
|
7196
7313
|
if remove:
|
|
7197
7314
|
if not path.exists():
|
|
@@ -7228,11 +7345,37 @@ def _connect_orchestral(*, profile_name, out, force, dry_run, remove) -> None:
|
|
|
7228
7345
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
7229
7346
|
path.write_text(content, encoding="utf-8")
|
|
7230
7347
|
console.print(f"[green]✓[/green] Wrote orchestral agent scaffold to {path}.")
|
|
7348
|
+
|
|
7349
|
+
# A scaffold from 0.8.1 or earlier next to the new one is not just
|
|
7350
|
+
# clutter: it is named `orchestral.py`, sits in the same directory, and
|
|
7351
|
+
# that directory heads `sys.path` at launch -- so it shadows the
|
|
7352
|
+
# `orchestral` package the new script imports. Retire it (marker-checked,
|
|
7353
|
+
# same rule as --remove).
|
|
7354
|
+
legacy = path.parent / LEGACY_SCRIPT_NAME
|
|
7355
|
+
if legacy.exists() and legacy != path:
|
|
7356
|
+
try:
|
|
7357
|
+
first = legacy.read_text(encoding="utf-8").split("\n", 1)[0]
|
|
7358
|
+
except OSError:
|
|
7359
|
+
first = ""
|
|
7360
|
+
if first.startswith(GENERATED_MARKER):
|
|
7361
|
+
legacy.unlink()
|
|
7362
|
+
console.print(
|
|
7363
|
+
f" [dim]Removed the superseded {legacy.name} (it shadowed "
|
|
7364
|
+
"the orchestral package).[/dim]"
|
|
7365
|
+
)
|
|
7366
|
+
else:
|
|
7367
|
+
console.print(
|
|
7368
|
+
f"[yellow]Warning: {legacy} is not toolbase-generated, so it "
|
|
7369
|
+
"was left alone — but it shadows the orchestral package and "
|
|
7370
|
+
"will break this script. Rename it.[/yellow]"
|
|
7371
|
+
)
|
|
7372
|
+
|
|
7231
7373
|
if not is_orchestral_available():
|
|
7232
7374
|
console.print(
|
|
7233
7375
|
"[yellow]Note: the orchestral package isn't importable here; "
|
|
7234
7376
|
"the script needs it (and an LLM API key) at runtime.[/yellow]"
|
|
7235
7377
|
)
|
|
7378
|
+
_warn_if_profile_selects_nothing(profile_name)
|
|
7236
7379
|
console.print(
|
|
7237
7380
|
"[dim]Configure orchestral (LLM + API key), then launch with "
|
|
7238
7381
|
"[cyan]tb orchestral[/cyan].[/dim]"
|
|
@@ -7304,28 +7447,44 @@ def disconnect(harness, global_scope, local_scope, all_scopes):
|
|
|
7304
7447
|
|
|
7305
7448
|
@main.command()
|
|
7306
7449
|
@click.option('--script', 'script', default=None, metavar='PATH',
|
|
7307
|
-
help='Path to the agent script (default: .toolbase/
|
|
7450
|
+
help='Path to the agent script (default: .toolbase/agent.py).')
|
|
7308
7451
|
def orchestral(script):
|
|
7309
7452
|
"""Launch your orchestral agent script (the one `tb connect orchestral`
|
|
7310
|
-
wrote). This just runs `python .toolbase/
|
|
7453
|
+
wrote). This just runs `python .toolbase/agent.py` -- the script owns
|
|
7311
7454
|
the agent (LLM, prompt, launch modality); toolbase only runs it.
|
|
7312
7455
|
|
|
7313
7456
|
\b
|
|
7314
7457
|
Examples:
|
|
7315
|
-
tb connect orchestral # scaffold .toolbase/
|
|
7458
|
+
tb connect orchestral # scaffold .toolbase/agent.py
|
|
7316
7459
|
tb orchestral # run it
|
|
7317
7460
|
"""
|
|
7318
7461
|
import subprocess
|
|
7319
7462
|
from pathlib import Path as _Path
|
|
7320
7463
|
from .envs import find_project_root
|
|
7321
7464
|
|
|
7322
|
-
|
|
7465
|
+
from .connect.orchestral import LEGACY_SCRIPT_NAME
|
|
7466
|
+
|
|
7467
|
+
path = _orchestral_script_path(script, accept_legacy=True)
|
|
7323
7468
|
if not path.exists():
|
|
7324
7469
|
console.print(
|
|
7325
7470
|
f"[red]No agent script at {path}.[/red] Create one with "
|
|
7326
7471
|
"[cyan]tb connect orchestral[/cyan] first."
|
|
7327
7472
|
)
|
|
7328
7473
|
sys.exit(1)
|
|
7474
|
+
if path.name == LEGACY_SCRIPT_NAME:
|
|
7475
|
+
# Older scaffold: its own directory heads sys.path at launch, so the
|
|
7476
|
+
# file shadows the `orchestral` package it imports and the run dies
|
|
7477
|
+
# on `from orchestral import Agent`. Say so before it happens.
|
|
7478
|
+
console.print(
|
|
7479
|
+
f"[yellow]{path} is an older scaffold whose filename shadows the "
|
|
7480
|
+
"orchestral package; it cannot import it.[/yellow]"
|
|
7481
|
+
)
|
|
7482
|
+
console.print(
|
|
7483
|
+
" [dim]Re-scaffold with[/dim] [cyan]tb connect orchestral "
|
|
7484
|
+
"--force[/cyan][dim] (your old file is removed) or copy your "
|
|
7485
|
+
"edits into .toolbase/agent.py.[/dim]"
|
|
7486
|
+
)
|
|
7487
|
+
sys.exit(1)
|
|
7329
7488
|
# Run with the interpreter toolbase runs under (toolbase + orchestral live
|
|
7330
7489
|
# there), cwd = the project root so the script resolves the active profile
|
|
7331
7490
|
# and orchestral persists its conversation under the project.
|
|
@@ -43,8 +43,16 @@ from ..serve.orchestrator import DEFAULT_CALL_TIMEOUT_S, Orchestrator
|
|
|
43
43
|
# The scaffold ``tb connect orchestral`` writes, relative to a project root.
|
|
44
44
|
# It lives under ``.toolbase/`` (alongside manifest.yaml / serve.yaml) and is
|
|
45
45
|
# launched by ``tb orchestral``.
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
#
|
|
47
|
+
# NOT named ``orchestral.py``: Python puts a script's own directory at the
|
|
48
|
+
# head of ``sys.path``, so a file by that name shadows the ``orchestral``
|
|
49
|
+
# package it imports and every launch dies with "cannot import name 'Agent'
|
|
50
|
+
# from partially initialized module 'orchestral'". That was the 0.8.1 and
|
|
51
|
+
# earlier default; ``LEGACY_SCRIPT_NAME`` exists so the runner and
|
|
52
|
+
# ``--remove`` still find those files.
|
|
53
|
+
DEFAULT_SCRIPT_NAME = "agent.py"
|
|
54
|
+
DEFAULT_SCRIPT_RELPATH = ".toolbase/agent.py"
|
|
55
|
+
LEGACY_SCRIPT_NAME = "orchestral.py"
|
|
48
56
|
|
|
49
57
|
# First line of every generated scaffold. ``tb connect orchestral --remove``
|
|
50
58
|
# only deletes a file carrying this marker, so it never removes a script the
|
|
@@ -183,10 +191,23 @@ def agent_script(profile: Optional[str] = None) -> str:
|
|
|
183
191
|
launch modalities -- terminal UI, headless, web GUI -- with the terminal
|
|
184
192
|
UI active and the other two commented out. The user edits to switch.
|
|
185
193
|
|
|
194
|
+
Two things the scaffold does deliberately, because getting them wrong is
|
|
195
|
+
the difference between a working agent and a confusing one:
|
|
196
|
+
|
|
197
|
+
- **One workspace.** A single ``WORKSPACE`` dir is passed to
|
|
198
|
+
``toolbase_tools(config_overrides=...)`` *and* to orchestral's own file
|
|
199
|
+
tools, so every tool resolves relative paths against the same root.
|
|
200
|
+
Without it, toolbase-served tools write wherever
|
|
201
|
+
``~/.toolbase/config/<toolkit>.yaml`` points and the agent cannot read
|
|
202
|
+
back its own output.
|
|
203
|
+
- **File tools.** Served toolkits are domain tools; on their own the agent
|
|
204
|
+
has no way to open the files they produce. The scaffold pairs them with
|
|
205
|
+
orchestral's read/write/edit/search/run tools, all scoped to WORKSPACE.
|
|
206
|
+
|
|
186
207
|
Configuring orchestral (the LLM, API keys) is the user's job; the scaffold
|
|
187
208
|
just shows where their LLM plugs in.
|
|
188
209
|
"""
|
|
189
|
-
profile_arg = f'profile="{profile}"' if profile else ""
|
|
210
|
+
profile_arg = f'profile="{profile}", ' if profile else ""
|
|
190
211
|
profile_note = (
|
|
191
212
|
f'serving the "{profile}" profile'
|
|
192
213
|
if profile
|
|
@@ -201,16 +222,57 @@ def agent_script(profile: Optional[str] = None) -> str:
|
|
|
201
222
|
# Run it: tb orchestral (or: python {DEFAULT_SCRIPT_RELPATH})
|
|
202
223
|
"""Launch an orchestral agent wired with your toolbase tools."""
|
|
203
224
|
|
|
204
|
-
|
|
225
|
+
import os
|
|
226
|
+
import sys
|
|
227
|
+
from pathlib import Path
|
|
228
|
+
|
|
229
|
+
# Python puts this script's own directory at the head of `sys.path`, so a
|
|
230
|
+
# sibling module named after a package we import (`orchestral.py`, say) would
|
|
231
|
+
# shadow the real package. Demote our directory to the end: site-packages wins,
|
|
232
|
+
# but local imports still resolve. Drop these lines if you move this script
|
|
233
|
+
# somewhere its directory must take import priority.
|
|
234
|
+
_here = os.path.dirname(os.path.abspath(__file__))
|
|
235
|
+
if sys.path and os.path.abspath(sys.path[0] or ".") == _here:
|
|
236
|
+
sys.path.append(sys.path.pop(0))
|
|
237
|
+
|
|
205
238
|
from orchestral import Agent
|
|
206
239
|
from orchestral.llm import Claude # swap for GPT, Gemini, ... as you like
|
|
240
|
+
from orchestral.tools import (
|
|
241
|
+
EditFileTool, FileSearchTool, FindFilesTool, ReadFileTool,
|
|
242
|
+
RunCommandTool, RunPythonTool, WriteFileTool,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
from toolbase.connect.orchestral import toolbase_tools
|
|
246
|
+
|
|
247
|
+
# The one directory every tool works in -- both the toolbase-served toolkits
|
|
248
|
+
# and the orchestral file tools below. Keeping them on the same root is what
|
|
249
|
+
# lets the agent read back the files its own tools write. Point it anywhere.
|
|
250
|
+
WORKSPACE = Path(__file__).resolve().parent.parent / "workspace"
|
|
207
251
|
|
|
208
252
|
|
|
209
253
|
def main():
|
|
254
|
+
WORKSPACE.mkdir(parents=True, exist_ok=True)
|
|
255
|
+
|
|
210
256
|
# `toolbase_tools` spins up one subprocess per served toolkit ({profile_note})
|
|
211
257
|
# and yields the tools as orchestral BaseTool instances. They are torn
|
|
212
|
-
# down when the `with` block exits.
|
|
213
|
-
|
|
258
|
+
# down when the `with` block exits. `config_overrides` scopes every served
|
|
259
|
+
# toolkit to WORKSPACE, overriding the `base_directory` in
|
|
260
|
+
# ~/.toolbase/config/<toolkit>.yaml for this run only.
|
|
261
|
+
with toolbase_tools(
|
|
262
|
+
{profile_arg}config_overrides={{"base_directory": str(WORKSPACE)}},
|
|
263
|
+
) as served:
|
|
264
|
+
tools = [
|
|
265
|
+
# General-purpose tools, scoped to the same workspace.
|
|
266
|
+
ReadFileTool(base_directory=str(WORKSPACE), show_line_numbers=True),
|
|
267
|
+
WriteFileTool(base_directory=str(WORKSPACE)),
|
|
268
|
+
EditFileTool(base_directory=str(WORKSPACE)),
|
|
269
|
+
FindFilesTool(base_directory=str(WORKSPACE)),
|
|
270
|
+
FileSearchTool(base_directory=str(WORKSPACE)),
|
|
271
|
+
RunCommandTool(base_directory=str(WORKSPACE)),
|
|
272
|
+
RunPythonTool(base_directory=str(WORKSPACE)),
|
|
273
|
+
# Your toolbase toolkits.
|
|
274
|
+
*served,
|
|
275
|
+
]
|
|
214
276
|
agent = Agent(llm=Claude(), tools=tools)
|
|
215
277
|
|
|
216
278
|
# -- Pick a launch modality: one is active, the others are commented. --
|
|
@@ -238,5 +300,6 @@ __all__ = [
|
|
|
238
300
|
"is_orchestral_available",
|
|
239
301
|
"DEFAULT_SCRIPT_NAME",
|
|
240
302
|
"DEFAULT_SCRIPT_RELPATH",
|
|
303
|
+
"LEGACY_SCRIPT_NAME",
|
|
241
304
|
"GENERATED_MARKER",
|
|
242
305
|
]
|
|
@@ -50,7 +50,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
|
50
50
|
|
|
51
51
|
from rich.console import Console
|
|
52
52
|
|
|
53
|
-
from ..config import LOGS_DIR, TOOLKITS_DIR
|
|
53
|
+
from ..config import CONFIG_DIR, LOGS_DIR, TOOLKITS_DIR
|
|
54
54
|
from ..envs.cache import LEGACY_META_FILE
|
|
55
55
|
from ..logging.logger import ToolLogger, get_logger
|
|
56
56
|
|
|
@@ -326,6 +326,7 @@ def _legacy_discover_toolkits(toolkits_dir: Path) -> List[ToolkitDiscovery]:
|
|
|
326
326
|
|
|
327
327
|
def _resolve_state_config(
|
|
328
328
|
disc: ToolkitDiscovery,
|
|
329
|
+
overrides: Optional[Dict[str, Any]] = None,
|
|
329
330
|
) -> Tuple[Optional[Dict[str, Any]], Optional[str]]:
|
|
330
331
|
"""Validate the toolkit's stored config against its declared schema.
|
|
331
332
|
|
|
@@ -339,6 +340,13 @@ def _resolve_state_config(
|
|
|
339
340
|
user hasn't filled in, or stored values fail validation. The
|
|
340
341
|
orchestrator skips this toolkit with ``reason`` in the banner.
|
|
341
342
|
|
|
343
|
+
``overrides`` is the embedder's ``config_overrides`` (see
|
|
344
|
+
``Orchestrator.__init__``). A field the embedder supplies counts as
|
|
345
|
+
filled in: it satisfies a required field and clears a stored-but-
|
|
346
|
+
invalid one, because the override is what the host will actually
|
|
347
|
+
receive. Without this a caller could pass the exact value a toolkit
|
|
348
|
+
demands and still watch it get skipped for lacking that value.
|
|
349
|
+
|
|
342
350
|
Imports the setup module lazily so a malformed ``config:`` block
|
|
343
351
|
in some other toolkit can't take down the whole orchestrator
|
|
344
352
|
startup. Per-toolkit failures stay per-toolkit.
|
|
@@ -388,6 +396,17 @@ def _resolve_state_config(
|
|
|
388
396
|
resolution = load_state_config(
|
|
389
397
|
disc.name, schema, project_root=project_root,
|
|
390
398
|
)
|
|
399
|
+
if overrides:
|
|
400
|
+
# Anything the embedder supplies is going to reach the host, so
|
|
401
|
+
# it can't also be "missing" or "invalid". Drop those complaints
|
|
402
|
+
# before the go/no-go check.
|
|
403
|
+
supplied = set(overrides)
|
|
404
|
+
resolution.missing_required = [
|
|
405
|
+
n for n in resolution.missing_required if n not in supplied
|
|
406
|
+
]
|
|
407
|
+
resolution.invalid = [
|
|
408
|
+
(n, e) for (n, e) in resolution.invalid if n not in supplied
|
|
409
|
+
]
|
|
391
410
|
if not resolution.ok:
|
|
392
411
|
return None, "config incomplete — " + (resolution.skip_reason() or "unknown")
|
|
393
412
|
state_config = dict(resolution.state_config)
|
|
@@ -584,6 +603,7 @@ def _tool_yaml_name_to_mcp_name(class_name: str) -> str:
|
|
|
584
603
|
|
|
585
604
|
def _resolve_bundle_availability(
|
|
586
605
|
disc: "ToolkitDiscovery",
|
|
606
|
+
overrides: Optional[Dict[str, Any]] = None,
|
|
587
607
|
) -> Tuple[Any, Dict[str, List[str]]]:
|
|
588
608
|
"""Evaluate this toolkit's ``bundles:`` against its resolved config.
|
|
589
609
|
|
|
@@ -599,6 +619,12 @@ def _resolve_bundle_availability(
|
|
|
599
619
|
VALUE>`` sentinel counts as unset, matching the existing
|
|
600
620
|
state-config gate semantics one level up.
|
|
601
621
|
|
|
622
|
+
``overrides`` (the embedder's ``config_overrides``) is merged last,
|
|
623
|
+
for the same reason the state-config gate honors it: a bundle whose
|
|
624
|
+
``requires:`` key the embedder supplies in-process is satisfied, so
|
|
625
|
+
gating it on the stored file alone would hide tools the caller just
|
|
626
|
+
configured.
|
|
627
|
+
|
|
602
628
|
On any read failure (no toolkit.yaml, malformed file, etc.),
|
|
603
629
|
returns an empty availability that gates nothing — pass-through
|
|
604
630
|
behavior so a broken yaml doesn't take down all toolkits.
|
|
@@ -632,6 +658,9 @@ def _resolve_bundle_availability(
|
|
|
632
658
|
# startup over a config-resolution glitch.
|
|
633
659
|
resolved_config = {}
|
|
634
660
|
|
|
661
|
+
if overrides:
|
|
662
|
+
resolved_config = {**resolved_config, **overrides}
|
|
663
|
+
|
|
635
664
|
availability = evaluate_bundles(bundles_block, resolved_config)
|
|
636
665
|
return availability, name_to_bundles
|
|
637
666
|
|
|
@@ -738,6 +767,73 @@ def _strip_caller_env_activation(env: Dict[str, str]) -> Dict[str, str]:
|
|
|
738
767
|
return env
|
|
739
768
|
|
|
740
769
|
|
|
770
|
+
def _toolbase_package_dir() -> Path:
|
|
771
|
+
"""Absolute path of the running ``toolbase`` package directory."""
|
|
772
|
+
import toolbase as _tb
|
|
773
|
+
_tb_file = getattr(_tb, "__file__", None)
|
|
774
|
+
if _tb_file:
|
|
775
|
+
return Path(_tb_file).resolve().parent
|
|
776
|
+
# Namespace-package / some editable layouts leave ``__file__`` None;
|
|
777
|
+
# ``__path__`` still points at the package dir.
|
|
778
|
+
return Path(next(iter(_tb.__path__))).resolve()
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
def _staged_toolbase_path() -> Optional[Path]:
|
|
782
|
+
"""Return a directory whose ONLY importable entry is ``toolbase``.
|
|
783
|
+
|
|
784
|
+
This is what the per-toolkit host gets on ``PYTHONPATH``, and the
|
|
785
|
+
"only" is the entire point. ``PYTHONPATH`` entries land ahead of the
|
|
786
|
+
toolkit venv's ``site-packages``, so handing over the directory that
|
|
787
|
+
merely *contains* toolbase means the whole serving environment
|
|
788
|
+
shadows the toolkit's own: under a normal (non-editable) install
|
|
789
|
+
that directory is ``site-packages``, and ``mcp``, ``numpy``,
|
|
790
|
+
``pydantic`` and ``orchestral`` all resolve to the orchestrator's
|
|
791
|
+
copies instead of the venv's. The per-toolkit venv then supplies only
|
|
792
|
+
what the serving env happens to lack and never wins a conflict --
|
|
793
|
+
which defeats the isolation the subprocess design exists to provide,
|
|
794
|
+
and makes a toolkit's behavior depend on whichever machine serves it.
|
|
795
|
+
|
|
796
|
+
A directory holding a single ``toolbase`` symlink gives the host what
|
|
797
|
+
it needs and nothing more. That is affordable because the host's
|
|
798
|
+
dependency footprint on the toolbase side is pure-Python and tiny:
|
|
799
|
+
``_toolkit_host`` imports the stdlib, ``orchestral``, and
|
|
800
|
+
``toolbase.naming`` (via ``toolbase/__init__``) -- no third-party
|
|
801
|
+
package. ``orchestral`` and ``mcp`` come from the venv, where
|
|
802
|
+
``tb install`` puts them on purpose.
|
|
803
|
+
|
|
804
|
+
Staged under ``~/.toolbase/hostpath/<hash of the package path>`` so
|
|
805
|
+
two toolbase installs (an editable checkout and a released one, say)
|
|
806
|
+
never collide. The symlink is revalidated on every call and replaced
|
|
807
|
+
atomically, so an upgraded or moved install self-heals.
|
|
808
|
+
|
|
809
|
+
Returns ``None`` if the staging directory can't be created (a
|
|
810
|
+
filesystem without symlinks, a read-only home); the caller then falls
|
|
811
|
+
back to the historical leaky-but-working behavior rather than failing
|
|
812
|
+
to serve.
|
|
813
|
+
"""
|
|
814
|
+
import hashlib
|
|
815
|
+
|
|
816
|
+
pkg_dir = _toolbase_package_dir()
|
|
817
|
+
key = hashlib.sha256(str(pkg_dir).encode("utf-8")).hexdigest()[:12]
|
|
818
|
+
stage = CONFIG_DIR / "hostpath" / key
|
|
819
|
+
link = stage / "toolbase"
|
|
820
|
+
try:
|
|
821
|
+
# Fast path: already staged and still pointing where we think.
|
|
822
|
+
if link.is_symlink() and Path(os.readlink(link)) == pkg_dir:
|
|
823
|
+
return stage
|
|
824
|
+
stage.mkdir(parents=True, exist_ok=True)
|
|
825
|
+
# Build beside the target and rename over it, so a concurrent serve
|
|
826
|
+
# either sees the old link or the new one -- never a missing one.
|
|
827
|
+
tmp = stage / f".toolbase.{os.getpid()}"
|
|
828
|
+
if tmp.is_symlink() or tmp.exists():
|
|
829
|
+
tmp.unlink()
|
|
830
|
+
tmp.symlink_to(pkg_dir, target_is_directory=True)
|
|
831
|
+
os.replace(tmp, link)
|
|
832
|
+
return stage
|
|
833
|
+
except (OSError, NotImplementedError):
|
|
834
|
+
return None
|
|
835
|
+
|
|
836
|
+
|
|
741
837
|
def _build_host_env(toolkit_path: Path, toolkit_name: str,
|
|
742
838
|
*, venv_bin: Optional[str] = None) -> Dict[str, str]:
|
|
743
839
|
"""Compose the subprocess environment for the per-toolkit host.
|
|
@@ -748,8 +844,10 @@ def _build_host_env(toolkit_path: Path, toolkit_name: str,
|
|
|
748
844
|
|
|
749
845
|
The toolkit's interpreter doesn't have ``toolbase`` installed, only
|
|
750
846
|
``orchestral-ai`` and ``mcp``. We need ``toolbase._toolkit_host`` to
|
|
751
|
-
be importable, so
|
|
752
|
-
|
|
847
|
+
be importable, so ``PYTHONPATH`` carries a staged directory holding
|
|
848
|
+
nothing but a ``toolbase`` symlink -- see ``_staged_toolbase_path``
|
|
849
|
+
for why exposing the package's real parent directory instead leaks
|
|
850
|
+
the entire serving environment into the toolkit's venv.
|
|
753
851
|
|
|
754
852
|
The caller's activated-conda/venv pollution is first stripped (see
|
|
755
853
|
``_strip_caller_env_activation``) so the toolkit's isolated env is
|
|
@@ -764,16 +862,11 @@ def _build_host_env(toolkit_path: Path, toolkit_name: str,
|
|
|
764
862
|
plumbing.
|
|
765
863
|
"""
|
|
766
864
|
env = _strip_caller_env_activation(os.environ.copy())
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
if
|
|
771
|
-
|
|
772
|
-
else:
|
|
773
|
-
# Namespace-package / some editable layouts leave ``__file__`` None;
|
|
774
|
-
# ``__path__`` still points at the package dir, so its parent is the
|
|
775
|
-
# directory that contains the ``toolbase`` package.
|
|
776
|
-
pkg_parent = str(Path(next(iter(_tb.__path__))).resolve().parent)
|
|
865
|
+
staged = _staged_toolbase_path()
|
|
866
|
+
# Fall back to the package's real parent when staging is unavailable.
|
|
867
|
+
# That re-leaks the serving env, but a leaky serve beats no serve.
|
|
868
|
+
pkg_parent = str(staged if staged is not None
|
|
869
|
+
else _toolbase_package_dir().parent)
|
|
777
870
|
existing = env.get("PYTHONPATH", "")
|
|
778
871
|
env["PYTHONPATH"] = (
|
|
779
872
|
pkg_parent + (os.pathsep + existing if existing else "")
|
|
@@ -1235,7 +1328,9 @@ class Orchestrator:
|
|
|
1235
1328
|
"""
|
|
1236
1329
|
# Resolve declarative state-config first. A missing-required-
|
|
1237
1330
|
# field condition means we never spawn.
|
|
1238
|
-
state_config, config_err = _resolve_state_config(
|
|
1331
|
+
state_config, config_err = _resolve_state_config(
|
|
1332
|
+
disc, self._config_overrides,
|
|
1333
|
+
)
|
|
1239
1334
|
if config_err is not None:
|
|
1240
1335
|
self.console.print(
|
|
1241
1336
|
f" [red]✗[/red] [dim]{disc.name:<18}[/dim] "
|
|
@@ -1314,7 +1409,9 @@ class Orchestrator:
|
|
|
1314
1409
|
message=note, level="warn",
|
|
1315
1410
|
)
|
|
1316
1411
|
|
|
1317
|
-
availability, name_to_bundles = _resolve_bundle_availability(
|
|
1412
|
+
availability, name_to_bundles = _resolve_bundle_availability(
|
|
1413
|
+
disc, self._config_overrides,
|
|
1414
|
+
)
|
|
1318
1415
|
if availability.dropped_bundles:
|
|
1319
1416
|
for bname, missing in availability.dropped_bundles.items():
|
|
1320
1417
|
line = format_skip_log_line(disc.name, bname, missing)
|
|
@@ -1609,7 +1706,9 @@ class Orchestrator:
|
|
|
1609
1706
|
# config file between sessions (the file is canonical; we always
|
|
1610
1707
|
# read fresh). Same shape as initial launch: a config error here
|
|
1611
1708
|
# marks the toolkit failed for this restart attempt.
|
|
1612
|
-
state_config, config_err = _resolve_state_config(
|
|
1709
|
+
state_config, config_err = _resolve_state_config(
|
|
1710
|
+
rt.discovery, self._config_overrides,
|
|
1711
|
+
)
|
|
1613
1712
|
if config_err is not None:
|
|
1614
1713
|
rt.restart_attempts = attempt
|
|
1615
1714
|
rt.last_error = config_err
|
|
@@ -804,8 +804,10 @@ def validate_toolkit(toolkit_path: Path) -> ValidationResult:
|
|
|
804
804
|
):
|
|
805
805
|
result.is_valid = False
|
|
806
806
|
result.errors.append(
|
|
807
|
-
"requirements.txt must include 'orchestral-ai>=1.
|
|
808
|
-
"(required for Orchestral tool framework
|
|
807
|
+
"requirements.txt must include 'orchestral-ai>=1.10.0' "
|
|
808
|
+
"(required for Orchestral tool framework; 1.10 is the "
|
|
809
|
+
"first release built on MCP SDK 2.x, which is what the "
|
|
810
|
+
"toolkit host speaks)"
|
|
809
811
|
)
|
|
810
812
|
|
|
811
813
|
except Exception as e:
|
|
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
|
|
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
|
|
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
|