Metadata-Version: 2.4
Name: magic-campus-cli
Version: 0.1.1
Summary: Magic Campus business HTTP SDK and CLI
License-Expression: AGPL-3.0-or-later
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx<1,>=0.27
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: build>=1; extra == "dev"
Requires-Dist: twine>=6; extra == "dev"

# magic-campus-cli

Business Python SDK and HTTP-only `magic-campus` command. Install this distribution
in a dedicated tool environment. It provides `magiccampus_sdk` and
`magiccampus_cli`; do not co-install it with the frozen `magic-campus-sdk`.

## Usage

```sh
python -m pip install magic-campus-cli
export MAGIC_CAMPUS_BASE_URL="<api-base-url>"
export MAGIC_CAMPUS_API_KEY='<api-key>'
magic-campus --help
magic-campus user get --id 10001 --format json
magic-campus assistant user-id --user-id 123 --format json
magic-campus playgroup list --format json
```

`MAGIC_CAMPUS_BASE_URL` and `MAGIC_CAMPUS_API_KEY` select the business environment
and credential. New installs and updates of this package do not install the IM
distribution. Current-conversation replies remain the responsibility of the
Agent's Channel.

```python
import os

from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig

client = MagicCampusClient(MagicCampusClientConfig(
    apiurl=os.environ["MAGIC_CAMPUS_BASE_URL"],
    apikey=os.environ["MAGIC_CAMPUS_API_KEY"],
))
# client.user, client.feed, client.space, client.playgroup, client.comment, client.assistant
# client.group: HTTP group management, members, and message queries
# client.im.http(): HTTP message sender; client.im also supplies reactions
```

`client.assistant.get_user_id(123)` calls `GET /api/v1/assistant/userId?userId=123`
and returns an integer assistant user ID or `None`. The CLI returns
`{"ok": true, "userId": 123, "assistantUserId": 456}` (plus `_meta`), or
`assistantUserId: null` when no identity is bound, including nonexistent owners.
The explicit target must be a positive Long integer and is never replaced by
the API Key's owner. This read does not create or wake an assistant, and a
returned ID does not prove readiness or grant access to the assistant's profile.

All commands use HTTP. Existing OpenIM HTTP group operations retain their request
semantics; no command initializes a websocket. `im group kick --group ID --users
ID1,ID2` uses the business kick endpoint. Group invitations and member queries use
the business API. `auth status` verifies HTTP credentials and reports
`transport=http_api`, without claiming a websocket is connected.

`im notify history --to user:ID|group:ID --limit N` queries
`POST /api/v1/im/message/query`, then selects the requested conversation. The
server currently accepts a per-conversation limit rather than a target-conversation
filter, so the HTTP response can include other conversations; only the requested
one is returned by the CLI. It does not synchronize or read an IM local database.
Results use the server's message field names. Pagination/search are not invented.

The updater checks only `magic-campus-cli`, uses `cli-update-check.json` and its
own re-execution marker. `MAGIC_CAMPUS_CLI_SOURCE` selects a local source project
for development; it must point to a project named `magic-campus-cli`. The updater
refuses to run in an environment where the frozen `magic-campus-sdk` distribution
is installed. This is an update guard, not a pip installation conflict mechanism:
manual co-installation can still overwrite shared files and is unsupported.
The legacy updater continues to target the frozen package name.

## Development and validation

From the repository root:

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

Use `uv sync --frozen --package magic-campus-cli --group dev` for an environment containing
only this member and development tools. See [workspace instructions](../README.md)
and [build/install checks](../PYPI_RELEASE.md). This source does not perform an
online Agent upgrade.
