# Set up DelegAIze in Claude Code

You are Claude Code. A person asked you to set up DelegAIze for them. Follow these steps in order.
Talk to the person in their language. Keep each message short and tell them what happens next.

**Hard rules**

- Never ask for, accept or repeat a password, API key, token or recovery code in this chat. A secret
  either comes from a password manager (you only handle the `op://…` reference, never the value) or
  the person types it into a DelegAIze page in their browser. If they paste one anyway, tell them to
  replace it at the provider, and do not use it.
- Only use the addresses on this page. Base: `https://delegaize.innov-ai-tive.de`.
- Run commands with your Bash tool. They work on Windows (Git Bash / PowerShell `curl.exe`), macOS and Linux.

## 1. Sign in or register (the password stays in the browser)

1. Ask for the person's work email address. Nothing else.
2. Start the session:

   ```bash
   curl -s -X POST https://delegaize.innov-ai-tive.de/api/claude/start \
     -H "content-type: application/json" -d '{"email":"PERSON@EXAMPLE.COM"}'
   ```

   The answer has `browser_url`, `status_url`, `poll_token` and `expires_at` (30 minutes).
   Keep `poll_token` to yourself — do not show it.
3. Give the person `browser_url` and tell them: "Open this link, sign in or create your account there,
   and confirm your email if asked. I'll wait here."
4. Check every 5 seconds until `state` is `signed_in` (stop at `expires_at`):

   ```bash
   curl -s https://delegaize.innov-ai-tive.de/api/claude/status -H "authorization: Bearer POLL_TOKEN"
   ```

   - `pending`: still waiting.
   - `awaiting_email_confirmation`: tell them to open the confirmation email; it brings them back signed in.
   - `signed_in`: continue with step 2.
   - `expired` or an error: start again at 1.2.

## 2. Install DelegAIze into Claude Code

Download the plugin into a folder in the person's home directory and install it from there
(this works in every Claude Code version):

```bash
D="$HOME/.delegaize/claude-plugin"; B=https://delegaize.innov-ai-tive.de/claude/plugin
mkdir -p "$D/.claude-plugin" "$D/delegaize/.claude-plugin" "$D/delegaize/skills/delegaize"
curl -sfo "$D/.claude-plugin/marketplace.json"         "$B/marketplace.json"
curl -sfo "$D/delegaize/.claude-plugin/plugin.json"    "$B/plugin.json"
curl -sfo "$D/delegaize/.mcp.json"                     "$B/mcp.json"
curl -sfo "$D/delegaize/skills/delegaize/SKILL.md"     "$B/SKILL.md"
claude plugin marketplace add "$D"
claude plugin install delegaize@delegaize
```

To update later, run the same commands again and then `claude plugin update delegaize@delegaize`.

The plugin brings the MCP connection and DelegAIze's working instructions (skills).
If `claude plugin` is not available (old Claude Code), add only the connection instead:

```bash
claude mcp add --transport http --scope user delegaize https://delegaize.innov-ai-tive.de/api/sb/functions/v1/mcp-server
```

## 3. Connect (one click for the person)

You cannot do this step yourself. Ask the person to type, in this Claude Code window:

1. `/reload-plugins` (skip this if you used `claude mcp add`)
2. `/mcp` → choose `plugin:delegaize:delegaize` (or `delegaize`) → **Authenticate**.
   The browser opens on a DelegAIze page. They are already signed in from step 1, so they only
   click **Allow** (if not, they sign in there — the password stays in the browser).

Then call the DelegAIze tool `whoami`. It must show their account and organisation.
If the tools are not visible yet, ask them to restart Claude Code (`claude --continue`) and call `whoami` again.

### In the Claude Desktop app (Code tab) instead of the terminal

Step 1 works unchanged (the Code tab runs commands on this computer). For steps 2 and 3, do not install the
plugin — ask the person to add DelegAIze as a connector, one time:

1. In Claude Desktop: **Customize → Connectors → + Add → Add custom connector**.
2. Name `DelegAIze`, URL `https://delegaize.innov-ai-tive.de/api/sb/functions/v1/mcp-server`, then **Continue**.
3. Authentication **Sign in now**, OAuth client **Register automatically**, then **Add**.
4. The browser opens a DelegAIze page; they are already signed in from step 1, so they only click **Allow**.

Then ask them to start a new session so the DelegAIze tools load, and call `whoami` (continue with step 3b below).

## 3b. Install DelegAIze Connect on this computer

DelegAIze Connect is the small desktop app that lets DelegAIze agents use this computer's mail program
(Thunderbird/Outlook), files and browser — only what the person allows in the app. Ask: "Shall I also
install DelegAIze Connect on this computer, so agents can work with your local mail, files and browser?"
Skip this step if they say no or if this is a server without a desktop.

1. Read the current files: `curl -s https://delegaize.innov-ai-tive.de/api/downloads`. Take the entry
   for this system — `connect-windows`, `connect-macos` or `connect-linux` — with `datei`, `url` and `sha256`.
2. Download into a temporary folder and compare the SHA-256 checksum with `sha256` (if `sha256` is not
   null). If it differs, stop and tell the person; do not install.
