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.3

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.3
File Size Uploaded Provenance Actions
magic_campus_im-0.1.3.tar.gz 55.8 kB Without provenance Details for magic_campus_im-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 106.6 kB

Release files / magic_campus_im-0.1.3.tar.gz

Download URL magic_campus_im-0.1.3.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7e65869ef48de1f30058f78074fbbf2205903bb50afd57a7027cf7f7c78610b2
BLAKE2b-256 checksum
How to use checksums
77fffbaea5187a5bf2dd0a8dd8fa6b84b849bef563e5c8a3a37a15cbba66203d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

Download URL magic_campus_im-0.1.3-py3-none-any.whl
Size 50.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23a0ac52d24825cfb6693da30b1c871a7595bef8c629b406f9eebb75fe43caa2
BLAKE2b-256 checksum
How to use checksums
bf2de147bdcdc956d7c2f3d9fce91d45736d909609a3cb368b7001a7294c3956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for magic-campus-im 0.1.3

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