ably
БесплатноБез исполняемых скриптовНе проверенAbly is a hosted realtime messaging service: clients publish and subscribe to named channels over WebSockets, see who is present, replay message history, and…
Об этом скилле
Ably — Realtime Infrastructure as a Service
Overview
Ably is a managed pub/sub platform. An application publishes messages to named channels and every subscribed client receives them over a WebSocket connection that the SDK keeps alive and resumes after a short network drop. On top of plain messaging it provides presence (who is on a channel), message history, token authentication with per-channel permissions, and a separate Chat SDK with rooms, typing indicators and reactions.
Two clients exist in the ably package: Ably.Realtime holds a connection and can subscribe; Ably.Rest is stateless HTTP and is the right choice for servers and serverless functions that only publish or issue tokens.
Instructions
Install
npm install ably
npm install @ably/chat # Chat SDK, optional; built on top of ably
npm install jsonwebtoken # server side, to sign tokens for browser clients
Create an app in the Ably dashboard and copy an API key. A key looks like I2E_JQ.OqUdfg:EVKVT...: the part before the colon is the key name, the part after it is the secret. Keep it in ABLY_API_KEY on the server only.
Authenticate clients with a JWT
Browsers and mobile apps must never receive the API key. The server signs a short-lived JWT with the key secret; the SDK fetches it through authUrl (or authCallback) and renews it before it expires.
// server/ably-token.ts
import jwt from "jsonwebtoken";
const [keyName, keySecret] = process.env.ABLY_API_KEY!.split(":");
export function createAblyToken(userId: string): string {
return jwt.sign(
{
"x-ably-clientId": userId,
// capability is a JSON string: resource -> allowed operations
"x-ably-capability": JSON.stringify({
"orders:*": ["subscribe", "history"],
[`notifications:${userId}`]: ["subscribe"],
"support:*": ["publish", "subscribe", "presence", "history", "message-update-own"],
}),
},
keySecret,
{ algorithm: "HS256", keyid: keyName, expiresIn: "1h" }, // 24 hours is the maximum
);
}
Return that string as the plain-text body of an authenticated endpoint such as GET /api/ably-token. ably.auth.createTokenRequest({ clientId, capability }) on an Ably.Rest client is the older alternative; it still works, but JWTs are the format Ably recommends.
Publish, subscribe and presence (Realtime)
// client/orders.ts
import * as Ably from "ably";
const realtime = new Ably.Realtime({ authUrl: "/api/ably-token" });
await realtime.connection.once("connected");
const channel = realtime.channels.get("orders:store-17");
// subscribe() attaches the channel; filter by event name or receive everything
await channel.subscribe("status-update", (message) => {
console.log(message.name, message.data, message.clientId, message.timestamp);
});
// Publishing needs the publish capability; the token above grants it on support:* only
const lobby = realtime.channels.get("support:lobby");
await lobby.publish("question", { text: "Is anyone from billing online?" });
// Presence needs an identified client (clientId comes from the token)
await lobby.presence.subscribe((member) => {
console.log(member.action, member.clientId, member.data); // enter | leave | update | present
});
await lobby.presence.enter({ name: "Dana Whitfield", status: "available" });
await lobby.presence.update({ name: "Dana Whitfield", status: "busy" });
const members = await lobby.presence.get();
console.log("Online:", members.map((m) => m.clientId));
realtime.close(); // release the connection when the page or process is done
History and rewind
Messages are kept for two minutes by default, enough for the SDK to resume a dropped connection. Longer retention is switched on with a channel rule in the app settings: a match expression such as orders:* with "Persist all messages" enabled (24 hours on the free plan, 72 hours on paid plans).
// client/history.ts
import * as Ably from "ably";
const realtime = new Ably.Realtime({ authUrl: "/api/ably-token" });
// Option 1, rewind: attach and immediately receive the last 10 messages, then live ones
const feed = realtime.channels.get("orders:store-17", { params: { rewind: "10" } });
await feed.subscribe((message) => console.log(message.data));
// Option 2, history: page backwards from the point of attachment, with no gap.
// Pick one: the first history page repeats the messages rewind already delivered.
const page = await feed.history({ untilAttach: true, limit: 50 });
for (const message of page.items) console.log(message.timestamp, message.data);
if (page.hasNext()) {
const older = await page.next();
console.log(older?.items.length);
}
Publish from a server (REST)
// server/notify.ts
import * as Ably from "ably";
const rest = new Ably.Rest({ key: process.env.ABLY_API_KEY });
// No connection is opened: one HTTP request per publish
await rest.channels.get("notifications:usr_8f3
Установить ably в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл ably?
Ably is a hosted realtime messaging service: clients publish and subscribe to named channels over WebSockets, see who is present, replay message history, and resume after a dropped connection. Use when a user asks to "add realtime updates", "push live notifications to the browser", "show who is online", "add a chat room with typing indicators", "publish from a serverless function", or "authenticate Ably clients without exposing the API key". Covers the ably 2.x JavaScript SDK (Realtime and REST), JWT token authentication, presence, history and rewind, batch publishing, and the @ably/chat 1.x SDK.
Как установить скилл ably?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ably запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic