11 Commits

Author SHA1 Message Date
Dhawal Upadhyay bccd32beae Refine ToolRouter preload docs and constants 2026-05-07 16:10:38 +05:30
Musthaq Ahamad 27ed0c9bd6 security(core): sensitive path blocklist + beforeFileUpload hook (patch) (#3262)
## Summary

Security-hardening for automatic file upload in `@composio/core` (patch
release per changeset).

### Changes
- **Default denylist** for local paths before auto-upload /
`files.upload`: blocks common credential directories (e.g. `.ssh`,
`.aws`) and credential-like filenames (e.g. `.env`, default SSH private
keys). Resolves symlinks when the path exists.
- **Config:** `sensitiveFileUploadProtection`,
`fileUploadPathDenySegments` on `Composio`.
- **`beforeFileUpload`** hook (e.g. with `composio.tools.get` /
`tools.execute`): rewrite path, return `false` to abort, or throw.
- **Errors:** `ComposioSensitiveFilePathBlockedError`,
`ComposioFileUploadAbortedError`; file modifier errors exported from
`@composio/core` errors entry.
- **Changeset:** patch bump for `@composio/core`.

### Notes
- URLs and `File` blobs are not subject to the path denylist
(unchanged).
- Opt out of path checks only if required:
`sensitiveFileUploadProtection: false`.

### Tests
- `pnpm test` in `ts/packages/core` (799 tests) passed locally before
commit.

Made with [Cursor](https://cursor.com)
2026-04-23 18:42:16 +05:30
Dhawal Upadhyay 8b0e618b64 refactor(python): remove dead CustomToolkit dataclass
CustomToolkit was the old frozen dataclass that nobody creates anymore.
ExperimentalToolkit (via composio.experimental.Toolkit()) is the only
toolkit type. Removes all Union[CustomToolkit, ExperimentalToolkit] noise.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:11:03 -07:00
Dhawal Upadhyay 6196f2e338 feat(python)!: replace factory functions with decorator API for custom tools
BREAKING: Remove experimental_create_tool() and experimental_create_toolkit()
factory functions. Replace with decorator-based API on composio.experimental:

  @composio.experimental.tool()
  def grep(input: GrepInput, ctx):
      """Search for a pattern."""
      return {"matches": []}

  @composio.experimental.tool(extends_toolkit="gmail")
  def create_draft(input: DraftInput, ctx):
      """Create a Gmail draft."""
      return ctx.proxy_execute(toolkit="gmail", ...)

  dev_tools = composio.experimental.Toolkit(
      slug="DEV_TOOLS", name="Dev Tools", description="Dev utilities",
  )

  @dev_tools.tool()
  def search_code(input: SearchInput, ctx):
      """Search code."""
      return {"results": []}

Decorator infers slug (fn name uppercased), name (humanized), description
(docstring), and input_params (first BaseModel-typed parameter). All can
be overridden with explicit kwargs. Supports @bare, @tool(), and
@tool(extends_toolkit=...) forms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:11:03 -07:00
Dhawal Upadhyay 27a23ad669 feat(python): add custom tools and toolkits for tool router sessions
Port the TypeScript custom tools feature to the Python SDK, enabling
developers to define local tools that run in-process alongside remote
Composio tools within a session.

Three tool patterns supported:
- Standalone tools (no auth)
- Extension tools (inherits auth from a Composio toolkit via extends_toolkit)
- Custom toolkits (groups related tools under one namespace)

Key implementation:
- Factory functions: experimental_create_tool() and experimental_create_toolkit()
- Pydantic BaseModel for input schema (equivalent of Zod in TS)
- SessionContext with execute() for sibling routing and proxy_execute() for auth proxy
- COMPOSIO_MULTI_EXECUTE_TOOL routing: splits local/remote, parallel execution via ThreadPoolExecutor (max 5 workers)
- Custom tools map built from backend response (authoritative slug mapping)
- Bumps composio-client to 1.29.0 for custom_tools/custom_toolkits/proxy_execute types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:11:03 -07:00
Musthaq Ahamad 2bccee8d55 feat(python): add file upload/download support and ToolRouterSession refactor (#2865) 2026-03-10 13:15:48 +05:30
jkomyno b6aa489d45 feat(core): add typed schema for connection expired webhook events
Add Zod schema (TypeScript) and TypedDict (Python) for typed handling
of `composio.connected_account.expired` webhook events.

Schemas:
- ConnectionExpiredEventSchema: Full webhook event envelope validation
- SingleConnectedAccountDetailedResponseSchema: Matches GET API response
- WebhookConnectionMetadataSchema: Project and org ID metadata

This builds on PR #2553 which loosened V3 detection to accept any
composio.* event type. Users can now type-safely parse connection
expiration events in their webhook handlers.

Linear: PLEN-1398
2026-02-02 23:44:18 +04:00
Musthaq Ahamad b750b06c60 Fix python sdk type issues (#1949) 2025-09-17 00:50:09 +05:30
Musthaq Ahamad 7077cee688 [WIP] Feat: Add versioning support for tools (#1926)
Co-authored-by: Jayesh Sharma <wjayesh@outlook.com>
2025-09-16 12:15:32 +05:30
angrybayblade 15d476df67 fix: send more event data for telemetry in python SDK 2025-06-18 15:29:15 +05:30
angrybayblade 860b1c444a chore: port python sdk to python/ 2025-06-17 12:58:00 +05:30