trading_agent.workspace.workspace_layout
¶
Where every file in the agent's workspace lives, and creating the missing ones from templates.
The workspace has a shared part that belongs to the user, and one folder per desk:
workspace/
shared/ Agents.md User.md TradingRules.md
shared/skills/installed/ the user's imported skills
shared/knowledge/ the user's documents, searched with search_knowledge
shared/agents/ the user's subagent definitions, starting with four starters
shared/hooks/
Typical usage example:
layout = WorkspaceLayout(Path('workspace')) layout.create_missing(['main']) text = layout.trading_rules_file.read_text()
WorkspaceLayout
¶
The paths of one workspace.
Attributes:
| Name | Type | Description |
|---|---|---|
root |
The workspace folder. |
|
shared_directory |
The folder of the files every desk shares. |
|
agents_file |
The operating manual every desk follows. |
|
user_file |
What the agent knows about the user. |
|
trading_rules_file |
The strategies and hard limits. |
Describes a workspace without touching the disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The workspace folder. |
required |
Source code in src/trading_agent/workspace/workspace_layout.py
desk_directory
¶
The folder that belongs to one desk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's folder. |
persona_file
¶
The desk's persona, which belongs to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's Persona.md. |
Source code in src/trading_agent/workspace/workspace_layout.py
memory_file
¶
The desk's lasting lessons, which the desk itself maintains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's Memory.md. |
Source code in src/trading_agent/workspace/workspace_layout.py
agents_directory
property
¶
The user's subagent definitions, one Markdown file each.
knowledge_index_file
property
¶
The SQLite full-text index of the knowledge folder.
installed_skills_directory
property
¶
The user's imported skills, shared by every desk and read-only to them.
agent_skills_directory
¶
The skills the desk wrote for itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's skills/agent folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
skill_usage_file
¶
The record of each time the desk loaded a skill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's skills/usage.jsonl. |
Source code in src/trading_agent/workspace/workspace_layout.py
skill_ledger_file
¶
The record of every change to the desk's own skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's skills/ledger.jsonl. |
Source code in src/trading_agent/workspace/workspace_layout.py
notes_directory
¶
Where the desk records its daily improvement notes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's notes folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
alerts_file
¶
The desk's price alerts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's alerts.json. |
Source code in src/trading_agent/workspace/workspace_layout.py
market_watcher_state_file
property
¶
The ids of broker orders the market watcher has already reported.
telegram_pairing_file
property
¶
The Telegram chats allowed to command the desks, and the pairing codes waiting for approval.
phone_devices_file
property
¶
The phones running the Android app that receive push notifications.
cron_directory
¶
Where the desk's scheduled jobs and their run record are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's cron folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
sessions_directory
¶
Where the desk's session logs, session state and daily summaries are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's sessions folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
checkpoint_repository
¶
The git directory holding snapshots of the desk's own files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The repository, such as workspace/.checkpoints/main.git. |
Source code in src/trading_agent/workspace/workspace_layout.py
proposals_directory
¶
Where the desk's proposed changes to the user's files wait.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's proposals folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
requests_directory
¶
Where the desk's questions, plans and permission requests to the user are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's requests folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
scratch_directory
¶
The desk's working folder for temporary files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's scratch folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
uploads_directory
¶
The desk's folder of files the user sent with messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk's name. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's uploads folder. |
Source code in src/trading_agent/workspace/workspace_layout.py
user_owned_file
¶
Finds one of the user's files by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk whose Persona.md is meant, for that file name. |
required |
file_name
|
str
|
One of USER_OWNED_FILE_NAMES. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The file's path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The name is not one of the user's files. |
Source code in src/trading_agent/workspace/workspace_layout.py
create_missing
¶
Creates the folders, and writes each missing file from its template.
Existing files are never overwritten. The intraday, scalper and positional desks get their own starter Persona.md; other desks get the general template. The starter subagents are written only when the agents folder does not exist yet, so one the user deleted stays deleted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_names
|
Sequence[str]
|
The desks to prepare. |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
The files that were created. |
Source code in src/trading_agent/workspace/workspace_layout.py
template_text
¶
Reads one of the templates shipped with the package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
The template's file name, such as "Agents.md". |
required |
Returns:
| Type | Description |
|---|---|
str
|
The template's text. |
Source code in src/trading_agent/workspace/workspace_layout.py
is_template
¶
Says whether a file is still an unfilled template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the file is missing or still holds the template's status line. |