@sokko/flue
v0.3.1
Published
This package wires a Flue agent to Sokko. It selects the Sokko-managed model, and it mounts Sokko policy around Flue's native Slack and Telegram webhook channels. It uses `@flue/slack` and `@flue/telegram` for request verification and routing. The agent s
Readme
@sokko/flue
This package wires a Flue agent to Sokko. It selects the Sokko-managed model, and it mounts
Sokko policy around Flue's native Slack and Telegram webhook channels. It uses @flue/slack
and @flue/telegram for request verification and routing. The agent sends replies itself
through a bound reply tool, so the package adds no background runner.
Model
Register the Sokko-managed provider once at module scope. Read the model inside the agent.
import { setSokkoProvider } from '@sokko/flue';
setSokkoProvider();'use agent';
import { useSokkoModel } from '@sokko/flue';
export function Assistant() {
useSokkoModel();
return '…your system prompt…';
}setSokkoProvider() reads the Sokko model environment and registers one Flue provider: OpenAI,
Anthropic, OpenRouter, or the ChatGPT subscription. useSokkoModel() selects the model id.
Sokko sets that id from the Model tab as FLUE_MODEL. Pass useSokkoModel({ modelId }) to pin
a model in code. Pass useSokkoModel({ fallbackModelId }) to set a default. The precedence is
modelId, then FLUE_MODEL, then fallbackModelId. The provider and the credential always come
from Sokko, so a pinned id must be one that provider can serve.
Channels
import { mountSokkoChannels } from '@sokko/flue';
mountSokkoChannels(app, { agent: Assistant });The mount adds these routes when their credential pairs are present:
POST /channels/slack/eventsPOST /channels/telegram/webhook
The package does not add a Slack interactions or slash-command route. Sokko does not expose or advertise those surfaces for Flue agents.
Environment
Slack requires SLACK_BOT_TOKEN and SLACK_SIGNING_SECRET. Telegram requires
TELEGRAM_BOT_TOKEN and TELEGRAM_WEBHOOK_SECRET_TOKEN. A partial credential pair throws
when the application mounts the channels.
The package also reads Sokko's provider policy variables:
SLACK_ALLOWED_USERSSLACK_REQUIRE_MENTIONTELEGRAM_ALLOWED_USERSTELEGRAM_GROUP_ALLOWED_CHATSTELEGRAM_GROUP_ALLOWED_USERSTELEGRAM_REQUIRE_MENTION
Inbound dispatch
The verified callback applies policy and dispatches one Flue message, then returns 200.
The dispatch carries the provider redelivery id as its idempotencyKey (a Slack event_id
or a Telegram update_id), so Flue delivers and answers each event at most once. The dispatch
also carries an initialData seed that names the reply destination.
Reply delivery
The agent replies by calling a bound reply tool. Add one line inside the agent function.
'use agent';
import { useSokkoModel, useSokkoChannelReply } from '@sokko/flue';
export function Assistant() {
useSokkoModel();
useSokkoChannelReply();
return 'Reply in the bound channel conversation when appropriate.';
}useSokkoChannelReply() reads the dispatch seed with useInitialData() and binds the matching
reply tool with useTool. The tool posts to the same Slack thread or Telegram conversation and
reads SLACK_BOT_TOKEN or TELEGRAM_BOT_TOKEN from the pod environment. The hook is a no-op when
the instance has no channel seed.
Bind a reply tool directly with sokkoSlackReply({ channelId, threadTs }) or
sokkoTelegramReply({ chatId, messageThreadId }) when the agent reads the destination itself.
