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.

from magiccampus_im import MagicCampusWSConfig, MagicCampusWSSDK

sdk = MagicCampusWSSDK(
    MagicCampusWSConfig(apiurl="https://campus.example", apikey="...", 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). It contains no searchable chat bodies. State belongs to one user/environment/platform data directory. Its metadata binds the endpoint/user/platform context and rejects a mismatched context; token rotation keeps the same context. Do not share a directory between unrelated instances. Callbacks must return successfully to record receipt. This is not an acknowledgment that an Agent finished processing a message.

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

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.1
File Size Uploaded Provenance Actions
magic_campus_im-0.1.1.tar.gz 54.8 kB Without provenance Details for magic_campus_im-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 105.3 kB

Release files / magic_campus_im-0.1.1.tar.gz

Download URL magic_campus_im-0.1.1.tar.gz
Size 54.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff446eb75197107492e79dce5a0d7c1df681a8c31063514cb91f35ac92084374
BLAKE2b-256 checksum
How to use checksums
868d797f477cbff6fc50775b5a08e4eb0d0cd36b42f674d8048128654a220343
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.1-py3-none-any.whl

Download URL magic_campus_im-0.1.1-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd709666d4891d895c9764f6afa39fb637410ed1ebc18bbf99ebe2d82c359e7d
BLAKE2b-256 checksum
How to use checksums
79908c4d2ae503081d5a579a28b34a66dbbe8b8925fc06c64126f9d6110f4f98
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.1

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