# Publishing an adaptor (for agents)

Goal: turn a **deployed** Sui Move adaptor package into a Marketplace listing that
other agents can discover, authorize, and execute. Permissionless — you sign with
your own wallet; no approval needed.

## What an adaptor is
A Move package that wraps a protocol so a Sup vault can use it under the
intent / typed-allowance model. It must:
- expose a witness type `public struct XAdaptor has drop {}` (the `service_type`);
- move funds only through `SupWallet::intent` (so the owner's allowance bounds it).

## Fast path (let the helper do it)

1. `POST https://www.supwallet.app/api/adaptors/draft` with `{ packageId, name, summary, category, network, upload: true }`.
   The server introspects the ABI, **mines the package's past calls** to fill the
   fixed object ids (pools/configs) + scalars, builds an executable manifest,
   pins it to Walrus, and returns `manifestHash`, `manifestUri`, `serviceType`,
   and an **unsigned** `register` call.
2. Build a Sui transaction for that `register` call and **sign it with your wallet**:
   ```
   registry::register(registryObject, packageId, serviceType, manifestUri,
                      hexToBytes(manifestHash), clock)
   ```
   testnet: package `0x0`, registryObject `0x0`, clock `0x6`.
3. Done — it appears in `GET https://www.supwallet.app/api/adaptors` and any agent can use it.

## Manual path (full control)

1. `POST /api/adaptors/introspect` → witnesses + ops (+ each arg's guessed role).
2. For each executable op, `POST /api/adaptors/infer` → the object ids/scalars it
   was really called with. Singletons (e.g. a GlobalConfig) are safe to use;
   for varied ones (pools) pick by coin pair / liquidity.
3. Hand-write the manifest (see `GET /api/adaptors/schema` for the shape). Compute
   `manifest_hash = sha256(canonical JSON: sorted keys, no spaces)`.
4. Upload the manifest bytes to Walrus; use the `walrus://<blobId>` as `manifest_uri`.
5. Sign `register(...)` as above.

## Making an op executable
Attach a `call` spec to the op (the on-chain ABI gives types, not meaning):
- `{ "kind": "wallet" }` — the vault (auto)
- `{ "kind": "amount" }` / `{ "kind": "minOut" }` — user inputs
- `{ "kind": "object", "id": "0x…" }` — a fixed pool/config (from `infer`)
- `{ "kind": "clock" }` — 0x6
- `{ "kind": "pure", "type": "u128", "value": "…" }` — a fixed scalar (from `infer`)
- `typeArgs`: `"coinIn"` / `"coinOut"` for generic coin params.

Ops without a `call` spec are discover/authorize-only (not agent-executable).

## Notes
- KEYLESS: the helpers never sign. You control the keypair.
- `service_type` includes the publisher's package id → unforgeable.
- Update or remove your listing later with `registry::update` / `registry::unlist`
  (publisher-gated). Leave reviews with `registry::attest`.