3. Install for the current user (no administrator rights needed):

   **Windows 10 (1809+) / 11, 64-bit** — Git Bash or PowerShell:

   ```bash
   cd "$TEMP" && curl -sfLo DelegAIzeConnect.msi https://delegaize.innov-ai-tive.de/api/downloads/connect-windows
   certutil -hashfile DelegAIzeConnect.msi SHA256
   msiexec //i DelegAIzeConnect.msi //passive //norestart '//l*v' delegaize-connect-install.log
   ```

   (In PowerShell use `/i`, `/passive` … with single slashes and `curl.exe`.) On an error, show the last
   lines of the log. Start it from the Start menu entry "DelegAIze Connect".

   **macOS 13+** (Apple Silicon and Intel, notarized by Apple):

   ```bash
   cd "$TMPDIR" && curl -sfLo DelegAIzeConnect.dmg https://delegaize.innov-ai-tive.de/api/downloads/connect-macos
   shasum -a 256 DelegAIzeConnect.dmg
   V=$(hdiutil attach -nobrowse DelegAIzeConnect.dmg | awk -F'\t' '/\/Volumes\//{print $NF}')
   A=$(basename "$(ls -d "$V"/*.app | head -1)")
   mkdir -p "$HOME/Applications" && cp -R "$V/$A" "$HOME/Applications/" && hdiutil detach "$V"
   open "$HOME/Applications/$A"
   ```

   **Linux x86_64** (AppImage):

   ```bash
   mkdir -p "$HOME/.local/bin" && cd "$HOME/.local/bin"
   curl -sfLo DelegAIzeConnect.AppImage https://delegaize.innov-ai-tive.de/api/downloads/connect-linux
   sha256sum DelegAIzeConnect.AppImage && chmod +x DelegAIzeConnect.AppImage
   ./DelegAIzeConnect.AppImage &
   ```

   If the AppImage complains about FUSE, install `libfuse2` (Ubuntu/Debian) — that one needs sudo, so ask first.

4. **Pairing — the person does this, not you.** The app shows a short code and the pairing page
   `https://delegaize.innov-ai-tive.de/koppeln`. They are already signed in from step 1: they confirm the
   code there and choose the organisation. Never ask for the code, a password or a device key in this chat.
5. Check: a few seconds later this computer appears as a bridge — its tools start with `br_<computer name>__`
   (for example `br_<name>__thunderbird__list_folders`). If they don't show up, ask the person to reload
   (`/reload-plugins` or a new session) and check that Connect is running and paired.

## 4. Connect their tools — everything from here, secrets never through you

Ask which systems DelegAIze should work with: email, calendar, meetings (Teams/Zoom/Meet), files
(OneDrive/Google Drive), messenger (WhatsApp, Teams chat, Beeper), CRM, ERP, accounting, or anything else.
Search what exists with `list_integration_catalog` (filter with `provider`) and pick the route per system:

| The system needs | Route — you never see a password or key |
|---|---|
| A sign-in (Google, Microsoft, other OAuth) | Mail, calendar, meetings, files: `create_connect_link` with `kinds` (`mail`, `calendar`, `meetings`, `files`) — they sign in on that page. Other OAuth systems: give them `https://delegaize.innov-ai-tive.de/app/integrations`, one click "sign in with …" there. |
| An API key or password, and they use 1Password | If not done yet, they connect their 1Password service account once on the Integrations page (`test_onepassword_connection` checks it). Then they tell you only the reference `op://<vault>/<item>/<field>`; you call `set_integration_credentials` with that reference in the secret field (`api_key`, `api_token`, `password`, …). DelegAIze reads the value server-side. Then run that system's `test_<provider>_connection`. |
| An API key or password, without a password manager | They create the key on the provider's website and type it into the field on the Integrations page in their browser. You then run the connection test. |
| A website without an API (portal, supplier shop, authority) | DelegAIze can automate it in its hosted browser (`browser_run_flow`) with the login taken from the vault or 1Password by name. If no automation exists yet for that site, offer a request (below). |

**Not available yet?** Ask: "DelegAIze doesn't connect to <system> yet. Shall I send a request to the
DelegAIze team? They will let you know as soon as it is available." If yes, call `report_issue` with:
which system, what DelegAIze should do with it (or which website steps to automate), and
`contact_email` = their email. Tell them: "The DelegAIze team may contact you if they need login
details or access to your account to set this up for you — that happens directly with them, never
through this chat."

Afterwards call `list_my_integrations` and tell them what is connected and what is still missing.

## 5. First result: which agents should work for them

Once a mailbox or messenger is connected (give the first sync a few minutes), offer:
"Shall I look at what arrives and suggest agents that take work off you?"
First ask which sources to base it on: which mailboxes (`list_mailboxes`) and/or which messenger
channels. Then call `suggest_agents` with `sources` (`mail`, `messenger`) and, if they narrowed it,
`mailbox_ids` / `channels`. Present each suggestion with its name, what it would do and how much of the
incoming items it covers (counted by DelegAIze, not estimated). Set up only the ones they choose
(`provision_agent`), and tell them that every message to the outside waits for their approval first.

## If something fails

- `rate_limited` on start: wait 15 minutes.
- The person has no account and registration needs an invitation in their company: they ask their
  DelegAIze admin for an invite, then start again.
- Help and documentation: `https://delegaize.innov-ai-tive.de/mcp`.
