Workspace and CLI API
The .tool-agents project folder and the command that runs it. See the
CLI guide for the narrative version.
Workspace
Workspace
dataclass
A loaded .tool-agents directory.
discover
classmethod
discover(
start: Path | str | None = None,
dirname: str = DEFAULT_WORKSPACE_DIRNAME,
) -> "Workspace"
Find the nearest workspace at or above start.
Raises:
| Type | Description |
|---|---|
WorkspaceNotFoundError
|
if no such directory exists, naming every directory that was searched so the failure is diagnosable. |
create
classmethod
create(
parent: Path | str | None = None,
dirname: str = DEFAULT_WORKSPACE_DIRNAME,
) -> "Workspace"
Create an empty workspace under parent and return it.
workflow_path
Return the path of one workflow, by name or filename.
load_adapters
Import adapter modules so they register their types.
Returns the module names imported, for reporting.
build_tool_registry
build_tool_registry() -> PipelineToolRegistry
Register every tool module as a plugin named for its file.
load_agent_configs
Return shared agent declarations and an optional default name.
A provider file may hold a list of agent declarations, or an object
with agents and optionally default_agent.
load_env
Read a .env file so provider keys can come from one.
With no argument this reads .tool-agents/.env if it exists, which
is where a project's keys naturally live: beside the workflows that
need them, and easy to gitignore as one path. Values already exported
in the environment are left alone.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Whether a file was read. |
load_workflow_document
Read one workflow document, merged with shared provider entries.
A workflow's own agents entries win over the shared ones, so a
workflow can override a shared declaration by redeclaring the name.
load_pipeline
load_pipeline(
name: str,
allow_writes: bool = False,
build_agents: bool = True,
default_agent: Any = None,
env_file: str | Path | None = None,
) -> Pipeline
Load one workflow with the workspace's tools, adapters and env.
run_workflow
run_workflow(
name: str,
arguments: Mapping[str, Any] | None = None,
allow_writes: bool = False,
build_agents: bool = True,
default_agent: Any = None,
env_file: str | Path | None = None,
) -> PipelineResults
Load and run one workflow, seeding the prompts section.
WorkspaceError
Bases: RuntimeError
Raised when a workspace is malformed or a member is missing.
WorkspaceNotFoundError
Bases: WorkspaceError
Raised when no workspace directory could be found.
Command line
parse_argument
Parse one key=value argument.
The value is decoded as JSON when it can be, so --arg n=3 gives an
integer, --arg tags=["a","b"] a list, and --arg name=Ada the plain
string it looks like.