Skip to content

@uclaw/sdk

Use @uclaw/sdk from trusted server environments. Browser apps should use @uclaw/sdk/react with short-lived client tokens.

AppClient

ts
import { AppClient } from "@uclaw/sdk";

const app = new AppClient({
  apiKey: process.env.UCLAW_API_KEY,
  appId: "default",
});

Constructor

ts
new AppClient(options?: AppClientOptions)
ts
interface AppClientOptions {
  url?: string;
  apiKey?: string;
  appId?: string;
}

AgentsResource

app.agents manages the app-level agent directory.

ts
const agent = await app.agents.create({
  title: "Research agent",
  config: {
    instructions: "Be concise.",
  },
});

const agents = await app.agents.list();
const existing = app.agents.get(agent.id);
await app.agents.rename(agent.id, "Renamed agent");
await app.agents.delete(agent.id);

Methods

ts
app.agents.create(input?: CreateAgentInput): Promise<AgentClient>
app.agents.list(): Promise<AgentSummary[]>
app.agents.get(agentId: string): AgentClient
app.agents.rename(agentId: string, title: string): Promise<void>
app.agents.delete(agentId: string): Promise<void>

AgentClient

AgentClient represents one managed runtime agent.

ts
const agent = app.agents.get("agent-id");

await agent.updateConfig({
  instructions: "Answer in short paragraphs.",
  maxSteps: 20,
});

const config = await agent.currentConfig();
await agent.rename("Support assistant");

Methods

ts
agent.run(input: string): Promise<Run>
agent.updateConfig(patch: AgentConfig): Promise<AgentConfig>
agent.currentConfig(): Promise<AgentConfig>
agent.rename(title: string): Promise<void>

Run

Run is a client-side execution handle for the current SDK process. It caches stream events and status changes in memory.

ts
const run = await agent.run("Draft a launch checklist.");

await run.wait({ until: "running", timeoutMs: 60_000 });

for await (const event of run.stream()) {
  if (event.type === "text-delta") {
    process.stdout.write(event.delta);
  }
}

const state = await run.getStatus();

Methods

ts
run.getStatus(): Promise<RunState>
run.wait(options?: RunWaitOptions): Promise<RunState>
run.stream(options?: RunStreamOptions): AsyncGenerator<RunEvent>

RunEvent is a Vercel AI SDK UIMessageChunk. text-delta chunks are common for plain text streaming, but tools and other agent events may produce different chunk types.

App-Level Generation

For one-off model calls that do not need a persistent agent:

ts
const text = await app.generateText("Write a tagline.", {
  modelTier: "fast",
});

for await (const delta of app.streamText("Draft an announcement.")) {
  process.stdout.write(delta);
}

Stable Server-Side Surface

Use app.agents.*, AgentClient, and agent.run for all new server-side integrations.