@devries-cameron20 / composio-1 / commits / 79c2d1d28
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.

chore: move owned clients to `2.0.0-rc.17` (#4906)

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.16` to `2.0.0-rc.17` ([release](https://github.com/ComposioHQ/composio-client/releases/tag/client-v2.0.0-rc.17), https://github.com/ComposioHQ/composio-client/pull/90), covering the TypeScript SDK, Python SDK, and CLI - core: `getClientIdentity(provider)` replaces `getSessionHeaders`/`getDefaultHeaders`; the client is built with `identity` (`@composio/core` or `@composio/slim`, `TYPESCRIPT_SDK`, the provider name, core's runtime label), and `defaultHeaders` carries only the caller's and the scope headers - CLI: `cliClientIdentity()` feeds `identity` on the Effect client; `cliRequestHeaders()` stays for the requests that do not go through the client (analytics, agents, run helpers) - Python SDK: `ClientIdentity(product="composio", source="PYTHON_SDK", ...)` replaces the identity part of the `_headers_for` override, which now only sets `x-request-id` - breaking (core and slim, minor changeset): an identity header in `defaultHeaders` or `createSession({ headers })` now fails with the client's `ComposioError` instead of being overwritten silently - adds a CLI `CHANGELOG.md` entry and updates the version quoted in `ts/packages/cli/AGENTS.md` ## Context rc.17 makes the client own its identity headers. The three library headers (`x-client-library`, `x-client-library-version`, `x-client-language`) are always the client's; once `identity` is set, so are `x-client-provenance`, `x-client-version`, `x-sdk-version`, `x-source`, `x-framework`, `x-runtime`, `x-client-runtime` and `x-runtime-version`. All three consumers set these by hand through default headers, which rc.17 refuses, so `next` without this PR fails at construction on rc.17. The headers on the wire are the same, with two exceptions. First, `x-client-runtime` and `x-runtime-version` now come from the client's runtime detection, so on Cloudflare Workers or Vercel Edge with Node.js compatibility they name that runtime instead of `nodejs` and its polyfilled version. Second, a provider name that is not a valid header value is sent as `unknown`. Verified locally on the published `2.0.0-rc.17`: - `pnpm typecheck` (workspace): 7/7 tasks; `typecheck:examples` and `lint:examples` pass - `pnpm turbo test` core: 73 files, 1825 passed, 2 expected fail; CLI: 152 files, 1673 passed, 1 skipped - `pnpm --filter @composio/cli run lint:effect`: 0 errors; `validate:changesets`: pass - `make tst` (python/): 2386 passed, 4 skipped; providers 11 + 16 + 6 passed - `nox -s chk` (python/): ruff and mypy pass on `composio/`, `providers/`, `tests/`, `scripts/` The client's hosted release acceptance ran these commits against the candidate before publishing (composio-client run 38795016206): `downstream-compile`, `downstream-python` and `effect-subpath` pass.

Alberto Schiabel committed Oct 16, 2026 at 00:53 UTC 79c2d1d283984eeea3bd402782070667f14e4f66
16 files changed +264 -315
.changeset/client-identity-headers.md new
+10
@@ -0,0 +1,10 @@
1 +---
2 +'@composio/core': minor
3 +'@composio/slim': minor
4 +---
5 +
6 +Requires `@composio/client` `2.0.0-rc.17`. The SDK now reports itself to the API client through the client's `identity` option instead of default headers. The headers sent with each request are unchanged, with one exception: on Cloudflare Workers and Vercel Edge with Node.js compatibility enabled, `x-client-runtime` now names that runtime instead of `nodejs`, and the polyfilled Node.js version is no longer sent as `x-runtime-version`. A `createSession()` clone no longer copies these headers into its `defaultHeaders`.
7 +
8 +The API client owns these headers, so `defaultHeaders` and `createSession({ headers })` now reject `x-client-provenance`, `x-client-version`, `x-client-library`, `x-client-library-version`, `x-client-language`, `x-client-runtime`, `x-sdk-version`, `x-source`, `x-framework`, `x-runtime` and `x-runtime-version` with a `ComposioError` from `@composio/client`. The SDK used to overwrite such entries silently.
9 +
10 +A custom provider whose `name` cannot be sent as a header value (anything other than printable ASCII with no leading or trailing whitespace) is reported as `unknown` in `x-framework`.
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.16
32 - version: 2.0.0-rc.16
31 + specifier: 2.0.0-rc.17
32 + version: 2.0.0-rc.17
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.16(effect@4.0.3)
971 + version: 2.0.0-rc.17(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.16(effect@4.0.3)
1219 + version: 2.0.0-rc.17(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.16(effect@4.0.3)
1325 + version: 2.0.0-rc.17(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.16(effect@4.0.3)
1730 + version: 2.0.0-rc.17(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.16':
2295 - resolution: {integrity: sha512-uT0oWMslDWpv4Hx8ZlVK6YwLhxKk69J41BK5RFs5kTcT1vCTH7jat2uVcW6VS1V8FJAl8ZwKkuruqLmGQJ1BUw==}
2294 + '@composio/client@2.0.0-rc.17':
2295 + resolution: {integrity: sha512-j1fqyiAwAO6kOmbLwkLn4fb4//GNveV2yo0iMo4wTwOk9euRwQNK6lodVcRhJT6ZeRCSS2Xv8uUsJtmGsPTyiA==}
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.16(effect@4.0.3)':
7584 + '@composio/client@2.0.0-rc.17(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.16
36 + '@composio/client': 2.0.0-rc.17
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
+30 -13
@@ -6,6 +6,7 @@ import contextvars
6 import logging
7 import os
8 import platform
9 +import re
10 import typing as t
11 import weakref
12 from importlib.metadata import PackageNotFoundError, version
@@ -17,6 +18,7 @@ from composio_client import (
18 NOT_GIVEN,
19 APIError,
20 APIStatusError,
21 + ClientIdentity,
22 NotGiven,
23 )
24 from composio_client import Composio as BaseComposio
@@ -39,7 +41,28 @@ def _distribution_version(name: str) -> str:
41
42
43 _SDK_VERSION = _distribution_version("composio")
42 -_CLIENT_LIBRARY_VERSION = _distribution_version("composio-client")
44 +
45 +#: What the client accepts as an identity value: printable ASCII with no
46 +#: leading or trailing whitespace.
47 +_HEADER_SAFE = re.compile(r"[\x21-\x7e](?:[\x20-\x7e]*[\x21-\x7e])?")
48 +
49 +
50 +def _client_identity(provider: str) -> ClientIdentity:
51 + """
52 + The SDK as the generated client reports it.
53 +
54 + The client sends the product headers from it, adds its own library
55 + headers, and reports the Python runtime and version itself. A provider
56 + name that cannot be sent as a header value is reported as ``unknown``
57 + rather than making the client fail to construct.
58 + """
59 + return ClientIdentity(
60 + product="composio",
61 + version=_SDK_VERSION,
62 + source="PYTHON_SDK",
63 + framework=provider if _HEADER_SAFE.fullmatch(provider) else "unknown",
64 + runtime=HttpClient._runtime_env,
65 + )
66
67
68 ComposioAPIError = APIError
@@ -423,6 +446,7 @@ class HttpClient(BaseComposio, WithLogger):
446 default_headers=default_headers,
447 default_query=default_query,
448 http_client=http_client,
449 + identity=_client_identity(provider),
450 _strict_response_validation=_strict_response_validation,
451 _environment_variables=_environment_variables,
452 )
@@ -550,7 +574,11 @@ class HttpClient(BaseComposio, WithLogger):
574 withdrawn: bool,
575 scheme: str,
576 ) -> t.Dict[str, str]:
553 - """Add SDK context at the active generated client's dispatch boundary."""
577 + """
578 + Add the request id at the active generated client's dispatch boundary.
579 +
580 + The identity headers come from the client's ``identity``.
581 + """
582 headers = super()._headers_for(
583 url,
584 json_body=json_body,
@@ -570,15 +598,4 @@ class HttpClient(BaseComposio, WithLogger):
598 headers["x-request-id"] = (
599 ctx.get("id") or headers.get("x-request-id") or uuid4().hex
600 )
573 - headers["x-framework"] = ctx["provider"]
574 - headers["x-source"] = "PYTHON_SDK"
575 - headers["x-runtime"] = HttpClient._runtime_env
576 - headers["x-runtime-version"] = platform.python_version()
577 - headers["x-client-provenance"] = "composio"
578 - headers["x-client-language"] = "python"
579 - headers["x-client-runtime"] = "python"
580 - headers["x-client-library"] = "composio-client"
581 - headers["x-client-library-version"] = _CLIENT_LIBRARY_VERSION
582 - headers["x-sdk-version"] = _SDK_VERSION
583 - headers["x-client-version"] = _SDK_VERSION
601 return headers
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.0rc16",
10 + "composio-client==2.0.0rc17",
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.0rc16",
28 + "composio-client==2.0.0rc17",
29 "typing-extensions>=4.16.0",
30 "openai>=2.48.0",
31 "json-schema-to-pydantic>=0.4.11",
python/tests/test_client_provenance.py
+36 -1
@@ -1,10 +1,11 @@
1 -"""Product provenance must reach the HTTP transport alongside legacy headers."""
1 +"""Product provenance must reach the HTTP transport through the client's identity."""
2
3 import platform
4 from importlib.metadata import version
5
6 import httpx
7 import pytest
8 +from composio_client import ComposioError as ClientComposioError
9
10 from composio.client import HttpClient
11
@@ -56,3 +57,37 @@ def test_product_provenance_is_not_added_to_another_origin():
57
58 assert "x-client-provenance" not in requests[0].headers
59 assert "x-framework" not in requests[0].headers
60 +
61 +
62 +@pytest.mark.parametrize(
63 + "header", ["x-framework", "x-source", "X-Client-Provenance", "x-client-library"]
64 +)
65 +def test_identity_headers_are_refused_in_default_headers(header):
66 + with pytest.raises(
67 + ClientComposioError, match="cannot be passed in `default_headers`"
68 + ):
69 + HttpClient(
70 + provider="test-provider",
71 + api_key="test-key",
72 + base_url="https://backend.invalid",
73 + default_headers={header: "caller-value"},
74 + )
75 +
76 +
77 +@pytest.mark.parametrize("provider", ["café", " padded ", "", "openai\n", "openai\r\n"])
78 +def test_unsendable_provider_name_is_reported_as_unknown(provider):
79 + requests = []
80 +
81 + def respond(request: httpx.Request) -> httpx.Response:
82 + requests.append(request)
83 + return httpx.Response(200, json={"items": []})
84 +
85 + with HttpClient(
86 + provider=provider,
87 + api_key="test-key",
88 + base_url="https://backend.invalid",
89 + http_client=httpx.Client(transport=httpx.MockTransport(respond)),
90 + ) as client:
91 + client.tools.list(limit=1)
92 +
93 + assert requests[0].headers["x-framework"] == "unknown"
ts/packages/cli/AGENTS.md
+2 -2
@@ -116,7 +116,7 @@ test/src/commands/<group>/<shared-module>.test.ts group helper
116 | `JsPackageManagerDetector` | Detects npm/pnpm/yarn/bun for install instructions |
117 | `UpgradeBinary` | Fetches latest release from GitHub, downloads and replaces binary |
118
119 -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 own `defaultHeaders` (provenance headers, `x-user-api-key`, plus `x-org-id`/`x-project-id` when both are known), 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. Client errors are classified for display by `src/utils/api-error-extraction.ts`.
119 +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`), the CLI's own `defaultHeaders` (`x-user-api-key`, plus `x-org-id`/`x-project-id` when both are known), 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. Client errors are classified for display by `src/utils/api-error-extraction.ts`.
120
121 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.
122
@@ -152,7 +152,7 @@ Steps 3–4 (and the TypeScript compiler they need) ship as the `generation-runt
152
153 ### Key Dependencies
154
155 -`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.16` 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`.
155 +`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.17` 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
157 ## Output Conventions: Composable CLI Output
158
ts/packages/cli/CHANGELOG.md
+4 -1
@@ -4,8 +4,11 @@
4
5 ### Patch Changes
6
7 -- The CLI now uses `@composio/client@2.0.0-rc.16` (up from `2.0.0-rc.14`). No
7 +- The CLI now uses `@composio/client@2.0.0-rc.17` (up from `2.0.0-rc.14`). No
8 command changes.
9 +- API requests now carry the CLI's product, version and runtime headers through
10 + the API client's `identity` option instead of default headers. The headers
11 + sent are unchanged.
12
13 ## 0.4.4
14
ts/packages/cli/src/services/client-provenance.ts
+18 -2
@@ -1,4 +1,4 @@
1 -import { VERSION as clientLibraryVersion } from '@composio/client/effect';
1 +import { VERSION as clientLibraryVersion, type ClientIdentity } from '@composio/client/effect';
2 import { APP_VERSION } from 'src/constants';
3
4 const runtime = () =>
@@ -6,7 +6,23 @@ const runtime = () =>
6 ? { name: 'BUN', version: Bun.version }
7 : { name: 'NODEJS', version: process.versions.node };
8
9 -/** Product attribution shared by API clients and first-party raw HTTP requests. */
9 +/**
10 + * The CLI as the API client reports it. The client sends the product headers
11 + * from it, adds its own library headers, and detects the runtime version.
12 + */
13 +export const cliClientIdentity = (): ClientIdentity => ({
14 + product: '@composio/cli',
15 + version: APP_VERSION,
16 + source: 'CLI',
17 + framework: 'cli',
18 + runtime: runtime().name,
19 +});
20 +
21 +/**
22 + * Product attribution for first-party HTTP requests that do not go through an
23 + * API client (analytics dispatch, the agents service, the companion runtime).
24 + * API clients get the same attribution from {@link cliClientIdentity}.
25 + */
26 export const cliRequestHeaders = (): Record<string, string> => ({
27 'x-framework': 'cli',
28 'x-source': 'CLI',
ts/packages/cli/src/services/composio-clients.ts
+3 -5
@@ -16,7 +16,6 @@ import { FetchHttpClient, HttpClient } from 'effect/http';
16 import {
17 // eslint-disable-next-line no-restricted-imports -- this module is the one place the client is built
18 make as makeComposioClient,
19 - VERSION as clientLibraryVersion,
19 type ComposioClientShape,
20 type ConfigurationError,
21 } from '@composio/client/effect';
@@ -29,7 +28,7 @@ import {
28 } from 'src/effects/toolkit-version-overrides';
29 import { Session, RetrievedSession } from 'src/models/session';
30 import { TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
32 -import { cliRequestHeaders } from './client-provenance';
31 +import { cliClientIdentity } from './client-provenance';
32 import { getCurrentCwdSessionId } from 'src/analytics/dispatch';
33 import { ComposioUserContext, ComposioUserContextLive } from './user-context';
34 import { ProjectContext } from './project-context';
@@ -94,10 +93,8 @@ const buildDefaultHeaders = (params: {
93 projectId?: string;
94 cliSessionId?: string;
95 }): Record<string, string> | undefined => {
96 + // The identity headers come from the client's `identity`, which refuses them here.
97 const defaultHeaders = {
98 - ...cliRequestHeaders(),
99 - 'x-client-library': '@composio/client',
100 - 'x-client-library-version': clientLibraryVersion,
98 ...(params.userApiKey
99 ? ({ 'x-user-api-key': params.userApiKey } satisfies Record<string, string>)
100 : {}),
@@ -200,6 +197,7 @@ const makeComposioClientSingleton = (metrics: ClientMetricsCollector) =>
197 // Preserve support for explicitly configured HTTP backends.
198 allowInsecureHTTP: true,
199 deprecationNotices: 'off',
200 + identity: cliClientIdentity(),
201 defaultHeaders: buildDefaultHeaders({
202 userApiKey: scope.userApiKey,
203 orgId: scope.orgId,
ts/packages/cli/test/src/services/composio-client-singleton.test.ts
+3 -1
@@ -7,7 +7,7 @@ import * as BunPath from '@effect/platform-bun/BunPath';
7 import { ConfigProvider, Effect, Exit, Layer, Logger } from 'effect';
8 import { FetchHttpClient } from 'effect/http';
9 import * as tempy from 'tempy';
10 -import type { ComposioClientShape } from '@composio/client/effect';
10 +import { VERSION as clientLibraryVersion, type ComposioClientShape } from '@composio/client/effect';
11 import { ComposioClientSingleton } from 'src/services/composio-clients';
12 import { idempotent, validated } from 'src/services/composio-request';
13 import { APP_VERSION } from 'src/constants';
@@ -392,6 +392,8 @@ describe('ComposioClientSingleton client', () => {
392 expect(headers.get('x-client-provenance')).toBe('@composio/cli');
393 expect(headers.get('x-client-version')).toBe(APP_VERSION);
394 expect(headers.get('x-client-language')).toBe('typescript');
395 + expect(headers.get('x-client-library')).toBe('@composio/client');
396 + expect(headers.get('x-client-library-version')).toBe(clientLibraryVersion);
397 }).pipe(Effect.provide(singletonLayer(baseConfig())));
398 });
399
ts/packages/core/src/composio.ts
+17 -14
@@ -31,7 +31,7 @@ import { version } from '../package.json';
31 import type { ComposioRequestHeaders } from './types/composio.types';
32 import type { ComposioRequestOptions } from './types/requestOptions.types';
33 import { Files } from '#files';
34 -import { getDefaultHeaders } from './utils/session';
34 +import { getClientIdentity } from './utils/session';
35 import { ToolkitVersionParam } from './types/tool.types';
36 import { ToolRouter } from './models/ToolRouter';
37 import { Sessions } from './models/Sessions';
@@ -171,8 +171,15 @@ export type ComposioConfig<
171 * `x-user-api-key` is the one header the SDK treats as a credential: together
172 * with `apiKey: null` it authenticates requests with a Composio user API key
173 * instead of a project key. The project key is only ever set from `apiKey`:
174 - * an `x-api-key` entry is rejected when `apiKey` is `null`. Every other
175 - * header is passed through untouched.
174 + * an `x-api-key` entry is rejected when `apiKey` is `null`.
175 + *
176 + * The SDK reports itself through the API client's identity headers
177 + * (`x-client-provenance`, `x-client-version`, `x-client-library`,
178 + * `x-client-library-version`, `x-client-language`, `x-client-runtime`,
179 + * `x-sdk-version`, `x-source`, `x-framework`, `x-runtime` and
180 + * `x-runtime-version`); an entry naming one of them is rejected with a
181 + * `ComposioError` from `@composio/client`. Every other header is passed
182 + * through untouched.
183 * @example
184 * ```typescript
185 * const composio = new Composio({
@@ -514,14 +521,12 @@ export class Composio<
521
522 // The resolved scope is the single source of the x-org-id / x-project-id
523 // headers: it travels via `this.config` to clones and to the MCP export.
517 - const defaultHeaders = getDefaultHeaders(
518 - { ...this.config.defaultHeaders, ...getScopeHeaders(scope) },
519 - this.provider
520 - );
524 + const defaultHeaders = { ...this.config.defaultHeaders, ...getScopeHeaders(scope) };
525
526 /**
527 * Initialize the Composio SDK client.
524 - * The client is used to make API calls to the Composio API.
528 + * The client is used to make API calls to the Composio API. It sends the
529 + * SDK's identity headers from `identity`, and refuses them in `defaultHeaders`.
530 */
531 this.client = new ComposioClient({
532 apiKey: apiKeyParsed,
@@ -529,6 +534,7 @@ export class Composio<
534 orgApiKey: config?.orgApiKey,
535 baseURL: baseURLParsed,
536 defaultHeaders: defaultHeaders,
537 + identity: getClientIdentity(this.provider),
538 logger: clientLoggerAdapter,
539 logLevel: toClientLogLevel(logger.getLevel()),
540 });
@@ -669,12 +675,9 @@ export class Composio<
675 const userApiKeyHeader = getUserApiKeyHeader(options?.headers)
676 ? undefined
677 : getUserApiKeyHeader(this.config.defaultHeaders);
672 - const sessionHeaders = getDefaultHeaders(
673 - userApiKeyHeader
674 - ? { [userApiKeyHeader.name]: userApiKeyHeader.value, ...options?.headers }
675 - : options?.headers,
676 - this.provider
677 - );
678 + const sessionHeaders = userApiKeyHeader
679 + ? { [userApiKeyHeader.name]: userApiKeyHeader.value, ...options?.headers }
680 + : options?.headers;
681 return new Composio({
682 ...this.config,
683 defaultHeaders: sessionHeaders,
ts/packages/core/src/utils/session.ts
+25 -47
@@ -1,9 +1,7 @@
1 import type { BaseComposioProvider } from '../provider/BaseProvider';
2 // Resolve against the installed package, including slim's copy of the core build.
3 -import identity from '#client_identity' with { type: 'json' };
4 -import { z } from 'zod';
5 -import { VERSION as clientLibraryVersion } from '@composio/client';
6 -import type { ComposioRequestHeaders } from '../types/composio.types';
3 +import manifest from '#client_identity' with { type: 'json' };
4 +import type { ClientIdentity } from '@composio/client';
5
6 /**
7 * Extended globalThis interface for runtime detection
@@ -93,51 +91,31 @@ function detectRuntime(): string {
91
92 // Detect once at module initialization
93 const RUNTIME_ENV = detectRuntime();
96 -const RuntimeVersionsSchema = z.object({
97 - Bun: z.object({ version: z.string() }).optional(),
98 - Deno: z.object({ version: z.object({ deno: z.string() }) }).optional(),
99 -});
100 -const runtimeVersions = RuntimeVersionsSchema.safeParse(globalThis);
101 -const detectRuntimeVersion = (): string | undefined => {
102 - switch (RUNTIME_ENV) {
103 - case 'BUN':
104 - return runtimeVersions.success ? runtimeVersions.data.Bun?.version : undefined;
105 - case 'DENO':
106 - return runtimeVersions.success ? runtimeVersions.data.Deno?.version.deno : undefined;
107 - case 'NODEJS':
108 - return process.versions.node;
109 - default:
110 - return undefined;
111 - }
112 -};
113 -const RUNTIME_VERSION = detectRuntimeVersion();
94
115 -export function getSessionHeaders(
116 - provider: BaseComposioProvider<unknown, unknown, unknown> | undefined
117 -) {
118 - return {
119 - 'x-framework': provider?.name || 'unknown',
120 - 'x-source': 'TYPESCRIPT_SDK',
121 - 'x-runtime': RUNTIME_ENV,
122 - 'x-client-runtime':
123 - RUNTIME_ENV === 'CLOUDFLARE_WORKERS' ? 'cloudflare' : RUNTIME_ENV.toLowerCase(),
124 - 'x-sdk-version': identity.version,
125 - 'x-client-provenance': identity.name,
126 - 'x-client-version': identity.version,
127 - 'x-client-language': 'typescript',
128 - 'x-client-library': '@composio/client',
129 - 'x-client-library-version': clientLibraryVersion,
130 - ...(RUNTIME_VERSION ? { 'x-runtime-version': RUNTIME_VERSION } : {}),
131 - };
132 -}
95 +/**
96 + * An identity value is sent as a header, so the client accepts only non-empty
97 + * printable ASCII with no leading or trailing whitespace.
98 + */
99 +const HEADER_SAFE = /^[\x21-\x7e](?:[\x20-\x7e]*[\x21-\x7e])?$/;
100
134 -export const getDefaultHeaders = (
135 - headers: ComposioRequestHeaders | undefined,
101 +/**
102 + * The identity the API client reports for this SDK: its product headers
103 + * (`x-client-provenance`, `x-client-version`, `x-sdk-version`) and the legacy
104 + * `x-source`, `x-framework` and `x-runtime` labels. The client adds the
105 + * library headers and detects the runtime and its version itself.
106 + *
107 + * A custom provider whose name cannot be sent as a header value is reported
108 + * as `unknown` rather than making the SDK fail to construct.
109 + */
110 +export function getClientIdentity(
111 provider: BaseComposioProvider<unknown, unknown, unknown> | undefined
137 -) => {
138 - const sessionHeaders = getSessionHeaders(provider);
112 +): ClientIdentity {
113 + const framework = provider?.name;
114 return {
140 - ...(headers || {}),
141 - ...sessionHeaders,
115 + product: manifest.name,
116 + version: manifest.version,
117 + source: 'TYPESCRIPT_SDK',
118 + framework: framework && HEADER_SAFE.test(framework) ? framework : 'unknown',
119 + runtime: RUNTIME_ENV,
120 };
143 -};
121 +}
ts/packages/core/test/core/session.test.ts
+100 -213
@@ -1,4 +1,7 @@
1 -import { VERSION as clientLibraryVersion } from '@composio/client';
1 +import {
2 + ComposioError as ClientComposioError,
3 + VERSION as clientLibraryVersion,
4 +} from '@composio/client';
5 import { afterEach, beforeEach, describe, it, expect, vi } from 'vitest';
6 import * as fs from 'node:fs';
7 import * as os from 'node:os';
@@ -7,7 +10,7 @@ import { Composio } from '../../src/composio';
10 import { SessionConfigs } from '../../src/models/SessionConfigs';
11 import { MockProvider } from '../utils/mocks/provider.mock';
12 import { OpenAIProvider } from '../../src/provider/OpenAIProvider';
10 -import { getDefaultHeaders, getSessionHeaders } from '../../src/utils/session';
13 +import { getClientIdentity } from '../../src/utils/session';
14 import { version } from '../../package.json';
15 import {
16 ComposioAPIKeyKindError,
@@ -17,14 +20,19 @@ import {
20 import { ComposioMCPDestinationError } from '../../src/errors/ToolRouterErrors';
21 import logger from '../../src/utils/logger';
22
20 -const provenanceHeaders = {
23 +const identityHeaders = (framework: string) => ({
24 'x-client-provenance': '@composio/core',
25 'x-client-version': version,
26 + 'x-sdk-version': version,
27 'x-client-language': 'typescript',
28 'x-client-library': '@composio/client',
29 'x-client-library-version': clientLibraryVersion,
30 + 'x-client-runtime': 'nodejs',
31 'x-runtime-version': process.versions.node,
27 -};
32 + 'x-runtime': 'NODEJS',
33 + 'x-source': 'TYPESCRIPT_SDK',
34 + 'x-framework': framework,
35 +});
36
37 describe('Composio Session Management', () => {
38 const baseConfig = {
@@ -53,12 +61,6 @@ describe('Composio Session Management', () => {
61 'x-request-id': '1234567890',
62 'x-correlation-id': 'session-abc-123',
63 'x-custom-header': 'custom-value',
56 - 'x-framework': 'MockProvider', // from provider
57 - 'x-source': 'TYPESCRIPT_SDK',
58 - 'x-runtime': 'NODEJS',
59 - 'x-client-runtime': 'nodejs',
60 - ...provenanceHeaders,
61 - 'x-sdk-version': version,
64 });
65
66 // Should preserve other config
@@ -99,44 +101,25 @@ describe('Composio Session Management', () => {
101 expect(headersA).toEqual({
102 'x-user-id': 'user-a',
103 'x-tenant-id': 'tenant-1',
102 - 'x-framework': 'MockProvider',
103 - 'x-source': 'TYPESCRIPT_SDK',
104 - 'x-runtime': 'NODEJS',
105 - 'x-client-runtime': 'nodejs',
106 - ...provenanceHeaders,
107 - 'x-sdk-version': version,
104 });
105
106 expect(headersB).toEqual({
107 'x-user-id': 'user-b',
108 'x-tenant-id': 'tenant-2',
113 - 'x-framework': 'MockProvider',
114 - 'x-source': 'TYPESCRIPT_SDK',
115 - 'x-runtime': 'NODEJS',
116 - 'x-client-runtime': 'nodejs',
117 - ...provenanceHeaders,
118 - 'x-sdk-version': version,
109 });
110
111 // Sessions should be isolated
112 expect(sessionA).not.toBe(sessionB);
113 });
114
125 - it('should include session headers even when no custom headers are provided', () => {
115 + it('should carry no default headers when no custom headers are provided', () => {
116 const composio = new Composio(baseConfig);
117 const session = composio.createSession();
118
129 - // Should still have session headers from provider
119 + // The identity headers come from the client's `identity`, not defaultHeaders
120 // @ts-expect-error: access private config for test
121 const defaultHeaders = session.config.defaultHeaders;
132 - expect(defaultHeaders).toEqual({
133 - 'x-framework': 'MockProvider', // from provider
134 - 'x-source': 'TYPESCRIPT_SDK',
135 - 'x-runtime': 'NODEJS',
136 - 'x-client-runtime': 'nodejs',
137 - ...provenanceHeaders,
138 - 'x-sdk-version': version,
139 - });
122 + expect(defaultHeaders).toBeUndefined();
123 });
124
125 it('should expose sessions.create and keep composio.create as a bound alias', async () => {
@@ -180,176 +163,105 @@ describe('Composio Session Management', () => {
163 });
164 });
165
183 -describe('Session Headers Generation', () => {
184 - describe('getSessionHeaders', () => {
185 - it('should generate correct session headers for OpenAI provider', () => {
186 - const openAIProvider = new OpenAIProvider();
187 - const headers = getSessionHeaders(openAIProvider);
188 -
189 - expect(headers).toEqual({
190 - 'x-framework': 'openai',
191 - 'x-source': 'TYPESCRIPT_SDK',
192 - 'x-runtime': 'NODEJS',
193 - 'x-client-runtime': 'nodejs',
194 - ...provenanceHeaders,
195 - 'x-sdk-version': version,
196 - });
197 - });
198 -
199 - it('should generate correct session headers for MockProvider', () => {
200 - const mockProvider = new MockProvider();
201 - const headers = getSessionHeaders(mockProvider);
202 -
203 - expect(headers).toEqual({
204 - 'x-framework': 'MockProvider',
205 - 'x-source': 'TYPESCRIPT_SDK',
206 - 'x-runtime': 'NODEJS',
207 - 'x-client-runtime': 'nodejs',
208 - ...provenanceHeaders,
209 - 'x-sdk-version': version,
210 - });
211 - });
166 +describe('getClientIdentity', () => {
167 + const sdkIdentity = (framework: string) => ({
168 + product: '@composio/core',
169 + version,
170 + source: 'TYPESCRIPT_SDK',
171 + framework,
172 + runtime: 'NODEJS',
173 + });
174
213 - it('should use fallback source when provider is undefined', () => {
214 - const headers = getSessionHeaders(undefined);
175 + it('reports the OpenAI provider as the framework', () => {
176 + expect(getClientIdentity(new OpenAIProvider())).toEqual(sdkIdentity('openai'));
177 + });
178
216 - expect(headers).toEqual({
217 - 'x-framework': 'unknown',
218 - 'x-source': 'TYPESCRIPT_SDK',
219 - 'x-runtime': 'NODEJS',
220 - 'x-client-runtime': 'nodejs',
221 - ...provenanceHeaders,
222 - 'x-sdk-version': version,
223 - });
224 - });
179 + it('reports a custom provider by its name', () => {
180 + expect(getClientIdentity(new MockProvider())).toEqual(sdkIdentity('MockProvider'));
181 + });
182
226 - it('should use fallback source when provider name is undefined', () => {
227 - const mockProvider = {
228 - name: undefined,
229 - } as unknown;
230 - const headers = getSessionHeaders(mockProvider);
183 + it('reports an unknown framework without a provider or a provider name', () => {
184 + expect(getClientIdentity(undefined)).toEqual(sdkIdentity('unknown'));
185 + expect(getClientIdentity({ name: undefined } as unknown as MockProvider)).toEqual(
186 + sdkIdentity('unknown')
187 + );
188 + });
189
232 - expect(headers).toEqual({
233 - 'x-framework': 'unknown',
234 - 'x-source': 'TYPESCRIPT_SDK',
235 - 'x-runtime': 'NODEJS',
236 - 'x-client-runtime': 'nodejs',
237 - ...provenanceHeaders,
238 - 'x-sdk-version': version,
239 - });
240 - });
190 + it('reports an unknown framework for a provider name the client cannot send', () => {
191 + for (const name of ['café', ' padded ', '', 'openai\n', 'openai\r\n']) {
192 + expect(getClientIdentity({ name } as unknown as MockProvider)).toEqual(
193 + sdkIdentity('unknown')
194 + );
195 + }
196 });
197 +});
198
243 - describe('getDefaultHeaders', () => {
244 - it('should merge custom headers with session headers for OpenAI provider', () => {
245 - const openAIProvider = new OpenAIProvider();
246 - const customHeaders = {
247 - 'x-request-id': '1234567890',
248 - 'x-custom-header': 'custom-value',
249 - };
199 +describe('Identity headers at the transport boundary', () => {
200 + const captureFetch = () => {
201 + const fetchMock = vi.fn(async () => Response.json({ items: [], next_cursor: null }));
202 + vi.stubGlobal('fetch', fetchMock);
203 + return fetchMock;
204 + };
205
251 - const headers = getDefaultHeaders(customHeaders, openAIProvider);
206 + const sentHeaders = (fetchMock: ReturnType<typeof captureFetch>) => {
207 + const call = fetchMock.mock.calls[0] as unknown as [string, { headers: HeadersInit }];
208 + return Object.fromEntries(new Headers(call[1].headers));
209 + };
210
253 - expect(headers).toEqual({
254 - 'x-request-id': '1234567890',
255 - 'x-custom-header': 'custom-value',
256 - 'x-framework': 'openai',
257 - 'x-source': 'TYPESCRIPT_SDK',
258 - 'x-runtime': 'NODEJS',
259 - 'x-client-runtime': 'nodejs',
260 - ...provenanceHeaders,
261 - 'x-sdk-version': version,
262 - });
211 + const build = (config: ConstructorParameters<typeof Composio>[0] = {}) =>
212 + new Composio({
213 + apiKey: 'test-api-key',
214 + baseURL: 'https://api.test.com',
215 + provider: new MockProvider(),
216 + allowTracking: false,
217 + disableVersionCheck: true,
218 + ...config,
219 });
220
265 - it('should merge custom headers with session headers for MockProvider', () => {
266 - const mockProvider = new MockProvider();
267 - const customHeaders = {
268 - 'x-user-id': 'user-123',
269 - 'x-tenant-id': 'tenant-456',
270 - };
271 -
272 - const headers = getDefaultHeaders(customHeaders, mockProvider);
273 -
274 - expect(headers).toEqual({
275 - 'x-user-id': 'user-123',
276 - 'x-tenant-id': 'tenant-456',
277 - 'x-framework': 'MockProvider',
278 - 'x-source': 'TYPESCRIPT_SDK',
279 - 'x-runtime': 'NODEJS',
280 - 'x-client-runtime': 'nodejs',
281 - ...provenanceHeaders,
282 - 'x-sdk-version': version,
283 - });
284 - });
221 + afterEach(() => {
222 + vi.unstubAllGlobals();
223 + });
224
286 - it('should prioritize session headers over custom headers when keys conflict', () => {
287 - const openAIProvider = new OpenAIProvider();
288 - const customHeaders = {
289 - 'x-source': 'custom-source',
290 - 'x-runtime': 'custom-runtime',
291 - 'x-sdk-version': 'custom-version',
292 - 'x-custom-header': 'custom-value',
293 - };
294 -
295 - const headers = getDefaultHeaders(customHeaders, openAIProvider);
296 -
297 - expect(headers).toEqual({
298 - 'x-framework': 'openai', // session header takes precedence
299 - 'x-source': 'TYPESCRIPT_SDK', // session header takes precedence
300 - 'x-runtime': 'NODEJS',
301 - 'x-client-runtime': 'nodejs', // session header takes precedence
302 - ...provenanceHeaders,
303 - 'x-sdk-version': version, // session header takes precedence
304 - 'x-custom-header': 'custom-value', // custom header preserved
305 - });
306 - });
225 + it('sends the SDK identity, the provider as the framework, and the caller headers', async () => {
226 + const fetchMock = captureFetch();
227
308 - it('should handle undefined custom headers', () => {
309 - const openAIProvider = new OpenAIProvider();
310 - const headers = getDefaultHeaders(undefined, openAIProvider);
228 + await build({ defaultHeaders: { 'x-request-id': 'req-1' } })
229 + .getClient()
230 + .toolkits.list({ limit: 1 });
231
312 - expect(headers).toEqual({
313 - 'x-framework': 'openai',
314 - 'x-source': 'TYPESCRIPT_SDK',
315 - 'x-runtime': 'NODEJS',
316 - 'x-client-runtime': 'nodejs',
317 - ...provenanceHeaders,
318 - 'x-sdk-version': version,
319 - });
232 + expect(sentHeaders(fetchMock)).toMatchObject({
233 + ...identityHeaders('MockProvider'),
234 + 'x-request-id': 'req-1',
235 });
236 + });
237
322 - it('should handle empty custom headers object', () => {
323 - const openAIProvider = new OpenAIProvider();
324 - const headers = getDefaultHeaders({}, openAIProvider);
238 + it('sends the same identity from a createSession clone', async () => {
239 + const fetchMock = captureFetch();
240
326 - expect(headers).toEqual({
327 - 'x-framework': 'openai',
328 - 'x-source': 'TYPESCRIPT_SDK',
329 - 'x-runtime': 'NODEJS',
330 - 'x-client-runtime': 'nodejs',
331 - ...provenanceHeaders,
332 - 'x-sdk-version': version,
333 - });
334 - });
241 + await build({ provider: new OpenAIProvider() })
242 + .createSession({ headers: { 'x-session': 's-1' } })
243 + .getClient()
244 + .toolkits.list({ limit: 1 });
245
336 - it('should handle undefined provider', () => {
337 - const customHeaders = {
338 - 'x-request-id': '1234567890',
339 - };
246 + expect(sentHeaders(fetchMock)).toMatchObject({
247 + ...identityHeaders('openai'),
248 + 'x-session': 's-1',
249 + });
250 + });
251
341 - const headers = getDefaultHeaders(customHeaders, undefined);
252 + it('rejects an identity header in defaultHeaders', () => {
253 + expect(() => build({ defaultHeaders: { 'x-source': 'custom-source' } })).toThrow(
254 + ClientComposioError
255 + );
256 + expect(() => build({ defaultHeaders: { 'X-Client-Library': 'other' } })).toThrow(
257 + ClientComposioError
258 + );
259 + });
260
343 - expect(headers).toEqual({
344 - 'x-request-id': '1234567890',
345 - 'x-framework': 'unknown',
346 - 'x-source': 'TYPESCRIPT_SDK',
347 - 'x-runtime': 'NODEJS',
348 - 'x-client-runtime': 'nodejs',
349 - ...provenanceHeaders,
350 - 'x-sdk-version': version,
351 - });
352 - });
261 + it('rejects an identity header passed to createSession', () => {
262 + expect(() => build().createSession({ headers: { 'x-framework': 'other' } })).toThrow(
263 + ClientComposioError
264 + );
265 });
266 });
267
@@ -415,12 +327,6 @@ describe('Session Headers Configuration Integration', () => {
327 expect(sessionDefaultHeaders).toEqual({
328 'x-request-id': '1234567890',
329 'x-user-context': 'user-session',
418 - 'x-framework': 'openai',
419 - 'x-source': 'TYPESCRIPT_SDK',
420 - 'x-runtime': 'NODEJS',
421 - 'x-client-runtime': 'nodejs',
422 - ...provenanceHeaders,
423 - 'x-sdk-version': version,
330 });
331 });
332
@@ -452,20 +358,14 @@ describe('Session Headers Configuration Integration', () => {
358 expect(sessionOpenAI.provider).toBe(openAIProvider);
359 expect(sessionMock.provider).toBe(mockProvider);
360
455 - // Verify session configurations have provider-specific headers
361 + // Each session carries its own headers; the provider reaches the wire through `identity`
362 // @ts-expect-error: access private config for test
457 - const openAIHeaders = sessionOpenAI.config.defaultHeaders!;
363 + expect(sessionOpenAI.config.defaultHeaders).toEqual({ 'x-session': 'openai-session' });
364 // @ts-expect-error: access private config for test
459 - const mockHeaders = sessionMock.config.defaultHeaders!;
460 -
461 - expect(openAIHeaders['x-framework']).toBe('openai');
462 - expect(openAIHeaders['x-session']).toBe('openai-session');
463 -
464 - expect(mockHeaders['x-framework']).toBe('MockProvider');
465 - expect(mockHeaders['x-session']).toBe('mock-session');
365 + expect(sessionMock.config.defaultHeaders).toEqual({ 'x-session': 'mock-session' });
366 });
367
468 - it('should create session with provider-specific headers even without custom headers', () => {
368 + it('should create session with no default headers without custom headers', () => {
369 const openAIProvider = new OpenAIProvider();
370 const composio = new Composio({
371 apiKey: 'test-api-key',
@@ -480,14 +380,7 @@ describe('Session Headers Configuration Integration', () => {
380 // @ts-expect-error: access private config for test
381 const sessionHeaders = session.config.defaultHeaders;
382
483 - expect(sessionHeaders).toEqual({
484 - 'x-framework': 'openai',
485 - 'x-source': 'TYPESCRIPT_SDK',
486 - 'x-runtime': 'NODEJS',
487 - 'x-client-runtime': 'nodejs',
488 - ...provenanceHeaders,
489 - 'x-sdk-version': version,
490 - });
383 + expect(sessionHeaders).toBeUndefined();
384 });
385
386 it('should properly merge headers when both parent and session have custom headers', () => {
@@ -518,12 +411,6 @@ describe('Session Headers Configuration Integration', () => {
411 expect(sessionHeaders).toEqual({
412 'x-session-header': 'session-value',
413 'x-shared-header': 'session-shared-value', // session value takes precedence
521 - 'x-framework': 'openai', // provider-specific header
522 - 'x-source': 'TYPESCRIPT_SDK',
523 - 'x-runtime': 'NODEJS',
524 - 'x-client-runtime': 'nodejs',
525 - ...provenanceHeaders,
526 - 'x-sdk-version': version,
414 });
415 });
416 });
uv.lock
+4 -4
@@ -757,7 +757,7 @@ dev = [
757
758 [package.metadata]
759 requires-dist = [
760 - { name = "composio-client", specifier = "==2.0.0rc16" },
760 + { name = "composio-client", specifier = "==2.0.0rc17" },
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.0rc16"
806 +version = "2.0.0rc17"
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/a4/93/8bc5924aef6c42e4a6c410134c3e2cdfb15afe8517edd2c8125c17baf417/composio_client-2.0.0rc16.tar.gz", hash = "sha256:f4c6bd3414c54ff2942a42cd3692a8e6e3a84e5ab0b2daade7e7c52df02a3faa", size = 618227, upload-time = "2026-10-15T18:17:33.727Z" }
813 +sdist = { url = "https://files.pythonhosted.org/packages/4f/5b/46db80356fd2fe5c4b47256bf2f8f8d0821609eafb6f9016a36c4aceb90f/composio_client-2.0.0rc17.tar.gz", hash = "sha256:9e6f3df1910518f4cd7c65c9a573986e11f0dbe02be0ec72175616fc3d7a45b1", size = 620910, upload-time = "2026-10-15T19:45:14.864Z" }
814 wheels = [
815 - { url = "https://files.pythonhosted.org/packages/e6/eb/de39ebd072e7bf670b31ae6fc73834a00728b7a959558709a39ceee2cefb/composio_client-2.0.0rc16-py3-none-any.whl", hash = "sha256:9f82079f1d22f59d603471d5ce3aae6b617d2cfa2427e50ec844f8a099876c4c", size = 445953, upload-time = "2026-10-15T18:17:31.873Z" },
815 + { url = "https://files.pythonhosted.org/packages/05/38/078d855a7c0f7edd24786e184a032a14333042367f0434b9beab5ecfa16e/composio_client-2.0.0rc17-py3-none-any.whl", hash = "sha256:cf12b509818fe077d58def2e5ca9c6931c5e7646e43506283204e3b823207f3a", size = 448281, upload-time = "2026-10-15T19:45:12.857Z" },
816 ]
817
818 [[package]]