Skip to main content

Core client SDK for the Copass platform (Python mirror of @copass/core)

Project description

copass-core

Core client SDK for the Copass platform. Python mirror of @copass/core — shared foundation for every Python Copass adapter.

Install

pip install copass-core

Requires httpx>=0.27. Python ≥ 3.10.

Quickstart

import asyncio
from copass_core import CopassClient, ApiKeyAuth

async def main():
    client = CopassClient(auth=ApiKeyAuth(key="olk_..."))

    # Retrieval
    menu = await client.retrieval.discover(
        sandbox_id="sb_...",
        query="How does auth work?",
    )
    print(menu["items"])

asyncio.run(main())

Auth options

from copass_core import CopassClient, ApiKeyAuth, BearerAuth, ProviderAuth

# Long-lived API key (olk_ prefix)
CopassClient(auth=ApiKeyAuth(key="olk_..."))

# Raw Bearer JWT (caller owns refresh)
CopassClient(auth=BearerAuth(token="eyJ..."))

# Custom AuthProvider implementation
class MyProvider:
    async def get_session(self):
        from copass_core import SessionContext
        return SessionContext(access_token=await _mint_token())

CopassClient(auth=ProviderAuth(provider=MyProvider()))

Available resources

Full resource surface matching @copass/core:

client = CopassClient(auth=ApiKeyAuth(key="olk_..."))

# Narrow retrieval tools
await client.retrieval.discover(sandbox_id, query="...")
await client.retrieval.interpret(sandbox_id, query="...", items=[...])
await client.retrieval.search(sandbox_id, query="...")

# Storage layer
await client.sandboxes.create(name="...", owner_id="...")
await client.sources.register(sandbox_id, provider="custom", name="...")
await client.ingest.text_in_sandbox(sandbox_id, text="...")
await client.projects.create(sandbox_id, name="...")
await client.vault.store(sandbox_id, "key/path", b"bytes")

# Knowledge graph
await client.entities.search(sandbox_id, q="auth")

# Account
await client.users.get_profile()
await client.api_keys.create(name="ci")
await client.usage.get_balance()

# Higher-order — ephemeral data source wrapping agent conversation
window = await client.context_window.create(sandbox_id=sandbox_id)
await window.add_turn(ChatMessage(role="user", content="..."))
# Pass directly to retrieval for window-aware calls:
await client.retrieval.search(sandbox_id, query="...", window=window)

Conversation metadata: speaker, participants, timestamp

Every ingestion path accepts optional metadata that travels alongside the content on the envelope. Set them when the data is conversation-shaped so the platform can attribute and order content correctly.

Field Where to set What it means
occurred_at IngestTextRequest / BaseDataSource.push / client.sources.ingest ISO 8601 timestamp anchoring this payload to a real-world moment. Falls back as the default occurred_at for any composed event whose own LLM-extracted timestamp is None.
speaker IngestTextRequest / BaseDataSource.push / client.sources.ingest Name of the participant who uttered this payload. Caller-decided literal ("User", "Assistant", "Alice", an email address, …). Most useful on conversation-shaped sources.
participants Same Roster of participants present in this artifact. Per-message — pass the snapshot at the time of utterance.
source_type Same Hint describing the payload kind. Conventional values: "text", "markdown", "code", "json" (content-shape) or "conversation", "ticket", "email", "note" (artifact-kind). Free-form string; custom values accepted.

Direct API

await client.ingest.text(
    text="Hey Alice, did you finish the report?",
    source_type="conversation",
    speaker="Bob",
    participants=["Alice", "Bob"],
    occurred_at="2026-05-08T15:30:00Z",
)

Through a ContextWindow

For a chat-style agent, set the participant roster once at window construction; it forwards on every add_turn call. Set ChatMessage.name when you want a richer speaker than the role-derived default ("User" / "Assistant"):

window = await client.context_window.create(
    sandbox_id=sandbox_id,
    participants=["User", "Alice"],   # default roster, applied on every turn
)

# Role-only — speaker derived as capitalized role.
await window.add_turn(ChatMessage(role="user", content="Hey Alice…"))

# Named participant — `name` overrides role-derived speaker.
await window.add_turn(
    ChatMessage(role="user", content="…thanks!", name="Bob"),
)

# Per-call override — use when the roster shifts mid-conversation.
await window.add_turn(
    ChatMessage(role="assistant", content="…"),
    participants=["User", "Alice", "Bob", "Carol"],
)

Through a BaseDataSource subclass

class SlackChannelSource(BaseDataSource):
    async def push_message(self, msg):
        await self.push(
            msg.text,
            source_type="conversation",
            speaker=msg.author_name,
            participants=msg.channel.member_names,
            occurred_at=msg.posted_at_iso,
        )

Existing callers that don't pass any of these fields keep working — all four are optional.

v0.2 scope

Shipped in v0.2:

  • Full resource surface (12 resource classes, all public paths).
  • ContextWindow + ContextWindowResource.
  • BaseDataSource + ensure_data_source for custom driver subclasses.
  • HttpClient raw-body / raw-response support (enables vault blob I/O).

Deferred to v0.3:

  • Crypto primitives (HKDF, AES-GCM, session tokens, DEK).
  • Supabase OTP auth provider (requires crypto).
  • BearerAuth(encryption_key=...) currently stores the key but doesn't derive a session token — works when the server doesn't demand one.

Open a PR with a scoped addition if you need those sooner.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copass_core-1.0.7.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

copass_core-1.0.7-py3-none-any.whl (41.7 kB view details)

Uploaded Python 3

File details

Details for the file copass_core-1.0.7.tar.gz.

File metadata

  • Download URL: copass_core-1.0.7.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for copass_core-1.0.7.tar.gz
Algorithm Hash digest
SHA256 e1bd2b8bac00018ce81c9c04a8aca24075ec3827202014344de06330791db46e
MD5 9574f1374068e27eab149dcd9b489474
BLAKE2b-256 170a88cf440465079d2f22bb8baaf65a08582d041c5de83beba85340ce7a67a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for copass_core-1.0.7.tar.gz:

Publisher: release-python.yml on olane-labs/copass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file copass_core-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: copass_core-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for copass_core-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e833736ab98dac0e25ab62b59e0fb721deabae07e860300f7b72e7167b8349
MD5 98cffbb6d0faa13514f73c7de0f5dc21
BLAKE2b-256 f96c64364be4afc62fbed6fb96cc10a3a8e8d8643ac0bac88ea1b8bb8b65ad26

See more details on using hashes here.

Provenance

The following attestation bundles were made for copass_core-1.0.7-py3-none-any.whl:

Publisher: release-python.yml on olane-labs/copass

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page