@devries-cameron20 / composio Mirror · read-only / commits / 57de614f5
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 08:30 UTC

feat: prepare core, CLI and Python SDK for `@composio/client` rc.19 (#4920)

This PR: - no Linear issue - moves `@composio/client` (pnpm catalog and lockfile) and `composio-client` (`python/pyproject.toml`, `python/setup.py`, `uv.lock`) from `2.0.0-rc.18` to `2.0.0-rc.19` ([release](https://github.com/ComposioHQ/composio-client/releases/tag/client-v2.0.0-rc.19), https://github.com/ComposioHQ/composio-client/pull/95), covering the TypeScript SDK, Python SDK, and CLI - core: forwards the client's log lines through a `Console`-shaped object (`clientLogForwarder`) instead of the client's `Logger` interface, which rc.19 removes. Same levels and sink - CLI: drops `deprecationNotices: 'off'` (including from the link handler test that #4921 added); the root logger wraps `consolePretty` in `withoutClientNotices`, which drops records matching the client's `isDeprecationNotice` (a log annotation, not the message text). Raising the CLI-wide `MinimumLogLevel` would also hide the CLI's own warnings - Python SDK: `HttpClient` stops accepting and forwarding `default_query`, which rc.19 removes - breaking (core and slim, minor changeset `client-rc19-logging`): with rc.19, `getClient()` no longer exposes `apiKey`/`userApiKey`/`orgApiKey`/`logger`, and its configuration fields are read-only - updates the CLI `CHANGELOG.md` entry and the version quoted in `ts/packages/cli/AGENTS.md` - fixes three review findings left on #4914: - core: an `x-org-api-key` default header alone now satisfies `apiKey: null` (it threw `ComposioNoAPIKeyError` before the header was folded into `Auth.organization`) - core: with only an organization key, trigger channel authorization and `session.mcp.headers` now carry `x-org-api-key`, as every API request already did (they went out without a credential). The `client-auth-scope` changeset says so - CLI: `clientScopeKey` includes a SHA-256 fingerprint of the client's credential (never the key), so two user keys on the same org, project and user no longer share one `listActiveConnectedAccounts` result Rebased on `next` after https://github.com/ComposioHQ/composio/pull/4914 merged. Verified locally on the published `2.0.0-rc.19`: - `pnpm typecheck` (workspace), `typecheck:examples`, `lint`, CLI `lint:effect` and `validate:changesets` pass - `pnpm turbo test` core: 73 files, 1882 passed, 2 expected fail; CLI: 157 files, 1870 passed, 1 skipped (the new regression tests fail without the fixes) - `nox -s tst` (python/): 2419 passed, 4 skipped; `nox -s chk` passes; `uv lock --check` passes - live, against staging: the `session-management`, `toolkits`, `tools/tool-conversion` and `openai/smoke` examples run green with bun; the Python SDK executes a tool and creates a session - live CLI from source (`bun run src/bin.ts`): `whoami`, `orgs list` and `execute HACKERNEWS_GET_USER` succeed

Alberto Schiabel committed Oct 16, 2026 at 13:23 UTC 57de614f5bd3673f393c43e0d83935166750ce31
30 files changed +220 -69
.changeset/client-auth-scope.md
+1 -1
@@ -3,7 +3,7 @@
3 '@composio/slim': minor
4 ---
5
6 -Requires `@composio/client` `2.0.0-rc.18`. The SDK now hands the API client its credential as the client's `auth` option and its organization and project as `scope`, instead of placing them in default headers. The `apiKey`, `userApiKey`, `orgApiKey`, `orgId` and `projectId` options, their environment fallbacks and the credentials sent on each request are unchanged, with one exception: with `apiKey: null` and only an organization API key, every request now carries `x-org-api-key`. Before, only the organization-owner operations did, and every other request went out without a credential.
6 +Requires `@composio/client` `2.0.0-rc.18`. The SDK now hands the API client its credential as the client's `auth` option and its organization and project as `scope`, instead of placing them in default headers. The `apiKey`, `userApiKey`, `orgApiKey`, `orgId` and `projectId` options, their environment fallbacks and the credentials sent on each request are unchanged, with one exception: with `apiKey: null` and only an organization API key (the `orgApiKey` option, `COMPOSIO_ORG_API_KEY`, or an `x-org-api-key` default header), every request now carries `x-org-api-key`, and so do trigger channel authorization and `session.mcp.headers`. Before, only the organization-owner operations did, and every other request went out without a credential.
7
8 Credential and scope headers in `defaultHeaders` or `createSession({ headers })` keep working, but the SDK folds them into its own options instead of forwarding them: an `x-user-api-key` or `x-org-api-key` entry becomes the credential every request carries, an `x-api-key` entry becomes the project key, and `x-org-id` / `x-project-id` entries become `orgId` / `projectId`. `getConfig()` reports the folded values (for example `apiKey: null` and `userApiKey` for an `x-user-api-key` entry) and no longer lists those entries under `defaultHeaders`. Setting more than one of `x-api-key`, `x-user-api-key` and `x-org-api-key` now throws a `ComposioError`; the API rejected every such request.
9
.changeset/client-rc19-logging.md new
+6
@@ -0,0 +1,6 @@
1 +---
2 +'@composio/core': minor
3 +'@composio/slim': minor
4 +---
5 +
6 +Requires `@composio/client` `2.0.0-rc.19`. The SDK forwards the API client's log lines through a `Console`-shaped object instead of the client's removed `Logger` interface; what is logged, and at which SDK level, is unchanged. With rc.19, the client returned by `getClient()` no longer has `apiKey`, `userApiKey`, `orgApiKey` or `logger`, and its `baseURL`, `maxRetries`, `timeout` and `logLevel` are read-only: read the keys from `getConfig()`, and derive a client with `withOptions()` to change the others.
pnpm-lock.yaml
+9 -9
@@ -28,8 +28,8 @@ catalogs:
28 specifier: ^5.20261012.1
29 version: 5.20261012.1
30 '@composio/client':
31 - specifier: 2.0.0-rc.18
32 - version: 2.0.0-rc.18
31 + specifier: 2.0.0-rc.19
32 + version: 2.0.0-rc.19
33 '@effect/language-service':
34 specifier: ^0.87.4
35 version: 0.87.4
@@ -968,7 +968,7 @@ importers:
968 dependencies:
969 '@composio/client':
970 specifier: 'catalog:'
971 - version: 2.0.0-rc.18(effect@4.0.3)
971 + version: 2.0.0-rc.19(effect@4.0.3)
972 '@composio/core':
973 specifier: workspace:*
974 version: link:../../packages/core
@@ -1216,7 +1216,7 @@ importers:
1216 version: link:../cli-keyring
1217 '@composio/client':
1218 specifier: 'catalog:'
1219 - version: 2.0.0-rc.18(effect@4.0.3)
1219 + version: 2.0.0-rc.19(effect@4.0.3)
1220 '@composio/core':
1221 specifier: workspace:*
1222 version: link:../core
@@ -1322,7 +1322,7 @@ importers:
1322 dependencies:
1323 '@composio/client':
1324 specifier: 'catalog:'
1325 - version: 2.0.0-rc.18(effect@4.0.3)
1325 + version: 2.0.0-rc.19(effect@4.0.3)
1326 '@composio/json-schema-to-zod':
1327 specifier: workspace:*
1328 version: link:../json-schema-to-zod
@@ -1727,7 +1727,7 @@ importers:
1727 dependencies:
1728 '@composio/client':
1729 specifier: 'catalog:'
1730 - version: 2.0.0-rc.18(effect@4.0.3)
1730 + version: 2.0.0-rc.19(effect@4.0.3)
1731 '@composio/json-schema-to-zod':
1732 specifier: workspace:*
1733 version: link:../json-schema-to-zod
@@ -2291,8 +2291,8 @@ packages:
2291 resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
2292 engines: {node: '>=0.1.90'}
2293
2294 - '@composio/client@2.0.0-rc.18':
2295 - resolution: {integrity: sha512-O7zIJfapLBVLkmSXf2Oqp/jsQ3st2XfOg8q7V/bliIg8akDmuflc6cwgGriFE3sV2HaaoAyqbtLqaF+ihXGMLg==}
2294 + '@composio/client@2.0.0-rc.19':
2295 + resolution: {integrity: sha512-EdBq7KXefbLXwK4F4wUtlG/e37pSxBQCAjJLRAgb0tHhiifDVqsmB/9AzLzpDsDfDKL/3UMUtYUiVUYaD87BVA==}
2296 engines: {node: '>=22'}
2297 peerDependencies:
2298 effect: '*'
@@ -7581,7 +7581,7 @@ snapshots:
7581 '@colors/colors@1.5.0':
7582 optional: true
7583
7584 - '@composio/client@2.0.0-rc.18(effect@4.0.3)':
7584 + '@composio/client@2.0.0-rc.19(effect@4.0.3)':
7585 optionalDependencies:
7586 effect: 4.0.3
7587
pnpm-workspace.yaml
+1 -1
@@ -33,7 +33,7 @@ catalog:
33 '@clack/prompts': '^1.8.1'
34 '@cloudflare/vitest-pool-workers': 0.23.0
35 '@cloudflare/workers-types': ^5.20261012.1
36 - '@composio/client': 2.0.0-rc.18
36 + '@composio/client': 2.0.0-rc.19
37 '@effect/language-service': ^0.87.4
38 '@effect/platform-bun': 4.0.3
39 '@effect/vitest': 4.0.3
python/composio/client/__init__.py
+2 -6
@@ -355,7 +355,6 @@ class HttpClient(BaseComposio, WithLogger):
355 timeout: t.Optional[t.Union[float, Timeout, NotGiven]] = NOT_GIVEN,
356 max_retries: int = DEFAULT_MAX_RETRIES,
357 default_headers: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
358 - default_query: t.Optional[t.Mapping[str, object]] = None,
358 identity: t.Optional[ClientIdentity] = None,
359 http_client: t.Optional[Client] = None,
360 logger: t.Optional[logging.Logger] = None,
@@ -380,7 +379,6 @@ class HttpClient(BaseComposio, WithLogger):
379 :param default_headers: The default headers to use for the client. They
380 may not name a credential header while ``auth`` holds a credential, nor
381 a scope header while ``scope`` is set.
383 - :param default_query: The default query parameters to use for the client.
382 :param identity: How the client reports the SDK; derived from ``provider``
383 when omitted. Clones pass the parent's.
384 :param http_client: The HTTP client to use for the client.
@@ -395,16 +393,14 @@ class HttpClient(BaseComposio, WithLogger):
393 timeout=timeout,
394 max_retries=max_retries,
395 default_headers=default_headers,
398 - default_query=default_query,
396 http_client=http_client,
397 identity=identity if identity is not None else _client_identity(provider),
398 _strict_response_validation=_strict_response_validation,
399 )
400 # The SDK's own reference to the credentials it authenticated with, for
401 # the places that hand a key to something other than this client (the
405 - # session MCP config, the realtime channel auth). The client's
406 - # `api_key` / `user_api_key` read-back properties go in 2.0.0-rc.19,
407 - # and `auth` is the generated `/auth` resource.
402 + # session MCP config, the realtime channel auth). The client reads no
403 + # key back, and `auth` is the generated `/auth` resource.
404 self.sdk_auth: Auth = auth
405 _install_client_log_forwarder(self._logger)
406 self.provider = provider
python/pyproject.toml
+1 -1
@@ -7,7 +7,7 @@ requires-python = ">=3.11,<3.16"
7 dependencies = [
8 "pysher>=1.0.8",
9 "pydantic>=2.11.9",
10 - "composio-client==2.0.0rc18",
10 + "composio-client==2.0.0rc19",
11 "typing-extensions>=4.16.0",
12 "openai>=2.48.0",
13 "json-schema-to-pydantic>=0.4.11",
python/setup.py
+1 -1
@@ -25,7 +25,7 @@ setup(
25 install_requires=[
26 "pysher>=1.0.8",
27 "pydantic>=2.11.9",
28 - "composio-client==2.0.0rc18",
28 + "composio-client==2.0.0rc19",
29 "typing-extensions>=4.16.0",
30 "openai>=2.48.0",
31 "json-schema-to-pydantic>=0.4.11",
ts/packages/cli/AGENTS.md
+2 -2
@@ -117,7 +117,7 @@ test/src/commands/<group>/<shared-module>.test.ts group helper
117 | `JsPackageManagerDetector` | Detects npm/pnpm/yarn/bun for install instructions |
118 | `UpgradeBinary` | Fetches latest release from GitHub, downloads and replaces binary |
119
120 -Every Composio API request goes through an Effect client from `@composio/client/effect`, obtained from `ComposioClientSingleton` (`src/services/composio-clients.ts`). Clients are built with `make`, which never reads the ambient environment: the user key and base URL come from the CLI's own configuration. Each client is built with `deprecationNotices: 'off'`, the CLI's `identity` (`cliClientIdentity()` in `client-provenance.ts`, from which the client sends the provenance headers and which makes it refuse them in `defaultHeaders` and per-call `headers`), `auth` (`Auth.user` with the user key, `Auth.project` when a caller passes `projectApiKey`, `Auth.none()` before login), `scope` (the org and project, when both are known), `x-cli-session-id` as the one default header (read once per process), and a counting `fetch` (`composio-client-metrics.ts`) provided as the transport's `FetchHttpClient.Fetch`. Explicitly configured HTTP base URLs remain supported without an additional environment flag. `composio-clients.ts` holds client construction, the two repositories, and the `collectAll` and `sortBySlug` helpers the catalog fetches share. The repository's auth-config, connected-account, trigger-instance, search, and single-item methods live in `src/services/composio-resource-operations.ts`; the account helpers (`listOrganizations`, `getSessionInfo*`, `resolveConsumerProject`, `createProjectApiKey`, `getLatestToolVersion`, …) in `src/services/composio-account.ts`; toolkit version validation and its errors (`InvalidToolkitsError`, `InvalidToolkitVersionsError`) in `src/services/toolkit-version-validation.ts`; the shared error types (`ClientError`, `HttpDecodingError`, `ComposioClientConfigurationError`) in `src/services/composio-errors.ts`; and the shared `decode` helper and `validated` request option in `src/services/composio-request.ts`. There is no CLI error wrapper around a request: the client's tagged errors (`@composio/client/NotFoundError`, `APIConnectionError`, `DecodeError`, …) flow to callers, which recover with `Effect.catchTag` or the client's `isAPIError` guard. Commands that report an API failure and continue with a fallback share one handler, `handleClientApiError` (`src/effects/handle-http-error.ts`), applied with `Effect.catchTag(CLIENT_API_ERROR_TAGS, …)`; the tag list lives in `src/services/composio-errors.ts`. Endpoints the client does not type use the raw `client.get`/`client.post`; `src/services/tool-permissions.ts` reaches them through its own `requestJson`, which raises `services/ToolPermissionsRequestError` because its callers fail closed on that tag. Do not add a raw `fetch` to the Composio backend from `src/commands`, `src/effects`, or `src/services` — the one sanctioned exception is the bundled companion runtime (`run-helpers-runtime.ts`), which runs in the user's spawned process outside the Effect runtime. (`src/services/agents.ts` also calls `fetch`, against the agents service at agents.composio.dev rather than the Composio backend.) oxlint rejects value imports of the `@composio/client` root and `@composio/client/pagination` from CLI `src/`; type-only imports are allowed. The CLI's clients send every request once. A call that is safe to repeat — a read, or a call whose repeat changes nothing on the server — passes the `idempotent` request option (`src/services/composio-request.ts`) and is retried by the client after a connection failure, a timeout, or a 408, 409, 429 or 5xx response; combine it with `validated` as `{ ...idempotent, ...validated }`. Creates, updates, deletes, links, sessions, tool executions and proxied calls never pass it, because a request that failed in flight may already have acted. It also rejects importing `make` or the client layers from `@composio/client/effect` anywhere but `composio-clients.ts`, and `getFor` takes an org and a project together or neither, because the two headers are only sent as a pair. Every `getFor` builds a new client, so never key a memo on a client instance: `clientScopeKey(client)` gives its auth mode, org, and project (`listActiveConnectedAccounts` keys on it and the user id). While a client has `auth` and `scope`, a per-call `x-api-key`, `x-user-api-key`, `x-org-api-key`, `x-org-id` or `x-project-id` header fails the call before it is sent; an org or project known alone goes on an unscoped client's request, as `orgScopedOptions` and `getLatestToolVersion` do. Client errors are classified for display by `src/utils/api-error-extraction.ts`.
120 +Every Composio API request goes through an Effect client from `@composio/client/effect`, obtained from `ComposioClientSingleton` (`src/services/composio-clients.ts`). Clients are built with `make`, which never reads the ambient environment: the user key and base URL come from the CLI's own configuration. Each client is built with the CLI's `identity` (`cliClientIdentity()` in `client-provenance.ts`, from which the client sends the provenance headers and which makes it refuse them in `defaultHeaders` and per-call `headers`), `auth` (`Auth.user` with the user key, `Auth.project` when a caller passes `projectApiKey`, `Auth.none()` before login), `scope` (the org and project, when both are known), `x-cli-session-id` as the one default header (read once per process), and a counting `fetch` (`composio-client-metrics.ts`) provided as the transport's `FetchHttpClient.Fetch`. Explicitly configured HTTP base URLs remain supported without an additional environment flag. The client's deprecation notices, which CLI users cannot act on, are dropped by the root logger (`withoutClientNotices`, `src/effects/without-client-notices.ts`, through the client's `isDeprecationNotice`). `composio-clients.ts` holds client construction, the two repositories, and the `collectAll` and `sortBySlug` helpers the catalog fetches share. The repository's auth-config, connected-account, trigger-instance, search, and single-item methods live in `src/services/composio-resource-operations.ts`; the account helpers (`listOrganizations`, `getSessionInfo*`, `resolveConsumerProject`, `createProjectApiKey`, `getLatestToolVersion`, …) in `src/services/composio-account.ts`; toolkit version validation and its errors (`InvalidToolkitsError`, `InvalidToolkitVersionsError`) in `src/services/toolkit-version-validation.ts`; the shared error types (`ClientError`, `HttpDecodingError`, `ComposioClientConfigurationError`) in `src/services/composio-errors.ts`; and the shared `decode` helper and `validated` request option in `src/services/composio-request.ts`. There is no CLI error wrapper around a request: the client's tagged errors (`@composio/client/NotFoundError`, `APIConnectionError`, `DecodeError`, …) flow to callers, which recover with `Effect.catchTag` or the client's `isAPIError` guard. Commands that report an API failure and continue with a fallback share one handler, `handleClientApiError` (`src/effects/handle-http-error.ts`), applied with `Effect.catchTag(CLIENT_API_ERROR_TAGS, …)`; the tag list lives in `src/services/composio-errors.ts`. Endpoints the client does not type use the raw `client.get`/`client.post`; `src/services/tool-permissions.ts` reaches them through its own `requestJson`, which raises `services/ToolPermissionsRequestError` because its callers fail closed on that tag. Do not add a raw `fetch` to the Composio backend from `src/commands`, `src/effects`, or `src/services` — the one sanctioned exception is the bundled companion runtime (`run-helpers-runtime.ts`), which runs in the user's spawned process outside the Effect runtime. (`src/services/agents.ts` also calls `fetch`, against the agents service at agents.composio.dev rather than the Composio backend.) oxlint rejects value imports of the `@composio/client` root and `@composio/client/pagination` from CLI `src/`; type-only imports are allowed. The CLI's clients send every request once. A call that is safe to repeat — a read, or a call whose repeat changes nothing on the server — passes the `idempotent` request option (`src/services/composio-request.ts`) and is retried by the client after a connection failure, a timeout, or a 408, 409, 429 or 5xx response; combine it with `validated` as `{ ...idempotent, ...validated }`. Creates, updates, deletes, links, sessions, tool executions and proxied calls never pass it, because a request that failed in flight may already have acted. It also rejects importing `make` or the client layers from `@composio/client/effect` anywhere but `composio-clients.ts`, and `getFor` takes an org and a project together or neither, because the two headers are only sent as a pair. Every `getFor` builds a new client, so never key a memo on a client instance: `clientScopeKey(client)` gives its auth mode, a SHA-256 fingerprint of its credential (never the key), org, and project (`listActiveConnectedAccounts` keys on it and the user id). While a client has `auth` and `scope`, a per-call `x-api-key`, `x-user-api-key`, `x-org-api-key`, `x-org-id` or `x-project-id` header fails the call before it is sent; an org or project known alone goes on an unscoped client's request, as `orgScopedOptions` and `getLatestToolVersion` do. Client errors are classified for display by `src/utils/api-error-extraction.ts`.
121
122 Services are `Context.Service` classes that export a `<Name>Shape` type and an explicit `static readonly Default` layer (`Layer.effect` / `Layer.sync`, dependencies provided with `Layer.provide`). Build a test double with `Service.of({ ... })`; there are no generated accessors or constructors.
123
@@ -153,7 +153,7 @@ Steps 3–4 (and the TypeScript compiler they need) ship as the `generation-runt
153
154 ### Key Dependencies
155
156 -`effect` (pinned `4.0.3`; `@effect/cli` and `@effect/platform` no longer exist as separate packages — folded into `effect`'s barrel and `effect/{cli,http,process}`), `@effect/platform-bun`, `@effect/vitest` (same exact pin), `@clack/prompts` (terminal UI — stderr by default), `picocolors`, `@composio/client` (owned Composio API client, `2.0.0-rc.18` via the workspace catalog; the CLI calls it through the `@composio/client/effect` entry point and imports only types from the rest of the package), `@composio/core` (types), `@composio/ts-builders` (AST gen), `@composio/cli-keyring` (OS credential store), `@composio/json-schema-to-effect-schema`, `semver`, `open`, `extract-zip`.
156 +`effect` (pinned `4.0.3`; `@effect/cli` and `@effect/platform` no longer exist as separate packages — folded into `effect`'s barrel and `effect/{cli,http,process}`), `@effect/platform-bun`, `@effect/vitest` (same exact pin), `@clack/prompts` (terminal UI — stderr by default), `picocolors`, `@composio/client` (owned Composio API client, `2.0.0-rc.19` via the workspace catalog; the CLI calls it through the `@composio/client/effect` entry point and imports only types from the rest of the package), `@composio/core` (types), `@composio/ts-builders` (AST gen), `@composio/cli-keyring` (OS credential store), `@composio/json-schema-to-effect-schema`, `semver`, `open`, `extract-zip`.
157
158 ## Output Conventions: Composable CLI Output
159
ts/packages/cli/CHANGELOG.md
+3 -1
@@ -11,7 +11,7 @@
11 developer project, an incomplete link response, a toolkit whose auth
12 Composio does not manage, and the waiting and timeout lines shown while a
13 link is pending. Exit codes and the JSON printed on stdout are unchanged.
14 -- The CLI now uses `@composio/client@2.0.0-rc.18` (up from `2.0.0-rc.17`). No
14 +- The CLI now uses `@composio/client@2.0.0-rc.19` (up from `2.0.0-rc.17`). No
15 command changes.
16 - API requests now authenticate through the API client's `auth` option (the
17 logged-in user's API key, or no credential before login) and name the org and
@@ -20,6 +20,8 @@
20 unchanged. The CLI no longer keeps a client per API key and project for the
21 life of the process, so the user API key is held only by the client making
22 the request.
23 +- The API client's deprecation notices are dropped by the CLI's logger instead
24 + of being turned off in the client. Nothing new is printed.
25
26 ## 0.4.5
27
ts/packages/cli/src/cli-main.ts
+5 -1
@@ -13,6 +13,7 @@ import * as BunRuntime from '@effect/platform-bun/BunRuntime';
13 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
14 import * as BunPath from '@effect/platform-bun/BunPath';
15 import { runWithConfig, type RootCommandBootstrap } from 'src/commands';
16 +import { withoutClientNotices } from 'src/effects/without-client-notices';
17 import * as constants from 'src/constants';
18 import { ComposioCliConfig } from 'src/cli-config';
19 import {
@@ -150,7 +151,10 @@ const layers = Layer.mergeAll(
151 FetchHttpClient.layer,
152 StdinLive,
153 TerminalUILive,
153 - Layer.merge(Logger.layer([Logger.consolePretty()]), Layer.succeed(Logger.LogToStderr, true))
154 + Layer.merge(
155 + Logger.layer([withoutClientNotices(Logger.consolePretty())]),
156 + Layer.succeed(Logger.LogToStderr, true)
157 + )
158 ) satisfies RequiredLayer;
159
160 export const teardown: Runtime.Teardown = <E, A>(
ts/packages/cli/src/effects/without-client-notices.ts new
+11
@@ -0,0 +1,11 @@
1 +import { isDeprecationNotice } from '@composio/client/effect';
2 +import { Logger } from 'effect';
3 +
4 +/**
5 + * Drops the API client's deprecation notices, which CLI users cannot act on,
6 + * and passes every other record to `logger`.
7 + */
8 +export const withoutClientNotices = <Message, Output>(
9 + logger: Logger.Logger<Message, Output>
10 +): Logger.Logger<Message, Output | undefined> =>
11 + Logger.make(options => (isDeprecationNotice(options) ? undefined : logger.log(options)));
ts/packages/cli/src/services/composio-clients.ts
+15 -6
@@ -19,6 +19,7 @@ import {
19 import { Session, RetrievedSession } from 'src/models/session';
20 import { TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
21 import { cliClientIdentity } from './client-provenance';
22 +import { sha256Hex } from 'src/utils/checksums';
23 import { getCurrentCwdSessionId } from 'src/analytics/dispatch';
24 import { ComposioUserContext, ComposioUserContextLive } from './user-context';
25 import { ProjectContext } from './project-context';
@@ -127,15 +128,16 @@ export interface ComposioClientSingletonShape {
128 */
129 export type ClientBuildError = ConfigurationError | ComposioClientConfigurationError;
130
130 -// What each client built here addresses: its auth mode, org, and project, never
131 -// its key. `getFor` builds a new client on every call, so a memo over a
132 -// client's reads keys on this rather than on the instance.
131 +// What each client built here addresses: its auth mode, a SHA-256 fingerprint
132 +// of its credential (never the key itself), org, and project. `getFor` builds
133 +// a new client on every call, so a memo over a client's reads keys on this
134 +// rather than on the instance.
135 const clientScopeKeys = new WeakMap<ComposioClientShape, string>();
136 let nextUnscopedClient = 0;
137
138 /**
139 * A memo key for what `client` addresses. Two clients from
138 - * {@link ComposioClientSingleton} with the same auth mode, org, and project
140 + * {@link ComposioClientSingleton} with the same credential, org, and project
141 * share it; a client built anywhere else (a test double) gets one of its own.
142 */
143 export const clientScopeKey = (client: ComposioClientShape): string => {
@@ -191,6 +193,11 @@ const makeComposioClientSingleton = (metrics: ClientMetricsCollector) =>
193 : Auth.none();
194 const orgId = params?.orgId;
195 const projectId = params?.projectId;
196 + const credential = params?.projectApiKey ?? userApiKey;
197 + const credentialFingerprint =
198 + credential !== undefined
199 + ? yield* Effect.promise(() => sha256Hex(new TextEncoder().encode(credential)))
200 + : '';
201
202 const client = yield* Effect.try({
203 try: () =>
@@ -206,7 +213,6 @@ const makeComposioClientSingleton = (metrics: ClientMetricsCollector) =>
213 baseURL: ctx.data.baseURL,
214 // Preserve support for explicitly configured HTTP backends.
215 allowInsecureHTTP: true,
209 - deprecationNotices: 'off',
216 // The identity headers come from here; the client refuses them
217 // in `defaultHeaders`.
218 identity: cliClientIdentity(),
@@ -228,7 +234,10 @@ const makeComposioClientSingleton = (metrics: ClientMetricsCollector) =>
234 cause,
235 }),
236 });
231 - clientScopeKeys.set(client, `${auth.mode}\u0000${orgId ?? ''}\u0000${projectId ?? ''}`);
237 + clientScopeKeys.set(
238 + client,
239 + `${auth.mode}\u0000${credentialFingerprint}\u0000${orgId ?? ''}\u0000${projectId ?? ''}`
240 + );
241 return client;
242 });
243
ts/packages/cli/src/services/connected-account-selection.ts
+5 -4
@@ -141,10 +141,11 @@ export const formatConnectedAccountChoices = (
141 items.filter(isUsableConnectedAccount).sort(compareNewestFirst).map(formatConnectedAccountChoice);
142
143 /**
144 - * Every active connected account of `userId`, fetched once per org, project,
145 - * and user for the lifetime of the process. The client's org and project come
146 - * from `clientScopeKey`: each `getFor` builds a new client, so two callers
147 - * holding different instances for the same project still share one fetch.
144 + * Every active connected account of `userId`, fetched once per credential,
145 + * org, project, and user for the lifetime of the process. The client's
146 + * credential, org, and project come from `clientScopeKey`: each `getFor`
147 + * builds a new client, so two callers holding different instances for the
148 + * same key and project still share one fetch.
149 *
150 * `composio execute` needs this list twice on every call, from two code paths
151 * that cannot see each other: `resolveConnectedAccountForToolkit` picks the
ts/packages/cli/test/__utils__/services/stub-composio-client.ts
-1
@@ -43,7 +43,6 @@ export const stubComposioClient = (
43 {
44 auth: Auth.project('test'),
45 baseURL: 'https://stub.invalid',
46 - deprecationNotices: 'off',
46 maxRetries: 0,
47 schemas: schemaLoaders,
48 },
ts/packages/cli/test/__utils__/services/test-layer.ts
-1
@@ -774,7 +774,6 @@ export const TestLayer = (input?: TestLiveInput) =>
774 {
775 auth: Auth.project('test'),
776 baseURL: 'https://mock.invalid',
777 - deprecationNotices: 'off',
777 },
778 dieOnNetworkCall
779 ),
ts/packages/cli/test/src/commands/connected-accounts/link/connected-accounts.link.handler.test.ts
-1
@@ -128,7 +128,6 @@ const baseClient = make(
128 {
129 auth: Auth.project('test'),
130 baseURL: 'https://mock.invalid',
131 - deprecationNotices: 'off',
131 },
132 HttpClient.make(request =>
133 Effect.die(new Error(`unexpected network call from the link handler test: ${request.url}`))
ts/packages/cli/test/src/effects/without-client-notices.test.ts new
+17
@@ -0,0 +1,17 @@
1 +import { describe, expect, it } from '@effect/vitest';
2 +import { Effect, Logger } from 'effect';
3 +import { withoutClientNotices } from 'src/effects/without-client-notices';
4 +
5 +describe('withoutClientNotices', () => {
6 + it.effect('keeps a record that only reads like a client notice', () => {
7 + const seen: Array<unknown> = [];
8 + const recording = Logger.make(({ message }) => {
9 + seen.push(message);
10 + });
11 + return Effect.gen(function* () {
12 + yield* Effect.logWarning('Composio: the CLI warns about something');
13 +
14 + expect(seen).toStrictEqual([['Composio: the CLI warns about something']]);
15 + }).pipe(Effect.provide(Logger.layer([withoutClientNotices(recording)])));
16 + });
17 +});
ts/packages/cli/test/src/services/composio-client-singleton.test.ts
+23 -8
@@ -14,6 +14,7 @@ import { stubComposioClient } from 'test/__utils__/services/stub-composio-client
14 import { idempotent, validated } from 'src/services/composio-request';
15 import { APP_VERSION } from 'src/constants';
16 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
17 +import { withoutClientNotices } from 'src/effects/without-client-notices';
18
19 // Exercise real user-context/config resolution without opening the OS credential store.
20 vi.mock('@composio/cli-keyring/effect', async importOriginal => {
@@ -493,13 +494,14 @@ describe('ComposioClientSingleton client', () => {
494 }).pipe(Effect.provide(singletonLayer(baseConfig())));
495 });
496
496 - it.effect('keys clients for a memo by auth mode, org, and project, never by instance', () =>
497 + it.effect('keys clients for a memo by credential, org, and project, never by instance', () =>
498 Effect.gen(function* () {
499 const clientSingleton = yield* ComposioClientSingleton;
500 const scope = { userApiKey: 'uak_a', orgId: 'org_a', projectId: 'proj_a' };
501
502 const first = yield* clientSingleton.getFor(scope);
502 - const second = yield* clientSingleton.getFor({ ...scope, userApiKey: 'uak_b' });
503 + const second = yield* clientSingleton.getFor(scope);
504 + const otherKey = yield* clientSingleton.getFor({ ...scope, userApiKey: 'uak_b' });
505 const otherProject = yield* clientSingleton.getFor({ ...scope, projectId: 'proj_b' });
506 const projectKey = yield* clientSingleton.getFor({
507 projectApiKey: 'ak_a',
@@ -510,6 +512,7 @@ describe('ComposioClientSingleton client', () => {
512
513 expect(second).not.toBe(first);
514 expect(clientScopeKey(second)).toBe(clientScopeKey(first));
515 + expect(clientScopeKey(otherKey)).not.toBe(clientScopeKey(first));
516 expect(clientScopeKey(otherProject)).not.toBe(clientScopeKey(first));
517 expect(clientScopeKey(projectKey)).not.toBe(clientScopeKey(first));
518 expect(clientScopeKey(first)).not.toContain('uak_a');
@@ -519,7 +522,7 @@ describe('ComposioClientSingleton client', () => {
522 }).pipe(Effect.provide(singletonLayer(baseConfig())))
523 );
524
522 - it.effect('lists active connected accounts once per org, project, and user', () => {
525 + it.effect('lists active connected accounts once per credential, org, project, and user', () => {
526 const fetchSpy = vi.spyOn(globalThis, 'fetch').mockImplementation(() =>
527 Promise.resolve(
528 new Response(
@@ -559,6 +562,13 @@ describe('ComposioClientSingleton client', () => {
562 userId: 'user_2',
563 });
564 expect(fetchSpy).toHaveBeenCalledTimes(3);
565 +
566 + // Another user key on the same scope never reads the first key's list.
567 + yield* listActiveConnectedAccounts({
568 + client: yield* clientSingleton.getFor({ ...scope, userApiKey: 'uak_other' }),
569 + userId: 'user_1',
570 + });
571 + expect(fetchSpy).toHaveBeenCalledTimes(4);
572 }).pipe(Effect.provide(singletonLayer(baseConfig([['COMPOSIO_USER_API_KEY', 'uak_memo']]))));
573 });
574
@@ -695,7 +705,7 @@ describe('ComposioClientSingleton client', () => {
705 );
706 });
707
698 - it.effect('logs nothing for a response that announces a deprecation', () => {
708 + it.effect('drops the deprecation notice the client logs at the CLI logger', () => {
709 vi.spyOn(globalThis, 'fetch').mockResolvedValue(
710 new Response(JSON.stringify({ data: [] }), {
711 status: 200,
@@ -707,11 +717,15 @@ describe('ComposioClientSingleton client', () => {
717 },
718 })
719 );
710 - const records: Array<unknown> = [];
711 - const capturingLogger = Logger.layer([
720 + const logged: Array<unknown> = [];
721 + const shown: Array<unknown> = [];
722 + const recordInto = (records: Array<unknown>) =>
723 Logger.make<unknown, void>(({ message }) => {
724 records.push(message);
714 - }),
725 + });
726 + const capturingLogger = Logger.layer([
727 + recordInto(logged),
728 + withoutClientNotices(recordInto(shown)),
729 ]);
730
731 return Effect.gen(function* () {
@@ -719,7 +733,8 @@ describe('ComposioClientSingleton client', () => {
733 const client = yield* clientSingleton.get();
734 yield* listTools(client);
735
722 - expect(records).toEqual([]);
736 + expect(logged).toHaveLength(1);
737 + expect(shown).toEqual([]);
738 }).pipe(
739 Effect.provide(
740 Layer.merge(
ts/packages/cli/test/src/services/tool-file-uploads.test.ts
-1
@@ -231,7 +231,6 @@ describe('uploadToolInputFiles — presigned-URL request', () => {
231 {
232 auth: Auth.project('test'),
233 baseURL: 'https://stub.invalid',
234 - deprecationNotices: 'off',
234 },
235 HttpClient.make(() =>
236 Effect.sync(() => reached.resolve()).pipe(
ts/packages/core/src/composio.ts
+8 -8
@@ -1,7 +1,7 @@
1 import { getEnvVariable } from './utils/env';
2 import type { BaseComposioProvider } from './provider/BaseProvider';
3 import ComposioClient from '@composio/client';
4 -import type { Logger as ClientLogger, LogLevel as ClientLogLevel } from '@composio/client';
4 +import type { LogLevel as ClientLogLevel } from '@composio/client';
5 import { Tools } from './models/Tools';
6 import { Toolkits } from './models/Toolkits';
7 import { Triggers } from './models/Triggers';
@@ -50,7 +50,7 @@ export type ComposioConfig<
50 * project key; the SDK throws instead of sending it.
51 * - `null`: disables project-key authentication entirely, including both fallbacks. The SDK
52 * then requires another credential (`userApiKey`, `orgApiKey`, or an `x-user-api-key`
53 - * entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
53 + * or `x-org-api-key` entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
54 * `defaultHeaders` is rejected, also on `createSession()` clones. The user API key
55 * then authenticates every request; the organization API key does when it is the
56 * only credential held.
@@ -299,11 +299,11 @@ const toClientLogLevel = (level: LogLevel): ClientLogLevel => {
299 * at call time so a later `logger.configure()` is honoured. The client's
300 * `info` records (per-request lifecycle) are forwarded as SDK `debug`.
301 */
302 -const clientLoggerAdapter: ClientLogger = {
303 - error: (...args) => logger.error(...args),
304 - warn: (...args) => logger.warn(...args),
305 - info: (...args) => logger.debug(...args),
306 - debug: (...args) => logger.debug(...args),
302 +const clientLogForwarder: Pick<Console, 'debug' | 'info' | 'warn' | 'error'> = {
303 + error: (...args: unknown[]) => logger.error(...args),
304 + warn: (...args: unknown[]) => logger.warn(...args),
305 + info: (...args: unknown[]) => logger.debug(...args),
306 + debug: (...args: unknown[]) => logger.debug(...args),
307 };
308
309 /**
@@ -552,7 +552,7 @@ export class Composio<
552 : {}),
553 defaultHeaders,
554 identity: getClientIdentity(this.provider),
555 - logger: clientLoggerAdapter,
555 + logger: clientLogForwarder,
556 logLevel: toClientLogLevel(logger.getLevel()),
557 });
558
ts/packages/core/src/lib/toolRouterMcp.ts
+2
@@ -71,6 +71,8 @@ export type MCPServerConfigInput = {
71 apiKey: string | null | undefined;
72 /** The user API key the client resolved (`userApiKey` option or `COMPOSIO_USER_API_KEY`). */
73 userApiKey: string | null | undefined;
74 + /** The organization API key the client resolved (`orgApiKey` option or `COMPOSIO_ORG_API_KEY`). */
75 + orgApiKey?: string | null;
76 /** The default headers configured on the SDK instance; only `x-user-api-key` is consulted. */
77 defaultHeaders: ComposioRequestHeaders | undefined;
78 /** Organization nano ID the instance is scoped to, if any. */
ts/packages/core/src/models/ToolRouter.ts
+3 -1
@@ -139,7 +139,8 @@ export class ToolRouter<
139 /**
140 * Derives the MCP config for a session from the auth context the session
141 * request was made with: the project key when one is configured, otherwise
142 - * the resolved user API key, plus the org/project scope when configured.
142 + * the resolved user API key, otherwise the organization API key, plus the
143 + * org/project scope when configured.
144 * Headers are only attached when the MCP URL shares the client's API
145 * origin. Any other destination throws when the caller passed `mcp: true`
146 * and otherwise yields empty headers plus a warning; see
@@ -155,6 +156,7 @@ export class ToolRouter<
156 apiBaseURL: this.client.baseURL,
157 apiKey: this.config?.apiKey,
158 userApiKey: this.config?.userApiKey,
159 + orgApiKey: this.config?.orgApiKey,
160 defaultHeaders: this.config?.defaultHeaders,
161 orgId: this.config?.orgId,
162 projectId: this.config?.projectId,
ts/packages/core/src/models/Triggers.ts
+1
@@ -161,6 +161,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
161 this.pusherService = new PusherService(client, {
162 apiKey: config?.apiKey,
163 userApiKey: config?.userApiKey,
164 + orgApiKey: config?.orgApiKey,
165 defaultHeaders: config?.defaultHeaders,
166 });
167 this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
ts/packages/core/src/services/pusher/Pusher.ts
+3
@@ -18,6 +18,8 @@ export type PusherServiceOptions = {
18 apiKey?: string | null;
19 /** The user API key the owning SDK instance resolved, or `null`. */
20 userApiKey?: string | null;
21 + /** The organization API key the owning SDK instance resolved, or `null`. */
22 + orgApiKey?: string | null;
23 /** Default headers of the owning SDK instance; only `x-user-api-key` is consulted. */
24 defaultHeaders?: ComposioRequestHeaders;
25 };
@@ -66,6 +68,7 @@ export class PusherService {
68 this.authHeaders = resolveCredentialHeaders({
69 apiKey: options.apiKey,
70 userApiKey: options.userApiKey,
71 + orgApiKey: options.orgApiKey,
72 defaultHeaders: options.defaultHeaders,
73 });
74 telemetry.instrument(this, 'PusherService');
ts/packages/core/src/utils/sdk.ts
+20 -6
@@ -157,8 +157,13 @@ const findHeader = (
157 */
158 export const getUserApiKeyHeader = (
159 headers: ComposioRequestHeaders | undefined
160 +): { name: string; value: string } | undefined => getCredentialHeader(headers, USER_API_KEY_HEADER);
161 +
162 +const getCredentialHeader = (
163 + headers: ComposioRequestHeaders | undefined,
164 + name: string
165 ): { name: string; value: string } | undefined => {
161 - const header = findHeader(headers, USER_API_KEY_HEADER);
166 + const header = findHeader(headers, name);
167 return header && typeof header.value === 'string' && header.value.length > 0 ? header : undefined;
168 };
169
@@ -167,6 +172,8 @@ export type CredentialHeaderInput = {
172 apiKey: string | null | undefined;
173 /** The user API key the client resolved (`userApiKey` option or `COMPOSIO_USER_API_KEY`). */
174 userApiKey: string | null | undefined;
175 + /** The organization API key the client resolved (`orgApiKey` option or `COMPOSIO_ORG_API_KEY`). */
176 + orgApiKey?: string | null;
177 /** The default headers configured on the SDK instance; only `x-user-api-key` is consulted. */
178 defaultHeaders: ComposioRequestHeaders | undefined;
179 };
@@ -177,8 +184,9 @@ export type CredentialHeaderInput = {
184 * headers wins: the client treats a caller-placed credential header as the
185 * credential and suppresses the configured keys. Otherwise the project key
186 * travels as `x-api-key`, otherwise the resolved user API key as
180 - * `x-user-api-key`. Empty when no credential is held. The environment is
181 - * never consulted here.
187 + * `x-user-api-key`, otherwise the organization API key as `x-org-api-key`
188 + * (the order {@link toClientAuth} picks them in). Empty when no credential is
189 + * held. The environment is never consulted here.
190 */
191 export const resolveCredentialHeaders = (input: CredentialHeaderInput): Record<string, string> => {
192 const userApiKeyHeader = getUserApiKeyHeader(input.defaultHeaders);
@@ -191,6 +199,9 @@ export const resolveCredentialHeaders = (input: CredentialHeaderInput): Record<s
199 if (hasValue(input.userApiKey)) {
200 return { [USER_API_KEY_HEADER]: input.userApiKey };
201 }
202 + if (hasValue(input.orgApiKey)) {
203 + return { [ORG_API_KEY_HEADER]: input.orgApiKey };
204 + }
205 return {};
206 };
207
@@ -345,12 +356,14 @@ export const resolveOrgApiKey = (orgApiKey: string | null | undefined): string |
356 /**
357 * Whether the instance holds a credential other than the project key: a user
358 * or organization API key (explicit or environment-resolved, as the API client
348 - * will see it), or a user API key placed in the default headers.
359 + * will see it), or a user or organization API key placed in the default
360 + * headers, which {@link resolveSDKCredentials} folds in.
361 */
362 const hasAlternateCredential = (options: SDKConfigOptions): boolean =>
363 resolveUserApiKey(options.userApiKey) !== undefined ||
364 resolveOrgApiKey(options.orgApiKey) !== undefined ||
353 - getUserApiKeyHeader(options.defaultHeaders) !== undefined;
365 + getUserApiKeyHeader(options.defaultHeaders) !== undefined ||
366 + getCredentialHeader(options.defaultHeaders, ORG_API_KEY_HEADER) !== undefined;
367
368 /**
369 * The credentials an SDK instance authenticates with, after the environment
@@ -465,7 +478,8 @@ export const toClientAuth = (credentials: SDKCredentials): Auth => {
478 * `api_key` is read, and the resolver only succeeds when the instance holds
479 * another credential: a `userApiKey` or `orgApiKey` (explicit, or resolved
480 * from `COMPOSIO_USER_API_KEY` / `COMPOSIO_ORG_API_KEY` the way the API
468 - * client does), or a non-empty `x-user-api-key` entry in `defaultHeaders`.
481 + * client does), or a non-empty `x-user-api-key` or `x-org-api-key` entry in
482 + * `defaultHeaders`.
483 * An `x-api-key` entry in `defaultHeaders` (any letter case) is rejected in
484 * that mode: the project credential is only ever set from `apiKey`.
485 *
ts/packages/core/test/core/credentials.test.ts
+18
@@ -245,6 +245,24 @@ describe('Composio credentials and scope', () => {
245 });
246 });
247
248 + it('authenticates with an x-org-api-key header alone when the project key is disabled', async () => {
249 + const fetchMock = captureFetch();
250 + const composio = new Composio({
251 + ...baseConfig,
252 + apiKey: null,
253 + defaultHeaders: { 'x-org-api-key': 'oak_header' },
254 + });
255 +
256 + expect(composio.getClient().authMode).toBe('organization');
257 + await composio.getClient().toolkits.retrieve('github');
258 +
259 + expect(credentialHeaders(sentHeaders(fetchMock))).toEqual({
260 + 'x-api-key': null,
261 + 'x-user-api-key': null,
262 + 'x-org-api-key': 'oak_header',
263 + });
264 + });
265 +
266 it('takes the project key from an x-api-key header', async () => {
267 const fetchMock = captureFetch();
268 const composio = new Composio({
ts/packages/core/test/core/session.test.ts
+12
@@ -633,6 +633,18 @@ describe('Credential resolution at the transport boundary', () => {
633 expect(session.mcp.headers).toEqual({ 'x-user-api-key': userKey });
634 });
635
636 + it('exports the organization API key placed in defaultHeaders when it is the only credential', async () => {
637 + const orgKey = 'oak_headerOrgKey';
638 + const fetchMock = captureSessionFetch();
639 +
640 + const composio = build({ apiKey: null, defaultHeaders: { 'x-org-api-key': orgKey } });
641 + const session = await composio.sessions.create('user_123', { mcp: true });
642 +
643 + expect(capturedHeaders(fetchMock).get('x-api-key')).toBeNull();
644 + expect(capturedHeaders(fetchMock).get('x-org-api-key')).toBe(orgKey);
645 + expect(session.mcp.headers).toEqual({ 'x-org-api-key': orgKey });
646 + });
647 +
648 it('exports the user API key a clone was given over the key the parent resolved', async () => {
649 const otherUserKey = 'uak_overridingUserKey';
650 const fetchMock = captureSessionFetch();
ts/packages/core/test/services/pusher.test.ts
+12
@@ -470,6 +470,18 @@ describe('PusherService channel authorization credentials', () => {
470 expect(channelAuthHeaders()).toEqual({ 'x-user-api-key': 'uak_userKey' });
471 });
472
473 + it('sends the organization API key when it is the only key the SDK resolved', async () => {
474 + const service = new PusherService({ baseURL } as never, {
475 + apiKey: null,
476 + userApiKey: null,
477 + orgApiKey: 'oak_orgKey',
478 + });
479 +
480 + await service.subscribe(vi.fn());
481 +
482 + expect(channelAuthHeaders()).toEqual({ 'x-org-api-key': 'oak_orgKey' });
483 + });
484 +
485 it('never reads a key back from the API client', async () => {
486 const client = {
487 baseURL,
ts/packages/core/test/utils/sdk.test.ts
+30
@@ -245,6 +245,17 @@ describe('getSDKConfig credential resolution', () => {
245 ).toEqual({ baseURL: DEFAULT_BASE_URL, apiKey: null });
246 });
247
248 + it('resolves to a null project key when an organization API key header is configured', () => {
249 + vi.stubEnv('COMPOSIO_API_KEY', ENV_KEY);
250 +
251 + expect(
252 + getSDKConfig(undefined, null, { defaultHeaders: { 'X-Org-Api-Key': 'oak_headerKey' } })
253 + ).toEqual({ baseURL: DEFAULT_BASE_URL, apiKey: null });
254 + expect(() =>
255 + getSDKConfig(undefined, null, { defaultHeaders: { 'x-org-api-key': '' } })
256 + ).toThrow(ComposioNoAPIKeyError);
257 + });
258 +
259 it('matches the user API key header name case-insensitively', () => {
260 expect(
261 getSDKConfig(undefined, null, { defaultHeaders: { 'X-User-Api-Key': USER_KEY } }).apiKey
@@ -362,6 +373,25 @@ describe('resolveCredentialHeaders', () => {
373 ).toEqual({ 'x-user-api-key': USER_KEY });
374 });
375
376 + it('sends the organization key only when no project or user key is held', () => {
377 + expect(
378 + resolveCredentialHeaders({
379 + apiKey: null,
380 + userApiKey: null,
381 + orgApiKey: 'oak_orgKey',
382 + defaultHeaders: undefined,
383 + })
384 + ).toEqual({ 'x-org-api-key': 'oak_orgKey' });
385 + expect(
386 + resolveCredentialHeaders({
387 + apiKey: null,
388 + userApiKey: USER_KEY,
389 + orgApiKey: 'oak_orgKey',
390 + defaultHeaders: undefined,
391 + })
392 + ).toEqual({ 'x-user-api-key': USER_KEY });
393 + });
394 +
395 it('ignores an empty credential header and returns nothing without a credential', () => {
396 expect(
397 resolveCredentialHeaders({
uv.lock
+9 -9
@@ -757,7 +757,7 @@ dev = [
757
758 [package.metadata]
759 requires-dist = [
760 - { name = "composio-client", specifier = "==2.0.0rc18" },
760 + { name = "composio-client", specifier = "==2.0.0rc19" },
761 { name = "json-schema-to-pydantic", specifier = ">=0.4.11" },
762 { name = "jsonschema", specifier = ">=4.23.0" },
763 { name = "openai", specifier = ">=2.48.0" },
@@ -803,16 +803,16 @@ requires-dist = [
803
804 [[package]]
805 name = "composio-client"
806 -version = "2.0.0rc18"
806 +version = "2.0.0rc19"
807 source = { registry = "https://pypi.org/simple" }
808 dependencies = [
809 { name = "httpx" },
810 { name = "pydantic" },
811 { name = "typing-extensions" },
812 ]
813 -sdist = { url = "https://files.pythonhosted.org/packages/62/cf/dbcfc9ca2f22117a5713c9bda594e94ccc7c0982a4496949bbb5ab19dad9/composio_client-2.0.0rc18.tar.gz", hash = "sha256:b0ee06db35c724fdafc7de2a60600f6cffa845bef83f7989c1f4fb9e628db185", size = 633932, upload-time = "2026-10-15T22:21:53.89Z" }
813 +sdist = { url = "https://files.pythonhosted.org/packages/3c/b0/892c075f29639ae235aed971654ace1295363700f6e722795909bd3a9b43/composio_client-2.0.0rc19.tar.gz", hash = "sha256:565f76236c0fcaece194935fd3e88c73a9fb0250e2d93630fda2abddc0ac807c", size = 632179, upload-time = "2026-10-16T00:41:29.118Z" }
814 wheels = [
815 - { url = "https://files.pythonhosted.org/packages/e1/e5/c17922253b80831c2aa4872ee2dd1161b624db67f937a7228345e3bd73e8/composio_client-2.0.0rc18-py3-none-any.whl", hash = "sha256:3852b2311c35229ef2109d36525bfbc3d696bbd88dd347b731b7d9233d22b199", size = 455413, upload-time = "2026-10-15T22:21:52.271Z" },
815 + { url = "https://files.pythonhosted.org/packages/07/7c/85936107e4353b069a150c830b124df7f092a9af4e5da718ea659ca61581/composio_client-2.0.0rc19-py3-none-any.whl", hash = "sha256:5e93220fd5188b46d05f0e2685d16b59a951ed281754fa3e3338661f22ac3113", size = 452798, upload-time = "2026-10-16T00:41:27.202Z" },
816 ]
817
818 [[package]]
@@ -1749,8 +1749,8 @@ name = "httpcore2"
1749 version = "2.13.0"
1750 source = { registry = "https://pypi.org/simple" }
1751 dependencies = [
1752 - { name = "h11" },
1753 - { name = "truststore" },
1752 + { name = "h11", marker = "python_full_version != '3.12.*' or sys_platform != 'emscripten'" },
1753 + { name = "truststore", marker = "python_full_version != '3.12.*' or sys_platform != 'emscripten'" },
1754 ]
1755 sdist = { url = "https://files.pythonhosted.org/packages/15/8c/e925b1c92018abb3a1863ce1549d76d2381e334d21d65d4ac8f65dabd78a/httpcore2-2.13.0.tar.gz", hash = "sha256:2adc8be4fb285fbcd6d894298db3b52c177e74b6674eda3a76bd36be3292a3db", size = 67740, upload-time = "2026-09-14T14:18:04.717Z" }
1756 wheels = [
@@ -1989,7 +1989,7 @@ name = "importlib-metadata"
1989 version = "9.0.1"
1990 source = { registry = "https://pypi.org/simple" }
1991 dependencies = [
1992 - { name = "zipp" },
1992 + { name = "zipp", marker = "python_full_version < '3.12'" },
1993 ]
1994 sdist = { url = "https://files.pythonhosted.org/packages/6f/7e/1e7e8dc30634b93ebb3d58a3dea569ad146e656218d3960ab04f62047b29/importlib_metadata-9.0.1.tar.gz", hash = "sha256:ab830580bc0ef3db61ce8fae716389e5462b67e033018bab6d8f80ef17172f99", size = 59124, upload-time = "2026-08-28T15:30:34.646Z" }
1995 wheels = [
@@ -4865,8 +4865,8 @@ name = "secretstorage"
4865 version = "3.5.0"
4866 source = { registry = "https://pypi.org/simple" }
4867 dependencies = [
4868 - { name = "cryptography" },
4869 - { name = "jeepney" },
4868 + { name = "cryptography", marker = "python_full_version != '3.12.*' or sys_platform != 'emscripten'" },
4869 + { name = "jeepney", marker = "python_full_version != '3.12.*' or sys_platform != 'emscripten'" },
4870 ]
4871 sdist = { url = "https://files.pythonhosted.org/packages/1c/03/e834bcd866f2f8a49a85eaff47340affa3bfa391ee9912a952a1faa68c7b/secretstorage-3.5.0.tar.gz", hash = "sha256:f04b8e4689cbce351744d5537bf6b1329c6fc68f91fa666f60a380edddcd11be", size = 19884, upload-time = "2025-11-23T19:02:53.191Z" }
4872 wheels = [