
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@pear-protocol/agent-sdk
Advanced tools
TypeScript client for the Pear **agent chat** API — the conversational assistant (pair-trade ideas, market data, and confirm-before-write trade execution).
TypeScript client for the Pear agent chat API — the conversational assistant (pair-trade ideas, market data, and confirm-before-write trade execution).
@pear-protocol/agent-sdk — framework-agnostic core (AgentChatClient).@pear-protocol/agent-sdk/react — optional React hooks (useAgentChat, useAgentSessions).Published to public npm (same registry as the org's other @pear-protocol
packages — no .npmrc or token needed). The wire types are a single source of
truth shared with the backend, so they can't silently drift.
pnpm add @pear-protocol/agent-sdk zod
# only if you use the React hooks:
pnpm add react
zod@^4.1.0 is a required peer dependency (the SDK ships zod schemas at
runtime). react@>=18 is required only for the /react hooks.
import { AgentChatClient } from "@pear-protocol/agent-sdk";
const client = new AgentChatClient({
// Inject your env — the SDK NEVER reads it.
baseUrl: import.meta.env.VITE_AGENT_PEAR_API_URL, // Vite
// baseUrl: process.env.NEXT_PUBLIC_AGENT_PEAR_API_URL, // Next.js
getToken: () => auth.accessToken, // returns the freshest JWT; called per request
tokenVersion: "v2", // "v2" wallet JWT (default) | "v3"
});
const { id } = await client.createSession();
for await (const ev of client.streamChat({ sessionId: id, message: "Long ETH short BTC?" })) {
if (ev.type === "token") process.stdout.write(ev.delta);
if (ev.type === "done" && ev.result.pendingAction) {
// A money-moving trade was STAGED, not executed — render Confirm/Cancel.
await client.confirmTicket(ev.result.pendingAction.ticketId);
// ...or: await client.cancelTicket(ev.result.pendingAction.ticketId);
}
}
streamChat yields token | thinking | status | sources events, then a
synthetic { type: "done", result }. Token text is delta-only — accumulate
ev.delta. The SSE wire has no terminal done frame; the SDK assembles one. If
the backend emits a mid-stream error, streamChat throws an AgentChatError.
Aborting the stream (the hook's stop(), or your own AbortSignal) also stops
generation server-side — the backend detects the disconnect and winds the
worker job down at the next safe boundary (never mid-trade-write).
There's also a sync client.sendMessage({ sessionId, message }) returning a
ChatResult, and sessions/history methods (listSessions,
listSessionSummaries, createSession, getSession, deleteSession,
getMessages).
import { useAgentChat } from "@pear-protocol/agent-sdk/react";
function Chat({ client }) {
const {
messages, sendMessage, isStreaming, status, stop,
pendingAction, confirmTicket, cancelTicket, mode, setMode,
} = useAgentChat({ client });
// render `messages`; if `pendingAction`, show Confirm/Cancel buttons wired to
// confirmTicket(pendingAction.ticketId) / cancelTicket(pendingAction.ticketId)
}
useAgentChat uses plain React state (no forced data lib). useAgentSessions(client)
is a minimal session-list hook; apps using TanStack Query can skip it and call the
client directly.
getToken() returns whatever bearer token the agent API accepts (today a v2
HL-issued JWT). The SDK sends Authorization: Bearer <token> +
X-Auth-Token-Version. It does NOT own sign-in — wire it to your wallet/auth
flow. v3 callers are identity-only (no wallet → trade tickets disabled).
confirmTicket / cancelTicket throw typed errors: TicketExpiredError (410),
ForbiddenError (403, not your ticket), ConflictError (409, already handled),
AuthError (401). All extend AgentChatError (carries .status).
A turn that would move money returns a pendingAction
({ ticketId, action, consequence, options: ["confirm","cancel"] }) instead of
executing. Render it, then call confirmTicket(ticketId) (executes) or
cancelTicket(ticketId) (discards). setTradeConfirmations(false) opts a user out
of the confirm step entirely.
FAQs
TypeScript client for the Pear **agent chat** API — the conversational assistant (pair-trade ideas, market data, and confirm-before-write trade execution).
The npm package @pear-protocol/agent-sdk receives a total of 210 weekly downloads. As such, @pear-protocol/agent-sdk popularity was classified as not popular.
We found that @pear-protocol/agent-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.