Scan your whole stack
From OX Research Newsroom
Are you using sarvam-agents-client?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.4.1
sarvam-agents-client was last scanned on 23 Nov 2026 at version 0.4.1. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.4.1 LATEST | 23 Nov 2026 | No rules fired |
| 0.4.0 | 19 Nov 2026 | No rules fired |
| 0.3.2 | 18 Nov 2026 | No rules fired |
| 0.3.1 | 16 Nov 2026 | Not shown |
| 0.3.0 | 12 Nov 2026 | Not shown |
Findings for v0.4.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.4.1; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
TypeScript/JavaScript client for the Sarvam Agents API. Use it to chat with an agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code.
fetch, so it works in Node 18+.npm install sarvam-agents-client
Every call needs:
Authorization: Bearer <token>X-Panja-Origin: managed_agentsRun this SDK on your server. A service token in browser code is readable by anyone who opens the page. The API also doesn't accept browser requests from other websites, so a web app has to call your backend, and your backend calls this SDK.
The agent must be a managed agent and must be deployed (AgentsApi.deployAgent). If it isn't, sending it a message
fails with 409 CHAT_CONFLICT, and details[0].reason is "AGENT_NOT_DEPLOYED".
import { Configuration, AgentsApi, ConversationsApi } from "sarvam-agents-client";
const config = new Configuration({
basePath: "https://chat.sarvamclaw.sarvam.ai",
accessToken: process.env.SARVAM_AGENTS_TOKEN,
headers: { "X-Panja-Origin": "managed_agents" },
});
const agentId = process.env.SARVAM_AGENTS_AGENT_ID!;
const agent = await new AgentsApi(config).getAgent({ agentId });
console.log(agent.name, agent.deployState);
const conversation = await new ConversationsApi(config).createConversation({
createConversationBody: { agentId, title: "Hello from TypeScript" },
});
streamResponse gives you the reply event by event, as the agent writes it.
The generated ResponsesApi.createResponse works differently: it waits for the whole turn to finish, which can take
minutes, and then returns all the raw event text as one string.
import { streamResponse } from "sarvam-agents-client";
const stream = await streamResponse(config, {
id: conversation.id, // same id again = next turn in the same conversation
agentId,
message: {
id: crypto.randomUUID(),
role: "user",
parts: [{ type: "text", text: "What can you help me with?" }],
},
});
for await (const event of stream) {
if (event.type === "text-delta") process.stdout.write(event.delta);
else if (event.type === "data-file-shared") console.log("\n[file]", event.data.filename);
else if (event.type === "error") console.log("\n[error]", event.errorText);
}
Each event is a plain object with a type. The types are:
type |
What it means |
|---|---|
start |
The reply has started |
text-delta |
The next piece of the reply's text |
data-file-shared |
The agent shared a file |
data-clarify-request |
The agent is asking you a question |
data-stopped |
The reply was stopped |
error |
Something went wrong |
finish |
The reply is complete |
Reconnect after a dropped connection. The stream remembers stream.responseId and stream.lastEventId. Pass
them to reconnect to continue from where it stopped:
import { reconnect } from "sarvam-agents-client";
const resumed = await reconnect(config, conversation.id, stream.responseId!, stream.lastEventId);
for await (const event of resumed) { /* ... */ }
The resumed stream restarts at the beginning of the current block of text. If you were partway through a block, throw away that partial text and use what arrives instead.
Answer a question from the agent. When you get a data-clarify-request event, answer it with answerClarify. It
streams the rest of the reply:
answerClarify(config, conversation.id, { requestId, answers: { ... } })
Answer the agent's function calls. An agent with function tools (agent.json functions) pauses on a
data-function-call-request event (requestId, calls with toolCallId, name and arguments, expiresAt). Run
the calls, then post every result in one request with postToolResults. It streams the rest of the turn:
postToolResults(config, conversation.id,
{ requestId, results: [{ toolCallId: "call_1", output: '{"status": "shipped"}' }] }, { idempotencyKey })
Use the same idempotencyKey when you retry a post: a repeat the server already delivered resolves to an empty
stream with duplicate set (follow the turn with reconnect). Errors are the response's own status (409 with a
reason such as in_progress or expired, 503 to retry with the same key; see
the function tools guide). Compose's tool() does all of this for you.
Timeouts. Every ordinary call is aborted after 120 seconds unless you pass your own signal. To change that
limit for the whole SDK, set defaults.requestTimeoutMs. A stream is aborted if no data arrives for 60 seconds. A healthy stream never hits this, because the
server sends a ping every 15 seconds. You can change the limit with { idleTimeoutMs }. To cancel from your own code,
pass { signal }. If you stop reading early, call stream.close().
To attach a file to a message:
ArtifactsApi.mintUploadUrl to get an upload URL.PUT the file to that URL. Don't send your token with this request.ArtifactsApi.commitArtifact with the file's SHA-256.parts:{ type: "file", mediaType, filename, providerMetadata: { custom: { artifactId, filename } } }
To get the files the agent shares, list them with ArtifactsApi.listConversationArtifacts, then get a link for each
one with ArtifactsApi.downloadUrl.
| Task | Call |
|---|---|
| Instructions | AgentsApi.getInstructions / putInstructions |
| Deploy | AgentsApi.deployAgent / undeployAgent |
| Skills | SkillsApi.listAgentSkills, bindSkill, unbindSkill, createSkillForAgent |
| Knowledge bases | CollectionsApi.listAgentCollections, bindAgentToCollection, then upload files: initFileUpload → PUT → completeFileUpload → poll getFile |
| Connectors | AppsApi.listApps, listAgentApps, bindApp, unbindApp, connectApp |
Define an agent in code, deploy it by name and run it with sarvam-agents-client/compose (a separate import path; the
package root is unchanged). Function tools (tool(), run in your process), structured output and clarify questions
are handled for you:
import { Agent, run, deploy } from "sarvam-agents-client/compose";
const agent = new Agent({ name: "support-bot", instructions: "Answer billing questions." });
await deploy(agent, { client: config });
console.log((await run(agent, "How do I update my card?", { client: config })).finalOutput);
See docs/compose.md for the full guide.
An agent can POST an event to your server when a turn completes, fails or waits for an answer. The server must have
outbound webhooks switched on; until then a deploy keeps the setting and logs the warning webhooks_disabled.
1. Name the endpoint on the agent (agent.json webhooks) and deploy:
import { Agent, deploy } from "sarvam-agents-client/compose";
const agent = new Agent({ name: "support-bot", instructions: "...", webhooks: [
{ url: "https://hooks.acme.com/panja", events: ["turn.completed", "turn.failed", "turn.requires_action"] },
] });
const deployment = await deploy(agent, { client: config });
Leave secretCredential out: the deploy fills in the credential that client.webhooks manages for that agent and
host. The first deploy of a webhook with no secret yet stores a random placeholder secret, that nobody holds, so the
server accepts the webhook, and lists the webhook's URL in deployment.webhooksMissingSecret. While the placeholder
is there, secretStatus reads "missing".
Call client.webhooks.setSecret right after the first deploy, before pointing a provider at the agent. Until then
deliveries fail verification, and a receiver that answers 4xx makes Panja drop them.
2. Set the signing secret with client.webhooks:
import { Client } from "sarvam-agents-client";
const client = new Client(config); // config: the Configuration from the Quickstart
const url = "https://hooks.acme.com/panja";
const secret = await client.webhooks.setSecret(deployment.agentId, url); // generates a whsec_ secret and returns it
// or: await client.webhooks.setSecret(agentId, url, "whsec_...") to store one you made
await client.webhooks.secretStatus(agentId, url); // "set" or "missing" ("missing" while the deploy placeholder is there)
const newSecret = await client.webhooks.rotateSecret(agentId, url);
await client.webhooks.deleteSecret(agentId, url);
Keep the returned secret where your receiver runs: Panja never shows it again. A secret that is not whsec_ plus
base64 of 24 to 64 bytes throws SecretFormatError before anything is sent. It works as in Python (see the
Python README): today the secret is a Custom API the SDK creates and binds, named
webhook-secret:<agentId>:<host>, with "enabled for chats" always off; deleteSecret only removes that one; a
later release moves secrets to a dedicated server store with no change to client.webhooks. Nothing logs a secret or
puts one in an error message.
secretCredential: "acme_webhook" still works, but is @deprecated: it names a Custom API you created and bound
yourself. To migrate, use client.webhooks.setSecret instead of creating a Custom API: call
setSecret(agentId, url, currentSecret), drop secretCredential and deploy, then unbind and delete the old Custom
API (unbindCustomApi, deleteCustomApi).
The rules are Python's (see the Python README), with the same UserError messages,
which name the agent.json path (webhooks.0.url: ...). Checks that need the server fail the deploy
(and delete an agent the deploy created) with UserError, whose issues hold the server's { code, path, message } list; a server without webhooks throws
NotSupportedByServerError with features ["webhooks"].
3. Verify and parse each delivery from sarvam-agents-client/webhooks (a separate import path; node:crypto
only, so Node 18+ or a runtime with Node's crypto and Buffer, such as Workers with nodejs_compat; not a browser
or an edge runtime without them), on the raw body bytes (express.raw(), not express.json()):
import { parseEvent, verify, WebhookVerificationError } from "sarvam-agents-client/webhooks";
let msgId: string;
try {
({ msgId } = verify(req.body, req.headers, secret)); // or [oldSecret, newSecret] while rotating
} catch (e) {
if (e instanceof WebhookVerificationError) return res.status(400).send(e.reason);
throw e;
}
const event = parseEvent(req.body);
if (event?.type === "turn.completed") console.log(event.data.text, event.data.output);
verify(payload, headers, secret, { tolerance, now }) takes a Buffer/Uint8Array or string body, and Node's
req.headers or a fetch Headers. It behaves exactly like Python's verify and the server's reference verifier,
and both SDKs run the server's test vectors. It returns { msgId, timestamp }; e.reason and SecretFormatError
are as in Python; an empty list of secrets throws TypeError. A header given as an array counts as missing.
parseEvent returns the JSON as sent, typed by its type (TurnCompletedEvent, TurnFailedEvent,
TurnRequiresActionEvent; narrow with event.type), or undefined for an event type this release doesn't know. It
checks the envelope and data.status and throws TypeError for a body that is not an event. A newer server may send
an action type this release doesn't know (typed UnknownAction, passed through as sent), so keep a default branch
when you switch on action.type. Answer a clarify action with answerClarify and a function_call action with
postToolResults (one result per toolCallId); a turn the SDK runner is driving answers its own function calls, so
leave those alone (a second answer gets 409 already_answered). The fields are listed
in the Python README, in camelCase here (data.turn.responseId, outputSkipped,
rawText, actions[i].toolCallId).
Reply 2xx within 10 seconds and do the work afterwards. Only a 2xx stops the retries: a 408, 425, 429, 5xx, timeout
or network failure is retried (10 attempts over about 16 hours), while a 3xx or any other 4xx is given up at once.
So return a 5xx (or 429) for a failure you want retried, never a 4xx. Dedupe on msgId. Starting a delivery is best effort: if an event you expect doesn't come, read the turn from the conversation
API. A complete Express receiver is in
docs/examples/webhooks/express_receiver.ts.
If an ID passed as a path parameter is empty, . or .., the SDK throws InvalidPathParameterError before
sending anything. Those values would otherwise change which resource the request reaches.
If the server answers with a 4xx or 5xx status, the SDK throws ResponseError. The streaming helpers do too.
err.response is the fetch Response, so you can read the status and the error body from it:
try {
await new AgentsApi(config).deployAgent({ agentId });
} catch (err) {
if (err instanceof ResponseError) console.log(err.response.status, await err.response.text());
}
Most of this package is generated. To rebuild it, see regen/README.md.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.