Linear adapter for chat-py
Project description
chat-adapter-linear
Linear adapter for chat-py. Python port of upstream packages/adapter-linear.
Handles Linear comment webhooks and optional Agent Session threads; supports API-key, OAuth access-token, multi-tenant OAuth, and client-credentials auth.
Install
uv add chat-py chat-py-adapter-linear chat-py-adapter-state-redis
Auth / config
LinearAdapterConfig — discriminated union of four variants:
| Mode | Required fields | Env var fallbacks |
|---|---|---|
| API key | apiKey |
LINEAR_API_KEY |
| OAuth access token | accessToken |
LINEAR_ACCESS_TOKEN |
| Multi-tenant OAuth | clientId + clientSecret |
LINEAR_CLIENT_ID, LINEAR_CLIENT_SECRET |
| Client credentials | clientCredentials (id + secret + scopes) |
— |
All variants additionally accept: webhookSecret, mode ("comments" or "agent-sessions"), apiUrl, userName.
Minimal example
from chat import Chat
from chat_adapter_linear import create_linear_adapter
from chat_adapter_state_redis import create_redis_state
bot = Chat(
user_name="mybot",
adapters={"linear": create_linear_adapter(
apiKey="lin_api_...",
webhookSecret="...",
)},
state=create_redis_state(url="redis://localhost:6379"),
)
@bot.on_new_mention
async def triage(thread, message):
await thread.post("Investigating.")
Mount bot.handle_webhook("linear", body, headers) under /api/webhooks/linear.
Thread ID
Linear thread IDs are linear:{organizationId}:{issueId[:commentId][/agentSession=<id>]}. Agent Session overlays nest under a comment thread — see LinearAgentSessionThreadId and assert_agent_session_thread.
Features
- HMAC signature verify (
verify_linear_signature) - GraphQL-layer error unwrapping (
handle_linear_graphql_bodyreturns the first typed error from a Linear GraphQL response body) - OAuth token refresh for OAuth / multi-tenant modes
- Comment mode and Agent Session mode (
LinearAdapterMode) - Linear-flavoured markdown ↔ mdast (
LinearFormatConverter) - Card → Linear markdown (
card_to_linear_markdown)
Parity notes
- No native cards or streaming — Linear comments are markdown-only.
- Agent Session support mirrors upstream's beta mode.
Test
uv run pytest packages/chat-adapter-linear
# Live
LINEAR_API_KEY=... uv run pytest packages/chat-integration-tests -k linear
Upstream
https://github.com/vercel/chat/tree/main/packages/adapter-linear
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file chat_py_adapter_linear-0.1.0.tar.gz.
File metadata
- Download URL: chat_py_adapter_linear-0.1.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5357360747857dcfe86c72634a2243c2a383a2132fecc98eac45928640a57f5
|
|
| MD5 |
d06c7e04e59e6838b529ca587c0847ac
|
|
| BLAKE2b-256 |
cc413eb64fb42d5793b5c811bca57d72e8c3237eb88983088b3af9a1697cbb7f
|