@archerprotocol/sdk
v0.6.0
Published
Build, monetize, and publish an Archer intent: typed envelope builders, caller context, and a one-call request handler.
Downloads
1,402
Maintainers
Readme
@archerprotocol/sdk
Build, monetize, and publish a service as an Archer intent.
- Verify inbound Archer requests in one line (re-exported from
@archerprotocol/verify). - Return the generic response envelope with typed builders:
archer.data,archer.cost,archer.authorization,archer.record. - Read the caller's context with
getArcherCaller(args). - Wire it all together with
createArcherIntent({ handler }).
Install
npm install @archerprotocol/sdkA read intent
Return archer.render({ text, embed }) so your data renders in the Archer GUI. The
embed builders mirror the whitelisted render kinds (chart, metric, table,
kv, alert, image).
import express from 'express';
import { createArcherIntent, archer } from '@archerprotocol/sdk';
const app = express();
app.use(express.json());
app.post('/price', createArcherIntent({
handler: async ({ args }) => {
const p = await lookupPrice(args.ticker);
return archer.render({
text: `${args.ticker} is $${p.usd}`,
embed: archer.embed.metric({ label: args.ticker, value: `$${p.usd}` }),
});
},
}));A funds intent
import { createArcherIntent, archer, requireArcherCaller } from '@archerprotocol/sdk';
export const deposit = createArcherIntent({
handler: async ({ args }) => {
const caller = requireArcherCaller(args);
const tx = await composeDeposit(caller.evmAddress, args.amount);
return archer.envelope({
cost: archer.cost({ model: 'embedded', archerFeeMicro: feeMicro }),
authorizations: [archer.authorization({ type: 'tx', namespace: 'evm', label: 'Deposit', payload: tx })],
record: archer.record({ recordKind: 'position', basisMicro: amountRaw, groupKey: vault }),
});
},
});Publish your intent
The archer CLI ships with this package. It turns a manifest into a live,
monetized intent.
# 1. scaffold a manifest (writes archer.intent.json + its JSON Schema)
npx @archerprotocol/sdk init
# 2. authenticate with a publish-scoped API key from your developer dashboard
archer auth login --token sk_live_...
# 3. publish (idempotent by handle)
archer publish
# 4. probe the endpoint and go live
archer activate @MyBot
# 5. track hits and fees
archer stats @MyBot --since 30dA published intent starts inactive: hidden from discovery, but you can still
invoke your own while you test it. archer activate runs the endpoint probe and
makes it public.
Other commands: archer list, archer status @MyBot, archer deactivate @MyBot,
archer delete @MyBot. Add --json to any command for machine-readable output,
and --base-url <url> or the ARCHER_API_URL environment variable to target a
specific deployment.
Browser sign-in (archer auth login with no token) is coming soon. Until then,
mint a key in the developer dashboard and pass it with --token.
License
Apache-2.0
