# Registering the MiniMax Adapter in Paperclip

This document shows the exact edits needed to register
`paperclip-adapter-minimax` as an adapter in your Paperclip deployment.

## 1. Install the package

```bash
# From inside the monorepo:
cd paperclip-adapter-minimax
npm install
npm run build

# Or from a published package (once on npm):
npm install paperclip-adapter-minimax
```

## 2. Edit `server/src/adapters/registry.ts`

```diff
@@ -1,6 +1,7 @@
 import { openrouterAdapter } from "@paperclip-adapter/openrouter";
 import { opencodeLocal } from "../opencode-local/index.js";
 import { claudeLocal } from "../claude-local/index.js";
+import { minimaxAdapter } from "@uthotyan/paperclip-adapter-minimax";
 
 export const adapterRegistry = {
   openai: openaiAdapter,
   anthropic: anthropicAdapter,
   opencode: opencodeLocal,
   claude: claudeLocal,
   openrouter: openrouterAdapter,
+  minimax: {
+    ...minimaxAdapter.metadata,
+    run: minimaxAdapter.run.bind(minimaxAdapter),
+  },
 };
 
 export function getAdapter(name: string) {
   return adapterRegistry[name];
 }
```

## 3. (Optional) Update `server/src/heartbeat/dispatcher.ts`

The community `paperclip-adapter-openrouter` pattern needs the dispatcher to
recognize that adapters with `supportsLocalAgentJwt: true` are eligible for
the per-run JWT mint. If your Paperclip version is recent enough, this is
already wired up — verify by reading the dispatcher:

```bash
grep -n supportsLocalAgentJwt server/src/heartbeat/dispatcher.ts
```

If that grep returns nothing, add the following patch:

```diff
@@ -12,7 +12,9 @@
   const adapter = getAdapter(agent.adapter);
   if (!adapter) throw new Error(`unknown adapter: ${agent.adapter}`);
-  if (adapter.supportsLocalAgentJwt) {
+  if (adapter.supportsLocalAgentJwt || adapter.name === "minimax") {
     const jwt = await createLocalAgentJwt({ ... });
     process.env.PAPERCLIP_API_KEY = jwt;
   }
```

## 4. Edit `server/package.json`

Add the dependency:

```diff
   "dependencies": {
     "@paperclipai/server": "...",
+    "@uthotyan/paperclip-adapter-minimax": "^0.1.0",
   }
```

Or, if you're working inside the monorepo, register the workspace:

```diff
   "workspaces": [
     ".",
+    "../paperclip-adapter-minimax"
   ]
```

## 5. Restart Paperclip

```bash
cd server
npm install     # picks up the new dep
npm run dev     # or however you boot
```

## 6. Verify

```bash
cd paperclip-adapter-minimax
MINIMAX_API_KEY=... PAPERCLIP_API_KEY=... npm run dev -- doctor
```

You should see `✅ minimax connection` in the output.

In the Paperclip UI:

1. Create or edit an agent.
2. Set its **Adapter** to `minimax`.
3. Set **Model** to `MiniMax-M3` (or whichever catalog ID you want).
4. Wake the agent; the transcript should appear in the live Working panel.
5. Confirm the per-run JWT works by clicking on the heartbeat and verifying
   no `401 Unauthorized` rows in the activity log.

---

## Why this works

Paperclip's adapter contract was designed to be open. The official
`@paperclipai/server` package exposes `createLocalAgentJwt()` for any package
that wants to authenticate as a local agent, and adapters that return
`supportsLocalAgentJwt: true` get the per-run JWT injected into their env.
This package implements that contract — it does not require a fork of
Paperclip.

If you find an edge case where this adapter doesn't fit, please open an
issue on this repo (or on Paperclip's repo, with a tag for
`paperclip-adapter-minimax`).
