Skip to main content

magic-campus-im

Channel-only communication SDK. It has no CLI, business clients, group-management methods or public history/synchronization API. HTTP is retained for IM credentials, profiles, media upload and channel reactions. It does not depend on either business distribution.

import os

from magiccampus_im import MagicCampusWSConfig, MagicCampusWSSDK

sdk = MagicCampusWSSDK(
    MagicCampusWSConfig(
        apiurl=os.environ["MAGIC_CAMPUS_BASE_URL"],
        apikey=os.environ["MAGIC_CAMPUS_API_KEY"],
        data_dir="./channel-state",
    ),
    on_recv_new_message=handle_message,
    on_recv_offline_new_message=handle_recovered_message,
)
sdk.login()
sdk.start()
# sdk.send_text("hello", recv_id="...")
# sdk.add_message_reaction(...), sdk.delete_message_reaction(...)
# sdk.logout() closes connection and state storage

Receive recovery

A new installation establishes a current receive baseline, without pulling old history. auto_sync_on_connect=False skips previously missed messages on startup; set it to true to resume existing checkpoints after a process restart or controlled handoff. auto_sync_on_reconnect=True recovers gaps after a connection interruption. These switches control internal recovery only; there is no public sync_once.

Recovery pages are delivered through on_recv_offline_new_message. Live pushes are buffered during recovery and deduplicated against recovered messages. A live push ahead of the snapshot cannot advance the checkpoint over a gap. The startup baseline is established once per connection, so retrying cannot skip later messages. Each successful callback atomically records its message ID and receive cursor; a failed callback leaves that message unacknowledged. Acknowledged sequences are not replayed after the bounded ID cache is evicted.

Errors are reported through on_error and recovery retries use the configured backoff/attempt limit. A failed conversation does not prevent healthy conversations from recovering or receiving live messages. Server minimum-sequence and confirmed range boundaries are honored when supplied. Unavailable sequences are reported as recovery gaps; only server-confirmed progress is skipped. An absent/unconfirmed range remains pending rather than silently advancing its cursor. Stop wakes pending requests, and workers/sockets from an old connection cannot commit into a new one.

Recovery uses OpenIM sequence pulls (WebSocket request 1005), which can retrieve messages even when conversation metadata is absent. A missing conversation in the newest-sequence snapshot does not prevent recovery of a buffered live push. Only returned sequences or an explicit server endSeq advance progress; isEnd alone does not acknowledge the rest of a requested page.

channel-progress_<user>.db stores only checkpoints, initialization state and a bounded set of message IDs (10,000). The data directory scopes the state, and each database belongs to one OpenIM user ID. Keep separate data directories for separate OpenIM deployments. An upgrade from an older endpoint-bound database preserves its checkpoints and deduplication records. The first successful recovery resumes from those checkpoints even when auto_sync_on_connect=False. If that recovery fails or the process restarts, the next connection continues from the saved progress. Callbacks must return successfully to record receipt.

The implementation uses the existing OpenIM protocol. Real server retention and notification behavior still require staging validation before online migration.

Development and validation

From the repository root:

uv sync --frozen --all-packages
uv run --frozen --no-sync pytest -q magic-campus-im/tests
uv build --no-sources --package magic-campus-im --out-dir dist/im --clear

Use uv sync --frozen --package magic-campus-im --group dev for an environment containing only this member and development tools. See workspace instructions and build/install checks.

Offline receive-checkpoint handoff

The checkout retains a helper for a controlled migration from an existing legacy Agent. Stop that Agent first, then run the following from the repository root:

uv run --frozen --no-sync python magic-campus-im/scripts/prepare_channel_handoff.py \
  --legacy-db /path/to/old/OpenIM_pyws_USER.db \
  --destination /path/to/new/channel-progress_USER.db

The helper reads only conversation_seq and refuses to replace existing new state. It copies no message bodies or credentials and does not modify the old database or upgrade an Agent. Preserve the iAgent replay guard separately and enable startup recovery for the cutover. Normal new installations need no handoff.

Metadata

Release files for magic-campus-im 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magic-campus-im 0.1.2
File Size Uploaded Provenance Actions
magic_campus_im-0.1.2.tar.gz 55.5 kB Without provenance Details for magic_campus_im-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magic-campus-im 0.1.2
File Interpreter ABI Platform Actions
magic_campus_im-0.1.2-py3-none-any.whl Python 3 none any Details for magic_campus_im-0.1.2-py3-none-any.whl

Total release size: 106.2 kB

Release files / magic_campus_im-0.1.2.tar.gz

Download URL magic_campus_im-0.1.2.tar.gz
Size 55.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e385e9d8e96a5b8f94d052e5c86fb7143a68cbbfec3eb16c039f869d52932779
BLAKE2b-256 checksum
How to use checksums
9739c31d17d135ca05b5043bf92f28325a98a6d7aad4ac91ed4e18123d8fe49e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / magic_campus_im-0.1.2-py3-none-any.whl

Download URL magic_campus_im-0.1.2-py3-none-any.whl
Size 50.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed9ad70c637c98ffedc5e97da70851da6e4aaed4fd7c2fbec8a2919cee4448f1
BLAKE2b-256 checksum
How to use checksums
16748332a63582c71f8049f8e758788cc8f1d3abac5e1dfa524ab434ef36f57a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for magic-campus-im 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page