pai-agent-sdk 0.4.1__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.
Potentially problematic release.
This version of pai-agent-sdk might be problematic. Click here for more details.
- pai_agent_sdk-0.4.1/.env.example +64 -0
- pai_agent_sdk-0.4.1/.gitattributes +3 -0
- pai_agent_sdk-0.4.1/.github/actions/setup-python-env/action.yml +40 -0
- pai_agent_sdk-0.4.1/.github/workflows/main.yml +71 -0
- pai_agent_sdk-0.4.1/.github/workflows/on-release-main.yml +81 -0
- pai_agent_sdk-0.4.1/.github/workflows/validate-codecov-config.yml +15 -0
- pai_agent_sdk-0.4.1/.gitignore +145 -0
- pai_agent_sdk-0.4.1/.pre-commit-config.yaml +29 -0
- pai_agent_sdk-0.4.1/.python-version +1 -0
- pai_agent_sdk-0.4.1/.vscode/settings.json +3 -0
- pai_agent_sdk-0.4.1/AGENTS.md +218 -0
- pai_agent_sdk-0.4.1/CLAUDE.md +1 -0
- pai_agent_sdk-0.4.1/CONTRIBUTING.md +126 -0
- pai_agent_sdk-0.4.1/LICENSE +28 -0
- pai_agent_sdk-0.4.1/Makefile +58 -0
- pai_agent_sdk-0.4.1/PKG-INFO +136 -0
- pai_agent_sdk-0.4.1/README.md +81 -0
- pai_agent_sdk-0.4.1/SKILL.md +241 -0
- pai_agent_sdk-0.4.1/YOUWARE.md +1 -0
- pai_agent_sdk-0.4.1/codecov.yaml +14 -0
- pai_agent_sdk-0.4.1/docs/README.md +23 -0
- pai_agent_sdk-0.4.1/docs/context.md +150 -0
- pai_agent_sdk-0.4.1/docs/environment.md +202 -0
- pai_agent_sdk-0.4.1/docs/logging.md +106 -0
- pai_agent_sdk-0.4.1/docs/model.md +97 -0
- pai_agent_sdk-0.4.1/docs/resumable-resources.md +166 -0
- pai_agent_sdk-0.4.1/docs/subagent.md +158 -0
- pai_agent_sdk-0.4.1/docs/toolset.md +134 -0
- pai_agent_sdk-0.4.1/examples/.env.example +83 -0
- pai_agent_sdk-0.4.1/examples/__init__.py +11 -0
- pai_agent_sdk-0.4.1/examples/browser_use.py +285 -0
- pai_agent_sdk-0.4.1/examples/deepresearch.py +360 -0
- pai_agent_sdk-0.4.1/examples/general.py +362 -0
- pai_agent_sdk-0.4.1/examples/prompts/browser_use.md +56 -0
- pai_agent_sdk-0.4.1/examples/prompts/deepresearch.md +244 -0
- pai_agent_sdk-0.4.1/examples/prompts/general.md +73 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/__init__.py +0 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/_config.py +30 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/_logger.py +176 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/__init__.py +0 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/compact.py +371 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/image_understanding.py +275 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/main.py +780 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/models/__init__.py +28 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/models/gateway.py +123 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/models/utils.py +79 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/prompts/compact.md +72 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/prompts/image_understanding.md +52 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/prompts/main.md +17 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/prompts/video_understanding.md +62 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/agents/video_understanding.py +265 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/context.py +1053 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/environment/__init__.py +33 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/environment/docker.py +445 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/environment/local.py +572 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/events.py +68 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/__init__.py +20 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/capability.py +218 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/environment_instructions.py +104 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/handoff.py +102 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/image.py +293 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/model_swtich.py +43 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/runtime_instructions.py +102 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/system_prompt.py +105 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/filters/tool_args.py +69 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/presets.py +609 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/sandbox/__init__.py +0 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/sandbox/browser/__init__.py +5 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/sandbox/browser/base.py +54 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/sandbox/browser/docker_.py +211 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/skills/__init__.py +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/skills/checkpointing/SKILL.md +215 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/stream/__init__.py +0 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/__init__.py +155 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/config.py +173 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/factory.py +238 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/presets/code-reviewer.md +114 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/presets/debugger.md +95 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/presets/explorer.md +114 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/subagents/presets/searcher.md +113 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/__init__.py +43 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/__init__.py +4 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/_config.py +37 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/_session.py +37 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/_tools.py +99 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/__init__.py +130 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/_types.py +180 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/dialog.py +148 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/form.py +399 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/interaction.py +459 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/navigation.py +333 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/query.py +248 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/state.py +333 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/validation.py +275 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/tools/wait.py +378 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/browser_use/toolset.py +258 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/__init__.py +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/base.py +705 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/content/__init__.py +16 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/content/_url_helper.py +200 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/content/load_media_url.py +161 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/content/prompts/load_media_url.md +24 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/context/__init__.py +17 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/context/handoff.py +132 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/context/prompts/handoff.md +163 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/document/__init__.py +28 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/document/office.py +218 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/document/pdf.py +243 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/document/prompts/office.md +9 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/document/prompts/pdf.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/enhance/__init__.py +22 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/enhance/prompts/thinking.md +22 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/enhance/prompts/todo.md +19 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/enhance/thinking.py +45 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/enhance/todo.py +143 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/__init__.py +71 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/_types.py +199 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/edit.py +172 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/glob.py +57 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/grep.py +173 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/ls.py +111 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/mkdir.py +99 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/move_copy.py +157 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/copy.md +9 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/edit.md +12 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/glob.md +16 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/grep.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/ls.md +9 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/mkdir.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/move.md +9 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/multi_edit.md +12 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/replace.md +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/prompts/view.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/replace.py +71 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/filesystem/view.py +398 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/multimodal/__init__.py +19 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/multimodal/image.py +71 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/multimodal/video.py +71 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/shell/__init__.py +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/shell/prompts/shell.md +18 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/shell/shell.py +139 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/subagent/__init__.py +66 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/subagent/factory.py +241 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/subagent/tools.py +145 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/__init__.py +39 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/_http_client.py +174 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/download.py +123 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/fetch.py +123 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/download.md +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/fetch.md +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/scrape.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/search.md +10 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/search_image.md +12 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/prompts/search_stock_image.md +11 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/scrape.py +105 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/toolsets/core/web/search.py +286 -0
- pai_agent_sdk-0.4.1/pai_agent_sdk/utils.py +172 -0
- pai_agent_sdk-0.4.1/pyproject.toml +167 -0
- pai_agent_sdk-0.4.1/pytest.ini +4 -0
- pai_agent_sdk-0.4.1/scripts/sync-skills.sh +19 -0
- pai_agent_sdk-0.4.1/tests/conftest.py +143 -0
- pai_agent_sdk-0.4.1/tests/environment/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/environment/test_docker.py +359 -0
- pai_agent_sdk-0.4.1/tests/environment/test_local.py +522 -0
- pai_agent_sdk-0.4.1/tests/filters/__init__.py +0 -0
- pai_agent_sdk-0.4.1/tests/filters/test_capability.py +201 -0
- pai_agent_sdk-0.4.1/tests/filters/test_environment_instructions.py +127 -0
- pai_agent_sdk-0.4.1/tests/filters/test_handoff.py +172 -0
- pai_agent_sdk-0.4.1/tests/filters/test_image.py +606 -0
- pai_agent_sdk-0.4.1/tests/filters/test_model_switch.py +126 -0
- pai_agent_sdk-0.4.1/tests/filters/test_runtime_instructions.py +165 -0
- pai_agent_sdk-0.4.1/tests/filters/test_system_prompt.py +155 -0
- pai_agent_sdk-0.4.1/tests/filters/test_tool_args.py +207 -0
- pai_agent_sdk-0.4.1/tests/sandbox/__init__.py +0 -0
- pai_agent_sdk-0.4.1/tests/sandbox/browser/__init__.py +0 -0
- pai_agent_sdk-0.4.1/tests/sandbox/browser/test_browser_sandbox.py +96 -0
- pai_agent_sdk-0.4.1/tests/subagents/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/subagents/test_config.py +225 -0
- pai_agent_sdk-0.4.1/tests/subagents/test_factory.py +267 -0
- pai_agent_sdk-0.4.1/tests/subagents/test_init.py +406 -0
- pai_agent_sdk-0.4.1/tests/test_config.py +42 -0
- pai_agent_sdk-0.4.1/tests/test_context.py +1318 -0
- pai_agent_sdk-0.4.1/tests/test_events.py +228 -0
- pai_agent_sdk-0.4.1/tests/test_hello.py +2 -0
- pai_agent_sdk-0.4.1/tests/test_presets.py +222 -0
- pai_agent_sdk-0.4.1/tests/test_utils.py +150 -0
- pai_agent_sdk-0.4.1/tests/toolsets/__init__.py +0 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/conftest.py +68 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_config.py +161 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_dialog.py +77 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_form.py +424 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_interaction.py +220 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_navigation.py +249 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_query.py +111 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_state.py +200 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_tools.py +28 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_toolset.py +226 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_validation.py +227 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_browser_use_wait.py +215 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/basic.html +18 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/delayed_requests.html +78 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/dialogs.html +28 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/dynamic.html +46 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/forms.html +94 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/interactive.html +47 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/long_page.html +44 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/navigation/page1.html +14 -0
- pai_agent_sdk-0.4.1/tests/toolsets/browser_use/test_fixtures/navigation/page2.html +13 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/content/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/content/test_url_helper.py +137 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/context/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/context/test_handoff.py +148 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/dummy.docx +0 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/dummy.pdf +0 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/dummy.pptx +0 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/dummy.xlsx +0 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/document/test_document.py +250 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/enhance/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/enhance/test_thinking.py +113 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/enhance/test_todo.py +318 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_edit.py +359 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_glob.py +141 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_grep.py +314 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_ls.py +173 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_mkdir.py +153 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_move_copy.py +286 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_replace.py +113 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/filesystem/test_view.py +421 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/shell/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/shell/test_shell.py +151 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/subagent/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/subagent/test_factory.py +648 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/subagent/test_tools.py +236 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/test_base.py +619 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/__init__.py +1 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/test_download.py +115 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/test_fetch.py +123 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/test_http_client.py +174 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/test_scrape.py +102 -0
- pai_agent_sdk-0.4.1/tests/toolsets/core/web/test_search.py +278 -0
- pai_agent_sdk-0.4.1/uv.lock +4208 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# pai-agent-sdk Environment Variables
|
|
2
|
+
# Copy this file to .env and uncomment the variables you need
|
|
3
|
+
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# Web Search API Keys
|
|
6
|
+
# =============================================================================
|
|
7
|
+
|
|
8
|
+
# Google Custom Search API
|
|
9
|
+
# Get your key at: https://developers.google.com/custom-search/v1/introduction
|
|
10
|
+
# GOOGLE_SEARCH_API_KEY=your_google_search_api_key
|
|
11
|
+
# GOOGLE_SEARCH_CX=your_google_search_cx
|
|
12
|
+
|
|
13
|
+
# Tavily Search API
|
|
14
|
+
# Get your key at: https://tavily.com/
|
|
15
|
+
# TAVILY_API_KEY=your_tavily_api_key
|
|
16
|
+
|
|
17
|
+
# =============================================================================
|
|
18
|
+
# Image Search API Keys
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
# Pixabay API (stock images)
|
|
22
|
+
# Get your key at: https://pixabay.com/api/docs/
|
|
23
|
+
# PIXABAY_API_KEY=your_pixabay_api_key
|
|
24
|
+
|
|
25
|
+
# RapidAPI (real-time image search)
|
|
26
|
+
# Get your key at: https://rapidapi.com/
|
|
27
|
+
# RAPIDAPI_API_KEY=your_rapidapi_key
|
|
28
|
+
|
|
29
|
+
# =============================================================================
|
|
30
|
+
# Web Scraping API Keys
|
|
31
|
+
# =============================================================================
|
|
32
|
+
|
|
33
|
+
# Firecrawl API
|
|
34
|
+
# Get your key at: https://firecrawl.dev/
|
|
35
|
+
# FIRECRAWL_API_KEY=your_firecrawl_api_key
|
|
36
|
+
|
|
37
|
+
# =============================================================================
|
|
38
|
+
# Agent Configuration (PAI_AGENT_ prefix)
|
|
39
|
+
# =============================================================================
|
|
40
|
+
|
|
41
|
+
# Model for image understanding when native vision is unavailable
|
|
42
|
+
# PAI_AGENT_IMAGE_UNDERSTANDING_MODEL=gpt-4o-mini
|
|
43
|
+
|
|
44
|
+
# Model for video understanding when native capability is unavailable
|
|
45
|
+
# PAI_AGENT_VIDEO_UNDERSTANDING_MODEL=gemini-2.0-flash
|
|
46
|
+
|
|
47
|
+
# Model for compact when native capability is unavailable
|
|
48
|
+
# PAI_AGENT_COMPACT_MODEL=gemini-2.0-flash
|
|
49
|
+
|
|
50
|
+
# =============================================================================
|
|
51
|
+
# Browser Use Configuration (PAI_AGENT_BROWSER_USE_ prefix)
|
|
52
|
+
# =============================================================================
|
|
53
|
+
|
|
54
|
+
# Maximum retry attempts for tool calls
|
|
55
|
+
# PAI_AGENT_BROWSER_USE_MAX_RETRIES=3
|
|
56
|
+
|
|
57
|
+
# Tool name prefix
|
|
58
|
+
# PAI_AGENT_BROWSER_USE_PREFIX=browser_use_
|
|
59
|
+
|
|
60
|
+
# Force create new page instead of reusing existing
|
|
61
|
+
# PAI_AGENT_BROWSER_USE_ALWAYS_USE_NEW_PAGE=false
|
|
62
|
+
|
|
63
|
+
# Automatically close created page targets on context exit
|
|
64
|
+
# PAI_AGENT_BROWSER_USE_AUTO_CLEANUP_PAGE=false
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: "Setup Python Environment"
|
|
2
|
+
description: "Set up Python environment for the given Python version"
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
python-version:
|
|
6
|
+
description: "Python version to use"
|
|
7
|
+
required: true
|
|
8
|
+
default: "3.13"
|
|
9
|
+
uv-version:
|
|
10
|
+
description: "uv version to use"
|
|
11
|
+
required: true
|
|
12
|
+
default: "0.6.2"
|
|
13
|
+
extras:
|
|
14
|
+
description: "Optional extras to install (comma-separated, e.g., 'docker')"
|
|
15
|
+
required: false
|
|
16
|
+
default: ""
|
|
17
|
+
|
|
18
|
+
runs:
|
|
19
|
+
using: "composite"
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ inputs.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
with:
|
|
28
|
+
version: ${{ inputs.uv-version }}
|
|
29
|
+
enable-cache: 'true'
|
|
30
|
+
cache-suffix: ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Install Python dependencies (no extras)
|
|
33
|
+
if: ${{ inputs.extras == '' }}
|
|
34
|
+
run: uv sync --frozen --python=${{ matrix.python-version }}
|
|
35
|
+
shell: bash
|
|
36
|
+
|
|
37
|
+
- name: Install Python dependencies (with extras)
|
|
38
|
+
if: ${{ inputs.extras != '' }}
|
|
39
|
+
run: uv sync --frozen --python=${{ matrix.python-version }} --extra ${{ inputs.extras }}
|
|
40
|
+
shell: bash
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Main
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
quality:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: Check out
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/cache@v4
|
|
18
|
+
with:
|
|
19
|
+
path: ~/.cache/pre-commit
|
|
20
|
+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
|
21
|
+
|
|
22
|
+
- name: Set up the environment
|
|
23
|
+
uses: ./.github/actions/setup-python-env
|
|
24
|
+
|
|
25
|
+
- name: Run checks
|
|
26
|
+
run: make check
|
|
27
|
+
|
|
28
|
+
tests-and-type-check:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
strategy:
|
|
31
|
+
matrix:
|
|
32
|
+
# No extra only runs on 3.13
|
|
33
|
+
include:
|
|
34
|
+
- python-version: "3.11"
|
|
35
|
+
extras: "all"
|
|
36
|
+
- python-version: "3.12"
|
|
37
|
+
extras: "all"
|
|
38
|
+
- python-version: "3.13"
|
|
39
|
+
extras: "all"
|
|
40
|
+
# - python-version: "3.14"
|
|
41
|
+
# extras: "all"
|
|
42
|
+
- python-version: "3.13"
|
|
43
|
+
extras: ""
|
|
44
|
+
fail-fast: false
|
|
45
|
+
env:
|
|
46
|
+
UV_PYTHON: ${{ matrix.python-version }}
|
|
47
|
+
defaults:
|
|
48
|
+
run:
|
|
49
|
+
shell: bash
|
|
50
|
+
steps:
|
|
51
|
+
- name: Check out
|
|
52
|
+
uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- name: Set up the environment
|
|
55
|
+
uses: ./.github/actions/setup-python-env
|
|
56
|
+
with:
|
|
57
|
+
python-version: ${{ matrix.python-version }}
|
|
58
|
+
extras: ${{ matrix.extras }}
|
|
59
|
+
|
|
60
|
+
- name: Run tests
|
|
61
|
+
run: uv run python -m pytest tests -n auto --cov --cov-config=pyproject.toml --cov-report=xml
|
|
62
|
+
|
|
63
|
+
- name: Check typing
|
|
64
|
+
run: uv run pyright
|
|
65
|
+
|
|
66
|
+
- name: Upload coverage reports to Codecov
|
|
67
|
+
uses: codecov/codecov-action@v5
|
|
68
|
+
with:
|
|
69
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
70
|
+
slug: youware-labs/pai-agent-sdk
|
|
71
|
+
if: ${{ matrix.python-version == '3.13' && matrix.extras == 'all' }}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
name: release-main
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
packages: write
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
set-version:
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Export tag
|
|
18
|
+
id: vars
|
|
19
|
+
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
|
|
20
|
+
if: ${{ github.event_name == 'release' }}
|
|
21
|
+
|
|
22
|
+
- name: Update project version
|
|
23
|
+
run: |
|
|
24
|
+
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
|
|
25
|
+
env:
|
|
26
|
+
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
|
|
27
|
+
if: ${{ github.event_name == 'release' }}
|
|
28
|
+
|
|
29
|
+
- name: Upload updated pyproject.toml
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: pyproject-toml
|
|
33
|
+
path: pyproject.toml
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
needs: [set-version]
|
|
38
|
+
steps:
|
|
39
|
+
- name: Check out
|
|
40
|
+
uses: actions/checkout@v4
|
|
41
|
+
|
|
42
|
+
- name: Set up the environment
|
|
43
|
+
uses: ./.github/actions/setup-python-env
|
|
44
|
+
|
|
45
|
+
- name: Download updated pyproject.toml
|
|
46
|
+
uses: actions/download-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: pyproject-toml
|
|
49
|
+
|
|
50
|
+
- name: Build package
|
|
51
|
+
run: uv build
|
|
52
|
+
|
|
53
|
+
- name: Publish package
|
|
54
|
+
run: uv publish
|
|
55
|
+
env:
|
|
56
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
57
|
+
|
|
58
|
+
- name: Upload dists to release
|
|
59
|
+
uses: svenstaro/upload-release-action@v2
|
|
60
|
+
with:
|
|
61
|
+
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
62
|
+
file: dist/*
|
|
63
|
+
file_glob: true
|
|
64
|
+
tag: ${{ github.ref }}
|
|
65
|
+
overwrite: true
|
|
66
|
+
|
|
67
|
+
- name: Sync skills folder
|
|
68
|
+
run: bash scripts/sync-skills.sh
|
|
69
|
+
|
|
70
|
+
- name: Create SKILL.zip
|
|
71
|
+
run: |
|
|
72
|
+
mv skills pai-agent-sdk
|
|
73
|
+
zip -r SKILL.zip pai-agent-sdk
|
|
74
|
+
|
|
75
|
+
- name: Upload SKILL.zip to release
|
|
76
|
+
uses: svenstaro/upload-release-action@v2
|
|
77
|
+
with:
|
|
78
|
+
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
79
|
+
file: SKILL.zip
|
|
80
|
+
tag: ${{ github.ref }}
|
|
81
|
+
overwrite: true
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: validate-codecov-config
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths: [codecov.yaml]
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
validate-codecov-config:
|
|
11
|
+
runs-on: ubuntu-22.04
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- name: Validate codecov configuration
|
|
15
|
+
run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
docs/source
|
|
2
|
+
|
|
3
|
+
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
|
|
4
|
+
|
|
5
|
+
# Byte-compiled / optimized / DLL files
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
|
|
10
|
+
# C extensions
|
|
11
|
+
*.so
|
|
12
|
+
|
|
13
|
+
# Distribution / packaging
|
|
14
|
+
.Python
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
share/python-wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
# Usually these files are written by a python script from a template
|
|
35
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
36
|
+
*.manifest
|
|
37
|
+
*.spec
|
|
38
|
+
|
|
39
|
+
# Installer logs
|
|
40
|
+
pip-log.txt
|
|
41
|
+
pip-delete-this-directory.txt
|
|
42
|
+
|
|
43
|
+
# Unit test / coverage reports
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
.nox/
|
|
47
|
+
.coverage
|
|
48
|
+
.coverage.*
|
|
49
|
+
.cache
|
|
50
|
+
nosetests.xml
|
|
51
|
+
coverage.xml
|
|
52
|
+
*.cover
|
|
53
|
+
*.py,cover
|
|
54
|
+
.hypothesis/
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
cover/
|
|
57
|
+
|
|
58
|
+
# Translations
|
|
59
|
+
*.mo
|
|
60
|
+
*.pot
|
|
61
|
+
|
|
62
|
+
# Django stuff:
|
|
63
|
+
*.log
|
|
64
|
+
local_settings.py
|
|
65
|
+
db.sqlite3
|
|
66
|
+
db.sqlite3-journal
|
|
67
|
+
|
|
68
|
+
# Flask stuff:
|
|
69
|
+
instance/
|
|
70
|
+
.webassets-cache
|
|
71
|
+
|
|
72
|
+
# Scrapy stuff:
|
|
73
|
+
.scrapy
|
|
74
|
+
|
|
75
|
+
# Sphinx documentation
|
|
76
|
+
docs/_build/
|
|
77
|
+
|
|
78
|
+
# PyBuilder
|
|
79
|
+
.pybuilder/
|
|
80
|
+
target/
|
|
81
|
+
|
|
82
|
+
# Jupyter Notebook
|
|
83
|
+
.ipynb_checkpoints
|
|
84
|
+
|
|
85
|
+
# IPython
|
|
86
|
+
profile_default/
|
|
87
|
+
ipython_config.py
|
|
88
|
+
|
|
89
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
90
|
+
__pypackages__/
|
|
91
|
+
|
|
92
|
+
# Celery stuff
|
|
93
|
+
celerybeat-schedule
|
|
94
|
+
celerybeat.pid
|
|
95
|
+
|
|
96
|
+
# SageMath parsed files
|
|
97
|
+
*.sage.py
|
|
98
|
+
|
|
99
|
+
# Environments
|
|
100
|
+
.env
|
|
101
|
+
.venv
|
|
102
|
+
env/
|
|
103
|
+
venv/
|
|
104
|
+
ENV/
|
|
105
|
+
env.bak/
|
|
106
|
+
venv.bak/
|
|
107
|
+
|
|
108
|
+
# Spyder project settings
|
|
109
|
+
.spyderproject
|
|
110
|
+
.spyproject
|
|
111
|
+
|
|
112
|
+
# Rope project settings
|
|
113
|
+
.ropeproject
|
|
114
|
+
|
|
115
|
+
# mkdocs documentation
|
|
116
|
+
/site
|
|
117
|
+
|
|
118
|
+
# mypy
|
|
119
|
+
.mypy_cache/
|
|
120
|
+
.pyright/
|
|
121
|
+
.dmypy.json
|
|
122
|
+
dmypy.json
|
|
123
|
+
|
|
124
|
+
# Pyre type checker
|
|
125
|
+
.pyre/
|
|
126
|
+
|
|
127
|
+
# pytype static type analyzer
|
|
128
|
+
.pytype/
|
|
129
|
+
|
|
130
|
+
# Cython debug symbols
|
|
131
|
+
cython_debug/
|
|
132
|
+
|
|
133
|
+
# Vscode config files
|
|
134
|
+
# .vscode/
|
|
135
|
+
|
|
136
|
+
# PyCharm
|
|
137
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
138
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
139
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
140
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
141
|
+
#.idea/
|
|
142
|
+
|
|
143
|
+
TO-DO.json
|
|
144
|
+
dev/
|
|
145
|
+
pai_agent_sdk/sandbox/shell/templates/public
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: "v6.0.0"
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-case-conflict
|
|
6
|
+
- id: check-merge-conflict
|
|
7
|
+
- id: check-toml
|
|
8
|
+
- id: check-yaml
|
|
9
|
+
- id: check-json
|
|
10
|
+
exclude: ^.devcontainer/devcontainer.json
|
|
11
|
+
- id: pretty-format-json
|
|
12
|
+
exclude: ^.devcontainer/devcontainer.json
|
|
13
|
+
args: [--autofix]
|
|
14
|
+
- id: end-of-file-fixer
|
|
15
|
+
- id: trailing-whitespace
|
|
16
|
+
- repo: https://github.com/executablebooks/mdformat
|
|
17
|
+
rev: 1.0.0
|
|
18
|
+
hooks:
|
|
19
|
+
- id: mdformat
|
|
20
|
+
args: [--number]
|
|
21
|
+
exclude: ^(pai_agent_sdk/.*\.md|examples/.*\.md)$
|
|
22
|
+
additional_dependencies:
|
|
23
|
+
[mdformat-gfm, mdformat-front-matters, mdformat-footnote]
|
|
24
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
25
|
+
rev: "v0.14.11"
|
|
26
|
+
hooks:
|
|
27
|
+
- id: ruff
|
|
28
|
+
args: [--exit-non-zero-on-fix]
|
|
29
|
+
- id: ruff-format
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
## Project Overview
|
|
2
|
+
|
|
3
|
+
**pai-agent-sdk** is a Python SDK for building production-ready AI agents with [Pydantic AI](https://ai.pydantic.dev/).
|
|
4
|
+
|
|
5
|
+
- **Language**: Python 3.11+
|
|
6
|
+
- **Package Manager**: uv
|
|
7
|
+
- **Build System**: hatchling
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **Environment-based Architecture**: Inject file operations, shell access, and resources via `Environment` for clean separation of concerns
|
|
12
|
+
- **Resumable Sessions**: Export/restore `AgentContext` state for multi-turn conversations across restarts
|
|
13
|
+
- **Hierarchical Agents**: Subagent system with task delegation and tool inheritance
|
|
14
|
+
- **Human-in-the-Loop**: Built-in approval workflows for sensitive operations
|
|
15
|
+
- **Streaming Support**: Real-time streaming of agent responses and tool executions
|
|
16
|
+
|
|
17
|
+
## Project Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pai_agent_sdk/
|
|
21
|
+
├── agents/ # Agent implementations
|
|
22
|
+
│ ├── main.py # create_agent, stream_agent entry points
|
|
23
|
+
│ ├── compact.py # Compact agent variant
|
|
24
|
+
│ ├── image_understanding.py # Image understanding agent
|
|
25
|
+
│ ├── video_understanding.py # Video understanding agent
|
|
26
|
+
│ └── models/ # Model configuration and inference
|
|
27
|
+
│
|
|
28
|
+
├── context.py # AgentContext, ModelConfig, ToolConfig, ResumableState
|
|
29
|
+
│
|
|
30
|
+
├── environment/ # Environment management
|
|
31
|
+
│ ├── base.py # Environment ABC, FileOperator, Shell, ResourceRegistry, BaseResource
|
|
32
|
+
│ ├── local.py # LocalEnvironment for local filesystem
|
|
33
|
+
│ └── docker.py # DockerEnvironment for container-based execution
|
|
34
|
+
│
|
|
35
|
+
├── toolsets/ # Tool implementations
|
|
36
|
+
│ ├── core/ # Core toolsets collection
|
|
37
|
+
│ │ ├── base.py # BaseTool, Toolset, GlobalHooks (base classes)
|
|
38
|
+
│ │ ├── content/ # Content loading tools
|
|
39
|
+
│ │ ├── context/ # Context management tools (handoff)
|
|
40
|
+
│ │ ├── document/ # Document processing tools
|
|
41
|
+
│ │ ├── enhance/ # Enhancement tools (todo, thinking)
|
|
42
|
+
│ │ ├── filesystem/ # File system operation tools
|
|
43
|
+
│ │ ├── multimodal/ # Multimodal tools (read_image, read_video)
|
|
44
|
+
│ │ ├── shell/ # Shell command execution tools
|
|
45
|
+
│ │ ├── subagent/ # Subagent delegation tools
|
|
46
|
+
│ │ └── web/ # Web interaction tools
|
|
47
|
+
│ └── browser_use/ # Browser automation toolset (independent)
|
|
48
|
+
│
|
|
49
|
+
├── subagents/ # Subagent system
|
|
50
|
+
│ ├── config.py # SubagentConfig parsing
|
|
51
|
+
│ ├── factory.py # Subagent tool factory functions
|
|
52
|
+
│ └── presets/ # Built-in subagent presets
|
|
53
|
+
│ ├── debugger.md # Debugging specialist
|
|
54
|
+
│ ├── explorer.md # Codebase exploration specialist
|
|
55
|
+
│ ├── searcher.md # Search specialist
|
|
56
|
+
│ └── code-reviewer.md # Code review specialist
|
|
57
|
+
│
|
|
58
|
+
├── filters/ # Message history processors
|
|
59
|
+
│ ├── handoff.py # Handoff message processing
|
|
60
|
+
│ ├── image.py # Image filtering
|
|
61
|
+
│ ├── system_prompt.py # System prompt filtering
|
|
62
|
+
│ └── tool_args.py # Tool argument fixing
|
|
63
|
+
│
|
|
64
|
+
├── sandbox/ # Sandbox environments
|
|
65
|
+
│ └── browser/ # Browser sandbox
|
|
66
|
+
│
|
|
67
|
+
├── skills/ # Skill definitions
|
|
68
|
+
│ └── checkpointing/ # Checkpointing skill
|
|
69
|
+
│
|
|
70
|
+
├── stream/ # Stream processing
|
|
71
|
+
├── presets.py # Preset configurations (model settings, etc.)
|
|
72
|
+
├── utils.py # Utility functions
|
|
73
|
+
└── _logger.py # Centralized logging
|
|
74
|
+
|
|
75
|
+
tests/ # Test suite (pytest)
|
|
76
|
+
├── environment/ # Environment tests
|
|
77
|
+
├── filters/ # Filter tests
|
|
78
|
+
├── sandbox/ # Sandbox tests
|
|
79
|
+
├── subagents/ # Subagent tests
|
|
80
|
+
└── toolsets/ # Toolset tests
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Development Workflow
|
|
84
|
+
|
|
85
|
+
After modifying any code:
|
|
86
|
+
|
|
87
|
+
1. `make lint` - Quick formatting and auto-fix (ruff + pre-commit)
|
|
88
|
+
2. `make check` - Full validation (lock file, pre-commit, Pyright type checking, deptry)
|
|
89
|
+
3. `make test` - Run test suite with coverage
|
|
90
|
+
|
|
91
|
+
## Key Commands
|
|
92
|
+
|
|
93
|
+
| Command | Description |
|
|
94
|
+
| --------------- | --------------------------------------------------- |
|
|
95
|
+
| `make install` | Create venv with uv and install pre-commit hooks |
|
|
96
|
+
| `make lint` | Run pre-commit linters (ruff format/lint) |
|
|
97
|
+
| `make check` | Full validation: lint + pyright + deptry |
|
|
98
|
+
| `make test` | Run pytest with coverage (inline snapshot disabled) |
|
|
99
|
+
| `make test-fix` | Run pytest with inline snapshot update enabled |
|
|
100
|
+
| `make build` | Build wheel file |
|
|
101
|
+
|
|
102
|
+
## Code Style
|
|
103
|
+
|
|
104
|
+
- **Formatter**: ruff (line-length: 120)
|
|
105
|
+
- **Type Checking**: pyright (standard mode)
|
|
106
|
+
- **Target Python**: 3.11
|
|
107
|
+
- **Import Style**: All imports must be at module level (top of file). Do not use function-level imports except within `TYPE_CHECKING` blocks for avoiding circular dependencies.
|
|
108
|
+
|
|
109
|
+
## Testing
|
|
110
|
+
|
|
111
|
+
- Framework: pytest with pytest-asyncio
|
|
112
|
+
- Coverage: pytest-cov
|
|
113
|
+
- Test location: `tests/`
|
|
114
|
+
- **Test Style**: Use standalone functions (not classes)
|
|
115
|
+
|
|
116
|
+
## Dependencies
|
|
117
|
+
|
|
118
|
+
Core dependencies:
|
|
119
|
+
|
|
120
|
+
- pydantic-ai-slim (AI agent framework)
|
|
121
|
+
- pydantic / pydantic-settings (data validation and configuration)
|
|
122
|
+
- httpx, anyio (async HTTP and concurrency)
|
|
123
|
+
- cdp-use (browser automation)
|
|
124
|
+
- pillow (image processing)
|
|
125
|
+
- jinja2 (template rendering for tool instructions)
|
|
126
|
+
|
|
127
|
+
Optional dependencies:
|
|
128
|
+
|
|
129
|
+
- `docker` - Docker sandbox support
|
|
130
|
+
- `web` - Web tools (tavily-python, firecrawl-py, markitdown)
|
|
131
|
+
- `document` - Document processing (pymupdf, markitdown)
|
|
132
|
+
|
|
133
|
+
## Environment Configuration
|
|
134
|
+
|
|
135
|
+
API keys and settings are loaded from environment variables or `.env` file via `pydantic-settings`. See `.env.example` for all available variables.
|
|
136
|
+
|
|
137
|
+
**Important**: When adding or modifying environment variables, always update `.env.example` as the single source of truth.
|
|
138
|
+
|
|
139
|
+
## Architecture Reference
|
|
140
|
+
|
|
141
|
+
### AgentContext and Sessions
|
|
142
|
+
|
|
143
|
+
See [docs/context.md](docs/context.md) for details:
|
|
144
|
+
|
|
145
|
+
- Session state management (run_id, timing, user prompts)
|
|
146
|
+
- Resumable sessions with `export_state()` and `with_state()`
|
|
147
|
+
- Extending `AgentContext` and `ResumableState` for custom fields
|
|
148
|
+
- Using `create_agent` with `state` parameter for session restoration
|
|
149
|
+
|
|
150
|
+
### Toolset Architecture
|
|
151
|
+
|
|
152
|
+
See [docs/toolset.md](docs/toolset.md) for details:
|
|
153
|
+
|
|
154
|
+
- Creating custom tools with `BaseTool`
|
|
155
|
+
- Hook system (pre/post hooks, global hooks)
|
|
156
|
+
- Error handling in post-hooks (exceptions as results)
|
|
157
|
+
- Extending `Toolset` via `_call_tool_func` for timeout/retry/custom logic
|
|
158
|
+
|
|
159
|
+
### Subagent System
|
|
160
|
+
|
|
161
|
+
See [docs/subagent.md](docs/subagent.md) for details:
|
|
162
|
+
|
|
163
|
+
- Hierarchical agent architecture and task delegation
|
|
164
|
+
- Markdown configuration format (YAML frontmatter + system prompt)
|
|
165
|
+
- Tool inheritance and availability rules
|
|
166
|
+
- Built-in presets (debugger, explorer, searcher, code-reviewer)
|
|
167
|
+
|
|
168
|
+
### Environment Management
|
|
169
|
+
|
|
170
|
+
See [docs/environment.md](docs/environment.md) for details:
|
|
171
|
+
|
|
172
|
+
- Environment ABC: FileOperator, Shell, ResourceRegistry
|
|
173
|
+
- `_setup`/`_teardown` pattern for custom environments
|
|
174
|
+
- `LocalEnvironment` and `DockerEnvironment` usage
|
|
175
|
+
- `AsyncExitStack` for managing dependent context managers
|
|
176
|
+
|
|
177
|
+
### Resumable Resources
|
|
178
|
+
|
|
179
|
+
See [docs/resumable-resources.md](docs/resumable-resources.md) for details:
|
|
180
|
+
|
|
181
|
+
- `Resource` protocol (requires `close()`) and `ResumableResource` protocol (adds `export_state`/`restore_state`)
|
|
182
|
+
- `BaseResource` abstract base class with async `close()` and default export/restore
|
|
183
|
+
- Factory-based resource creation and lazy initialization
|
|
184
|
+
- State export/restore for session persistence across restarts
|
|
185
|
+
|
|
186
|
+
### Model Configuration
|
|
187
|
+
|
|
188
|
+
See [docs/model.md](docs/model.md) for details:
|
|
189
|
+
|
|
190
|
+
- Native pydantic-ai model strings (direct provider connection)
|
|
191
|
+
- Gateway mode (route requests through unified gateway)
|
|
192
|
+
- Sticky routing and extra headers
|
|
193
|
+
|
|
194
|
+
### Logging
|
|
195
|
+
|
|
196
|
+
See [docs/logging.md](docs/logging.md) for details:
|
|
197
|
+
|
|
198
|
+
- Global log level: `PAI_AGENT_LOG_LEVEL`
|
|
199
|
+
- Module-specific log levels: `PAI_AGENT_LOG_LEVEL_<MODULE_PATH>`
|
|
200
|
+
- Use `get_logger(__name__)` to obtain logger
|
|
201
|
+
|
|
202
|
+
## Examples
|
|
203
|
+
|
|
204
|
+
| Example | Description |
|
|
205
|
+
| ------------------------------------------- | ------------------------------------------------------------------------- |
|
|
206
|
+
| [general.py](examples/general.py) | Complete production pattern with streaming, HITL, and session persistence |
|
|
207
|
+
| [deepresearch.py](examples/deepresearch.py) | Autonomous research agent with web search and content extraction |
|
|
208
|
+
| [browser_use.py](examples/browser_use.py) | Browser automation with Docker-based headless Chrome sandbox |
|
|
209
|
+
|
|
210
|
+
## Quick Start
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from pai_agent_sdk.agents import create_agent
|
|
214
|
+
|
|
215
|
+
async with create_agent("openai:gpt-4o") as runtime:
|
|
216
|
+
result = await runtime.agent.run("Hello", deps=runtime.ctx)
|
|
217
|
+
print(result.output)
|
|
218
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|